diff mbox series

[v2,3/5] completion: reflog show <log-options>

Message ID 27fe304d-6011-430d-8f43-7e0581566182@gmail.com (mailing list archive)
State Accepted
Commit c689c38bc2dceac3f8fe975472f12c0dbe473537
Headers show
Series completion for git-reflog show | expand

Commit Message

Rubén Justo March 2, 2024, 3:50 p.m. UTC
Let's add completion for <log-options> in "reflog show" so that the user
can easily discover uses like:

   $ git reflog --since=1.day.ago

Signed-off-by: Rubén Justo <rjusto@gmail.com>
---
 contrib/completion/git-completion.bash | 10 ++++++++++
 t/t9902-completion.sh                  |  5 ++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 849d191b02..dc5f73a9f3 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2427,6 +2427,16 @@  _git_rebase ()
 _git_reflog ()
 {
 	local subcommands="show delete expire"
+	local subcommand="$(__git_find_subcommand "$subcommands" "show")"
+
+	case "$subcommand,$cur" in
+	show,--*)
+		__gitcomp "
+			$__git_log_common_options
+			"
+		return
+		;;
+	esac
 
 	__git_complete_refs
 
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index dbd57e6a28..04f3620e5b 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2626,7 +2626,10 @@  test_expect_success 'git reflog show' '
 	shown Z
 	EOF
 	test_completion "git reflog show sho" "shown " &&
-	test_completion "git reflog shown sho" "shown "
+	test_completion "git reflog shown sho" "shown " &&
+	test_completion "git reflog --unt" "--until=" &&
+	test_completion "git reflog show --unt" "--until=" &&
+	test_completion "git reflog shown --unt" "--until="
 '
 
 test_expect_success 'options with value' '