commit f2b6a97d56d8273e6e97080c1b86b1dedd174ef7 from: Stefan Sperling date: Mon Jul 15 17:06:05 2019 UTC allow branch names with tog log/blame/tree -c options commit - 2312fc47a59d27ed181e1a095baf45c8b88cffd6 commit + f2b6a97d56d8273e6e97080c1b86b1dedd174ef7 blob - 8801ee6c890f7fea8d134551d25cfa15ef92fcab blob + 419435b7c7b9acd5bed04c64feff1de3ccab0d23 --- tog/tog.c +++ 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;