Download raw body.
handle reference arguments that look like short object IDs
Christian Weisgerber:
> It looks like
> add_ref()
> cmd_cherrypick()
> cmd_backout()
> don't use got_repo_match_object_id() and have hand-rolled code that
> matches the old logic.
And this switches over cherrypick/backout to got_repo_match_object_id().
If I understand correctly, we don't want to match the argument against
tags, so we don't pass in a ref list.
OK?
-----------------------------------------------
commit b30bea7058e22ef67ac97330d0cfd76c112a3db5 (work)
from: Christian Weisgerber <naddy@mips.inka.de>
date: Thu Mar 10 21:48:07 2022 UTC
make "got cherrypick/backout" match argument against refs before object IDs
Use got_repo_match_object_id() instead of hand-rolled code and pick up
the updated handling of reference arguments.
M got/got.c
diff 4d52d6dcbc943de222768574d7ebf55ef9bd5ba2 aecff18a392b6da13c20f538dae5c6a9195164cf
blob - a8e02bf8f39f50b80a56e690e28c3ba7851cc7af
blob + 175740d9c6f4b9443624418107f8b2314f6f44b0
--- got/got.c
+++ got/got.c
@@ -8372,20 +8372,10 @@ cmd_cherrypick(int argc, char *argv[])
if (error)
goto done;
- error = got_repo_match_object_id_prefix(&commit_id, argv[0],
- GOT_OBJ_TYPE_COMMIT, repo);
- if (error != NULL) {
- struct got_reference *ref;
- if (error->code != GOT_ERR_BAD_OBJ_ID_STR)
- goto done;
- error = got_ref_open(&ref, repo, argv[0], 0);
- if (error != NULL)
- goto done;
- error = got_ref_resolve(&commit_id, repo, ref);
- got_ref_close(ref);
- if (error != NULL)
- goto done;
- }
+ error = got_repo_match_object_id(&commit_id, NULL, argv[0],
+ GOT_OBJ_TYPE_COMMIT, NULL, repo);
+ if (error)
+ goto done;
error = got_object_id_str(&commit_id_str, commit_id);
if (error)
goto done;
@@ -8479,20 +8469,10 @@ cmd_backout(int argc, char *argv[])
if (error)
goto done;
- error = got_repo_match_object_id_prefix(&commit_id, argv[0],
- GOT_OBJ_TYPE_COMMIT, repo);
- if (error != NULL) {
- struct got_reference *ref;
- if (error->code != GOT_ERR_BAD_OBJ_ID_STR)
- goto done;
- error = got_ref_open(&ref, repo, argv[0], 0);
- if (error != NULL)
- goto done;
- error = got_ref_resolve(&commit_id, repo, ref);
- got_ref_close(ref);
- if (error != NULL)
- goto done;
- }
+ error = got_repo_match_object_id(&commit_id, NULL, argv[0],
+ GOT_OBJ_TYPE_COMMIT, NULL, repo);
+ if (error)
+ goto done;
error = got_object_id_str(&commit_id_str, commit_id);
if (error)
goto done;
--
Christian "naddy" Weisgerber naddy@mips.inka.de
handle reference arguments that look like short object IDs