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. ok stsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
diff --git a/got/got.c b/got/got.c
index a8e02bf..175740d 100644
--- a/got/got.c
+++ b/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;