Skip to content

Commit a9e5b7a

Browse files
bkeringitster
authored andcommitted
completion: new function __git_complete_log_opts
The options accepted by git-log are also accepted by at least one other command (git-bisect). Factor the common option completion code into a new function and use it from _git_log. The new function leaves COMPREPLY empty if no option candidates are found, so that callers can safely check it to determine if completion for other arguments should be attempted. Signed-off-by: Britton Leo Kerin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 41928ae commit a9e5b7a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

contrib/completion/git-completion.bash

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,10 +2089,12 @@ __git_diff_merges_opts="off none on first-parent 1 separate m combined c dense-c
20892089
__git_log_pretty_formats="oneline short medium full fuller reference email raw format: tformat: mboxrd"
20902090
__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default human raw unix auto: format:"
20912091

2092-
_git_log ()
2092+
# Complete porcelain (i.e. not git-rev-list) options and at least some
2093+
# option arguments accepted by git-log. Note that this same set of options
2094+
# are also accepted by some other git commands besides git-log.
2095+
__git_complete_log_opts ()
20932096
{
2094-
__git_has_doubledash && return
2095-
__git_find_repo_path
2097+
COMPREPLY=()
20962098

20972099
local merge=""
20982100
if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
@@ -2186,6 +2188,16 @@ _git_log ()
21862188
return
21872189
;;
21882190
esac
2191+
}
2192+
2193+
_git_log ()
2194+
{
2195+
__git_has_doubledash && return
2196+
__git_find_repo_path
2197+
2198+
__git_complete_log_opts
2199+
[ ${#COMPREPLY[@]} -eq 0 ] || return
2200+
21892201
__git_complete_revlist
21902202
}
21912203

0 commit comments

Comments
 (0)