completion: teach rebase to use __gitcomp_builtin
Currently, _git_rebase() uses a hardcoded list of options for its completion. However, we can use __gitcomp_builtin() to get a dynamically generated list of completions instead. Teach _git_rebase() to use __gitcomp_builtin() so that newly implemented options in rebase will be automatically completed without any mucking around in git-completion.bash. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Denton Liu committed
Sep 12, 2019 at 12:43 UTC
2b9bd488ae09dc89f02be7d73f3710ee2ea7325c
1 file changed
+7
-15
contrib/completion/git-completion.bash
+7
-15
@@ -2004,15 +2004,18 @@ _git_range_diff ()
2004
__git_complete_revlist
2005
}
2006
2007
+__git_rebase_inprogress_options="--continue --skip --abort --quit --show-current-patch"
2008
+__git_rebase_interactive_inprogress_options="$__git_rebase_inprogress_options --edit-todo"
2009
+
2010
_git_rebase ()
2011
{
2012
__git_find_repo_path
2013
if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
2011
- __gitcomp "--continue --skip --abort --quit --edit-todo --show-current-patch"
2014
+ __gitcomp "$__git_rebase_interactive_inprogress_options"
2015
return
2016
elif [ -d "$__git_repo_path"/rebase-apply ] || \
2017
[ -d "$__git_repo_path"/rebase-merge ]; then
2015
- __gitcomp "--continue --skip --abort --quit --show-current-patch"
2018
+ __gitcomp "$__git_rebase_inprogress_options"
2019
return
2020
fi
2021
__git_complete_strategy && return
@@ -2022,19 +2025,8 @@ _git_rebase ()
2025
return
2026
;;
2027
--*)
2025
- __gitcomp "
2026
- --onto --merge --strategy --interactive
2027
- --rebase-merges --preserve-merges --stat --no-stat
2028
- --committer-date-is-author-date --ignore-date
2029
- --ignore-whitespace --whitespace=
2030
- --autosquash --no-autosquash
2031
- --fork-point --no-fork-point
2032
- --autostash --no-autostash
2033
- --verify --no-verify
2034
- --keep-empty --root --force-rebase --no-ff
2035
- --rerere-autoupdate
2036
- --exec
2037
- "
2028
+ __gitcomp_builtin rebase "" \
2029
+ "$__git_rebase_interactive_inprogress_options"
2030
2031
return
2032
esac