Skip to content

Commit 67405b9

Browse files
committed
Merge branch 'sg/completion'
* sg/completion: bash: support pretty format aliases bash: support more 'git notes' subcommands and their options bash: not all 'git bisect' subcommands make sense when not bisecting bash: offer refs for 'git bisect start'
2 parents 10793e6 + c389811 commit 67405b9

File tree

1 file changed

+64
-15
lines changed

1 file changed

+64
-15
lines changed

contrib/completion/git-completion.bash

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,19 @@ __git_compute_porcelain_commands ()
756756
: ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
757757
}
758758

759+
__git_pretty_aliases ()
760+
{
761+
local i IFS=$'\n'
762+
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
763+
case "$i" in
764+
pretty.*)
765+
i="${i#pretty.}"
766+
echo "${i/ */}"
767+
;;
768+
esac
769+
done
770+
}
771+
759772
__git_aliases ()
760773
{
761774
local i IFS=$'\n'
@@ -913,12 +926,16 @@ _git_bisect ()
913926
local subcommands="start bad good skip reset visualize replay log run"
914927
local subcommand="$(__git_find_on_cmdline "$subcommands")"
915928
if [ -z "$subcommand" ]; then
916-
__gitcomp "$subcommands"
929+
if [ -f "$(__gitdir)"/BISECT_START ]; then
930+
__gitcomp "$subcommands"
931+
else
932+
__gitcomp "replay start"
933+
fi
917934
return
918935
fi
919936

920937
case "$subcommand" in
921-
bad|good|reset|skip)
938+
bad|good|reset|skip|start)
922939
__gitcomp "$(__git_refs)"
923940
;;
924941
*)
@@ -1374,12 +1391,12 @@ _git_log ()
13741391
fi
13751392
case "$cur" in
13761393
--pretty=*)
1377-
__gitcomp "$__git_log_pretty_formats
1394+
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
13781395
" "" "${cur##--pretty=}"
13791396
return
13801397
;;
13811398
--format=*)
1382-
__gitcomp "$__git_log_pretty_formats
1399+
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
13831400
" "" "${cur##--format=}"
13841401
return
13851402
;;
@@ -1474,18 +1491,50 @@ _git_name_rev ()
14741491

14751492
_git_notes ()
14761493
{
1477-
local subcommands="edit show"
1478-
if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
1479-
__gitcomp "$subcommands"
1480-
return
1481-
fi
1494+
local subcommands='add append copy edit list prune remove show'
1495+
local subcommand="$(__git_find_on_cmdline "$subcommands")"
1496+
local cur="${COMP_WORDS[COMP_CWORD]}"
14821497

1483-
case "${COMP_WORDS[COMP_CWORD-1]}" in
1484-
-m|-F)
1485-
COMPREPLY=()
1498+
case "$subcommand,$cur" in
1499+
,--*)
1500+
__gitcomp '--ref'
1501+
;;
1502+
,*)
1503+
case "${COMP_WORDS[COMP_CWORD-1]}" in
1504+
--ref)
1505+
__gitcomp "$(__git_refs)"
1506+
;;
1507+
*)
1508+
__gitcomp "$subcommands --ref"
1509+
;;
1510+
esac
1511+
;;
1512+
add,--reuse-message=*|append,--reuse-message=*)
1513+
__gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
1514+
;;
1515+
add,--reedit-message=*|append,--reedit-message=*)
1516+
__gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
1517+
;;
1518+
add,--*|append,--*)
1519+
__gitcomp '--file= --message= --reedit-message=
1520+
--reuse-message='
1521+
;;
1522+
copy,--*)
1523+
__gitcomp '--stdin'
1524+
;;
1525+
prune,--*)
1526+
__gitcomp '--dry-run --verbose'
1527+
;;
1528+
prune,*)
14861529
;;
14871530
*)
1488-
__gitcomp "$(__git_refs)"
1531+
case "${COMP_WORDS[COMP_CWORD-1]}" in
1532+
-m|-F)
1533+
;;
1534+
*)
1535+
__gitcomp "$(__git_refs)"
1536+
;;
1537+
esac
14891538
;;
14901539
esac
14911540
}
@@ -2106,12 +2155,12 @@ _git_show ()
21062155
local cur="${COMP_WORDS[COMP_CWORD]}"
21072156
case "$cur" in
21082157
--pretty=*)
2109-
__gitcomp "$__git_log_pretty_formats
2158+
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
21102159
" "" "${cur##--pretty=}"
21112160
return
21122161
;;
21132162
--format=*)
2114-
__gitcomp "$__git_log_pretty_formats
2163+
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
21152164
" "" "${cur##--format=}"
21162165
return
21172166
;;

0 commit comments

Comments
 (0)