-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When fetching, fetch all the relevant objects without leaving out any
- Loading branch information
Showing
6 changed files
with
109 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
function wp_git_get_all_descendant_oids_in_tree(WP_Git_Repository $repository, $tree_oid) { | ||
if(false === $repository->read_object($tree_oid)) { | ||
return false; | ||
} | ||
$oids = [$tree_oid]; | ||
$trees = [$tree_oid]; | ||
|
||
while (!empty($trees)) { | ||
$tree_hash = array_pop($trees); | ||
if (!$repository->read_object($tree_hash)) { | ||
_doing_it_wrong('wp_git_get_all_descendant_oids_in_tree', 'Failed to read object: ' . $tree_hash, '1.0.0'); | ||
return false; | ||
} | ||
$tree = $repository->get_parsed_tree(); | ||
foreach ($tree as $object) { | ||
$oids[] = $object['sha1']; | ||
if ($object['mode'] === WP_Git_Pack_Processor::FILE_MODE_DIRECTORY) { | ||
$trees[] = $object['sha1']; | ||
} | ||
} | ||
} | ||
return $oids; | ||
} | ||
|
||
function wp_git_get_parsed_commit(WP_Git_Repository $repository, $commit_oid) { | ||
if(false === $repository->read_object($commit_oid)) { | ||
_doing_it_wrong('wp_git_get_parsed_commit', 'Failed to read object: ' . $commit_oid, '1.0.0'); | ||
return false; | ||
} | ||
if($repository->get_type() !== WP_Git_Pack_Processor::OBJECT_TYPE_COMMIT) { | ||
_doing_it_wrong('wp_git_get_parsed_commit', 'Object was not a commit in find_objects_added_in: ' . $repository->get_type(), '1.0.0'); | ||
return false; | ||
} | ||
return $repository->get_parsed_commit(); | ||
} | ||
|
||
function wp_git_is_null_oid($oid) { | ||
return $oid === null || $oid === WP_Git_Repository::NULL_OID; | ||
} |