ostree-repo-resolve-rev: Add function to accept a partial checksum
This patch adds a function that will parse a partial checksum when resolving a refspec. If the inputted refspec matches a truncated existing checksum, it will return that checksum to be parsed. If multiple truncated checksums match the partial refspec, it is not unique and will return false. This addition is inspired by the same functionality in Docker, which allows a user to reference a specific commit without typing the entire checksum. partial checksums: Add function to abstract comparison This modifies the list_objects and list_objects_at functions to take an additional argument for the string that a commit starts with. If this string arg is not null, it will only list commit objects beginning with that string. This allows for a new function ostree_repo_list_commit_objects_starting_with to pass a partial string and return a list of all matching commits. This improves on the previous strategy of listing refs because it will list all commit objects, even ones in past history. This update also includes bugfixes on error handling and string comparison, and changes the output structure of resolve_partial_checksum. The new strcuture will no longer return FALSE without error. Also, the hashtable foreach now uses iter. Also includes modified test file
This commit is contained in:
1 parent
3645afc6d7
commit
fd56952d6b
4 files changed
+170
-16
No files matched your search
@@ -34,6 +34,15 @@ $OSTREE rev-parse 'test2^'
|
||||
$OSTREE rev-parse 'test2^^' 2>/dev/null && (echo 1>&2 "rev-parse test2^^ unexpectedly succeeded!"; exit 1)
|
||||
echo "ok rev-parse"
|
||||
|
||||
checksum=$($OSTREE rev-parse test2)
|
||||
partial=${checksum:0:6}
|
||||
echo "partial:" $partial
|
||||
echo "corresponds to:" $checksum
|
||||
$OSTREE rev-parse test2 > checksum
|
||||
$OSTREE rev-parse $partial > partial-results
|
||||
assert_file_has_content checksum $(cat partial-results)
|
||||
echo "ok shortened checksum"
|
||||
|
||||
(cd repo && ostree rev-parse test2)
|
||||
echo "ok repo-in-cwd"
|
||||
|
||||
|
||||
Reference in new issue
Block a user