replace resolve_commit_arg() helper in got.c with got_repo_match_object_id()
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
diff --git a/got/got.c b/got/got.c
index 40ab964..3d41cd3 100644
--- a/got/got.c
+++ b/got/got.c
@@ -3676,54 +3676,6 @@ get_default_log_limit(void)
}
static const struct got_error *
-resolve_commit_arg(struct got_object_id **id, const char *commit_arg,
- struct got_repository *repo)
-{
- const struct got_error *err = NULL;
- struct got_reference *ref;
-
- *id = NULL;
-
- err = got_ref_open(&ref, repo, commit_arg, 0);
- if (err == NULL) {
- int obj_type;
- err = got_ref_resolve(id, repo, ref);
- got_ref_close(ref);
- if (err)
- return err;
- err = got_object_get_type(&obj_type, repo, *id);
- if (err)
- return err;
- if (obj_type == GOT_OBJ_TYPE_TAG) {
- struct got_tag_object *tag;
- err = got_object_open_as_tag(&tag, repo, *id);
- if (err)
- return err;
- if (got_object_tag_get_object_type(tag) !=
- GOT_OBJ_TYPE_COMMIT) {
- got_object_tag_close(tag);
- return got_error(GOT_ERR_OBJ_TYPE);
- }
- free(*id);
- *id = got_object_id_dup(
- got_object_tag_get_object_id(tag));
- if (*id == NULL)
- err = got_error_from_errno(
- "got_object_id_dup");
- got_object_tag_close(tag);
- if (err)
- return err;
- } else if (obj_type != GOT_OBJ_TYPE_COMMIT)
- return got_error(GOT_ERR_OBJ_TYPE);
- } else {
- err = got_repo_match_object_id_prefix(id, commit_arg,
- GOT_OBJ_TYPE_COMMIT, repo);
- }
-
- return err;
-}
-
-static const struct got_error *
cmd_log(int argc, char *argv[])
{
const struct got_error *error;
@@ -3870,12 +3822,14 @@ cmd_log(int argc, char *argv[])
goto done;
got_object_commit_close(commit);
} else {
- error = resolve_commit_arg(&start_id, start_commit, repo);
+ error = got_repo_match_object_id(&start_id, NULL,
+ start_commit, GOT_OBJ_TYPE_COMMIT, 1, repo);
if (error != NULL)
goto done;
}
if (end_commit != NULL) {
- error = resolve_commit_arg(&end_id, end_commit, repo);
+ error = got_repo_match_object_id(&end_id, NULL,
+ end_commit, GOT_OBJ_TYPE_COMMIT, 1, repo);
if (error != NULL)
goto done;
}
diff --git a/regress/cmdline/log.sh b/regress/cmdline/log.sh
index 6d76d89..81ae9fc 100755
--- a/regress/cmdline/log.sh
+++ b/regress/cmdline/log.sh
@@ -471,7 +471,7 @@ test_log_end_at_commit() {
return 1
fi
echo -n > $testroot/stdout.expected
- echo "got: nonexistent: bad object id string" \
+ echo "got: reference nonexistent not found" \
> $testroot/stderr.expected
cmp -s $testroot/stderr.expected $testroot/stderr
ret="$?"