diff mbox series

[4/4] completion: reflog show <log-options>

Message ID 42861028-3ffa-40e2-bb97-a54cfc11ddcc@gmail.com (mailing list archive)
State New, archived
Headers show
Series completion for git-reflog show | expand

Commit Message

Rubén Justo Jan. 26, 2024, 12:53 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 | 13 ++++++++++++-
 t/t9902-completion.sh                  |  5 ++++-
 2 files changed, 16 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c41f25aa80..3deb98389c 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2447,12 +2447,23 @@  _git_rebase ()
 
 _git_reflog ()
 {
-	local subcommands="show delete expire"
+	local subcommand subcommands="show delete expire"
 
 	if __gitcomp_subcommand "$subcommands"; then
 		return
 	fi
 
+	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 231e17f378..a74d774168 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -2623,7 +2623,10 @@  test_expect_success 'git reflog show' '
 	git checkout -b shown &&
 	test_completion "git reflog sho" "show " &&
 	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' '