commit 93c250cd168c2e1d2f9997774c87cc2718373404 from: Mark Jamsek date: Mon Aug 07 07:10:28 2023 UTC got: allow 'got log -x' to accept keywords Suggested by Lucas on IRC. ok stsp@ and op@ commit - 0f2e686eec562e28977521d25101acfa4396b47a commit + 93c250cd168c2e1d2f9997774c87cc2718373404 blob - 9c2fa4cf0f0253f379430b774f532e2e54e6ebc3 blob + 10a6aa7aa384b8d8773e28516972143fd0c7c93a --- got/got.1 +++ got/got.1 @@ -1039,6 +1039,12 @@ option. Stop traversing commit history immediately after the specified .Ar commit has been traversed. +Like +.Fl c , +the expected +.Ar commit +argument is a commit ID SHA1 hash, or a reference name or a keyword +which will be resolved to a commit ID. This option has no effect if the specified .Ar commit is never traversed. blob - 81971e1f4c71f923c6da083afafa88b6001e10bf blob + 3ca38bd57684cbbf48e72c190d7346237ec825ed --- got/got.c +++ got/got.c @@ -4594,6 +4594,7 @@ cmd_log(int argc, char *argv[]) struct got_worktree *worktree = NULL; struct got_object_id *start_id = NULL, *end_id = NULL; char *repo_path = NULL, *path = NULL, *cwd = NULL, *in_repo_path = NULL; + char *keyword_idstr = NULL; const char *start_commit = NULL, *end_commit = NULL; const char *search_pattern = NULL; int diff_context = -1, ch; @@ -4760,8 +4761,6 @@ cmd_log(int argc, char *argv[]) goto done; got_object_commit_close(commit); } else { - char *keyword_idstr = NULL; - error = got_keyword_to_idstr(&keyword_idstr, start_commit, repo, worktree); if (error != NULL) @@ -4771,11 +4770,17 @@ cmd_log(int argc, char *argv[]) error = got_repo_match_object_id(&start_id, NULL, start_commit, GOT_OBJ_TYPE_COMMIT, &refs, repo); - free(keyword_idstr); if (error != NULL) goto done; } if (end_commit != NULL) { + error = got_keyword_to_idstr(&keyword_idstr, end_commit, + repo, worktree); + if (error != NULL) + goto done; + if (keyword_idstr != NULL) + end_commit = keyword_idstr; + error = got_repo_match_object_id(&end_id, NULL, end_commit, GOT_OBJ_TYPE_COMMIT, &refs, repo); if (error != NULL) @@ -4831,6 +4836,7 @@ done: free(cwd); free(start_id); free(end_id); + free(keyword_idstr); if (worktree) got_worktree_close(worktree); if (repo) {