Skip to content

Commit 2a5da75

Browse files
szedergitster
authored andcommitted
bash: support more 'git notes' subcommands and their options
The current completion function for 'git notes' only supported the 'edit' and 'show' subcommands and none of their options. This patch adds support for all missing subcommands, options, and their arguments (files or refs), if any. The code responsible for completing subcommand looks different compared to the completion functions of other git commands with subcommands. This is because of the '--ref <notes-ref>' option which comes before the subcommand (i.e. git notes --ref <notes-ref> add). Signed-off-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 128191f commit 2a5da75

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

contrib/completion/git-completion.bash

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,18 +1472,50 @@ _git_name_rev ()
14721472

14731473
_git_notes ()
14741474
{
1475-
local subcommands="edit show"
1476-
if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
1477-
__gitcomp "$subcommands"
1478-
return
1479-
fi
1475+
local subcommands='add append copy edit list prune remove show'
1476+
local subcommand="$(__git_find_on_cmdline "$subcommands")"
1477+
local cur="${COMP_WORDS[COMP_CWORD]}"
14801478

1481-
case "${COMP_WORDS[COMP_CWORD-1]}" in
1482-
-m|-F)
1483-
COMPREPLY=()
1479+
case "$subcommand,$cur" in
1480+
,--*)
1481+
__gitcomp '--ref'
1482+
;;
1483+
,*)
1484+
case "${COMP_WORDS[COMP_CWORD-1]}" in
1485+
--ref)
1486+
__gitcomp "$(__git_refs)"
1487+
;;
1488+
*)
1489+
__gitcomp "$subcommands --ref"
1490+
;;
1491+
esac
1492+
;;
1493+
add,--reuse-message=*|append,--reuse-message=*)
1494+
__gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
1495+
;;
1496+
add,--reedit-message=*|append,--reedit-message=*)
1497+
__gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
1498+
;;
1499+
add,--*|append,--*)
1500+
__gitcomp '--file= --message= --reedit-message=
1501+
--reuse-message='
1502+
;;
1503+
copy,--*)
1504+
__gitcomp '--stdin'
1505+
;;
1506+
prune,--*)
1507+
__gitcomp '--dry-run --verbose'
1508+
;;
1509+
prune,*)
14841510
;;
14851511
*)
1486-
__gitcomp "$(__git_refs)"
1512+
case "${COMP_WORDS[COMP_CWORD-1]}" in
1513+
-m|-F)
1514+
;;
1515+
*)
1516+
__gitcomp "$(__git_refs)"
1517+
;;
1518+
esac
14871519
;;
14881520
esac
14891521
}

0 commit comments

Comments
 (0)