allow branch names with tog log/blame/tree -c options
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
diff --git a/tog/tog.c b/tog/tog.c
index 8801ee6..419435b 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -2240,9 +2240,15 @@ cmd_log(int argc, char *argv[])
error = get_head_commit_id(&start_id, worktree ?
got_worktree_get_head_ref_name(worktree) : GOT_REF_HEAD,
repo);
- else
- error = got_repo_match_object_id_prefix(&start_id,
- start_commit, GOT_OBJ_TYPE_COMMIT, repo);
+ else {
+ error = get_head_commit_id(&start_id, start_commit, repo);
+ if (error) {
+ if (error->code != GOT_ERR_NOT_REF)
+ goto done;
+ error = got_repo_match_object_id_prefix(&start_id,
+ start_commit, GOT_OBJ_TYPE_COMMIT, repo);
+ }
+ }
if (error != NULL)
goto done;
@@ -3706,8 +3712,13 @@ cmd_blame(int argc, char *argv[])
error = got_ref_resolve(&commit_id, repo, head_ref);
got_ref_close(head_ref);
} else {
- error = got_repo_match_object_id_prefix(&commit_id,
- commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
+ error = get_head_commit_id(&commit_id, commit_id_str, repo);
+ if (error) {
+ if (error->code != GOT_ERR_NOT_REF)
+ goto done;
+ error = got_repo_match_object_id_prefix(&commit_id,
+ commit_id_str, GOT_OBJ_TYPE_COMMIT, repo);
+ }
}
if (error != NULL)
goto done;
@@ -4432,9 +4443,15 @@ cmd_tree(int argc, char *argv[])
if (commit_id_arg == NULL)
error = get_head_commit_id(&commit_id, GOT_REF_HEAD, repo);
- else
- error = got_repo_match_object_id_prefix(&commit_id,
- commit_id_arg, GOT_OBJ_TYPE_COMMIT, repo);
+ else {
+ error = get_head_commit_id(&commit_id, commit_id_arg, repo);
+ if (error) {
+ if (error->code != GOT_ERR_NOT_REF)
+ goto done;
+ error = got_repo_match_object_id_prefix(&commit_id,
+ commit_id_arg, GOT_OBJ_TYPE_COMMIT, repo);
+ }
+ }
if (error != NULL)
goto done;