threads / patch / 55443

patchbash completion: complete CHERRY_PICK_HEAD

Subject: [PATCH] bash completion: complete CHERRY_PICK_HEAD

## tl;dr

2 messages between Apr 7, 2021 and Apr 7, 2021. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Ævar Arnfjörð Bjarmason· Apr 7, 2021, 10:50 UTC · lore

When e.g. in a failed cherry pick we did not recognize CHERRY_PICK_HEAD as we do e.g. REBASE_HEAD in a failed rebase let's rectify that.

When REBASE_HEAD was added in fbd7a232370 (rebase: introduce and use pseudo-ref REBASE_HEAD, 2018-02-11) a completion was added for it, but no corresponding completion existed for CHERRY_PICK_HEAD added in d7e5c0cbfb0 (Introduce CHERRY_PICK_HEAD, 2011-02-19).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to contrib/completion/git-completion.bash +1 −1
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index e1a66954fe8..dbb290956b6 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -744,7 +744,7 @@ __git_refs ()
 			track=""
 			;;
 		*)
-			for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
+			for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD; do
 				case "$i" in
 				$match*)
 					if [ -e "$dir/$i" ]; then
-- 
2.31.1.527.g9b8f7de2547
Junio C Hamano· Apr 7, 2021, 22:21 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH] bash completion: complete CHERRY_PICK_HEAD

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
Show 8 quoted lines
> -			for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
> +			for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD CHERRY_PICK_HEAD; do
>  				case "$i" in
>  				$match*)
>  					if [ -e "$dir/$i" ]; then
>						echo "$pfx$i$sfx"
>					fi
>					;;
Hmph, it gets tempting to do this instead:
	for i in $(cd "$dir/" && echo HEAD *_HEAD)
	do
		case "$i" in
		$match*)
			echo "$pfx$i$sfx"
			;;
		esac
	done
but I am no completion expert, so I'll queue the patch as-is.
Thanks.

← back to recent threads