summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/completion/git-completion.bash104
-rw-r--r--contrib/completion/git-prompt.sh1
-rwxr-xr-xcontrib/git-resurrect.sh13
3 files changed, 71 insertions, 47 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 69d8272fa9..463a3124da 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1120,26 +1120,44 @@ __git_pretty_aliases ()
# __git_aliased_command requires 1 argument
__git_aliased_command ()
{
- local word cmdline=$(__git config --get "alias.$1")
- for word in $cmdline; do
- case "$word" in
- \!gitk|gitk)
- echo "gitk"
- return
- ;;
- \!*) : shell command alias ;;
- -*) : option ;;
- *=*) : setting env ;;
- git) : git itself ;;
- \(\)) : skip parens of shell function definition ;;
- {) : skip start of shell helper function ;;
- :) : skip null command ;;
- \'*) : skip opening quote after sh -c ;;
- *)
- echo "$word"
+ local cur=$1 last list word cmdline
+
+ while [[ -n "$cur" ]]; do
+ if [[ "$list" == *" $cur "* ]]; then
+ # loop detected
return
- esac
+ fi
+
+ cmdline=$(__git config --get "alias.$cur")
+ list=" $cur $list"
+ last=$cur
+ cur=
+
+ for word in $cmdline; do
+ case "$word" in
+ \!gitk|gitk)
+ cur="gitk"
+ break
+ ;;
+ \!*) : shell command alias ;;
+ -*) : option ;;
+ *=*) : setting env ;;
+ git) : git itself ;;
+ \(\)) : skip parens of shell function definition ;;
+ {) : skip start of shell helper function ;;
+ :) : skip null command ;;
+ \'*) : skip opening quote after sh -c ;;
+ *)
+ cur="$word"
+ break
+ esac
+ done
done
+
+ cur=$last
+ if [[ "$cur" != "$1" ]]; then
+ echo "$cur"
+ fi
}
# Check whether one of the given words is present on the command line,
@@ -1466,14 +1484,15 @@ _git_bundle ()
# Helper function to decide whether or not we should enable DWIM logic for
# git-switch and git-checkout.
#
-# To decide between the following rules in priority order
-# 1) the last provided of "--guess" or "--no-guess" explicitly enable or
-# disable completion of DWIM logic respectively.
-# 2) If the --no-track option is provided, take this as a hint to disable the
-# DWIM completion logic
-# 3) If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
-# logic, as requested by the user.
-# 4) Enable DWIM logic otherwise.
+# To decide between the following rules in decreasing priority order:
+# - the last provided of "--guess" or "--no-guess" explicitly enable or
+# disable completion of DWIM logic respectively.
+# - If checkout.guess is false, disable completion of DWIM logic.
+# - If the --no-track option is provided, take this as a hint to disable the
+# DWIM completion logic
+# - If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
+# logic, as requested by the user.
+# - Enable DWIM logic otherwise.
#
__git_checkout_default_dwim_mode ()
{
@@ -1484,11 +1503,17 @@ __git_checkout_default_dwim_mode ()
fi
# --no-track disables DWIM, but with lower priority than
- # --guess/--no-guess
+ # --guess/--no-guess/checkout.guess
if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then
dwim_opt=""
fi
+ # checkout.guess = false disables DWIM, but with lower priority than
+ # --guess/--no-guess
+ if [ "$(__git config --type=bool checkout.guess)" = "false" ]; then
+ dwim_opt=""
+ fi
+
# Find the last provided --guess or --no-guess
last_option="$(__git_find_last_on_cmdline "--guess --no-guess")"
case "$last_option" in
@@ -1687,8 +1712,13 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--submodule --submodule= --ignore-submodules
--indent-heuristic --no-indent-heuristic
--textconv --no-textconv
+ --patch --no-patch
"
+__git_diff_difftool_options="--cached --staged --pickaxe-all --pickaxe-regex
+ --base --ours --theirs --no-index --relative --merge-base
+ $__git_diff_common_options"
+
_git_diff ()
{
__git_has_doubledash && return
@@ -1711,10 +1741,7 @@ _git_diff ()
return
;;
--*)
- __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
- --base --ours --theirs --no-index
- $__git_diff_common_options
- "
+ __gitcomp "$__git_diff_difftool_options"
return
;;
esac
@@ -1736,11 +1763,7 @@ _git_difftool ()
return
;;
--*)
- __gitcomp_builtin difftool "$__git_diff_common_options
- --base --cached --ours --theirs
- --pickaxe-all --pickaxe-regex
- --relative --staged
- "
+ __gitcomp_builtin difftool "$__git_diff_difftool_options"
return
;;
esac
@@ -2030,11 +2053,9 @@ _git_log ()
--no-walk --no-walk= --do-walk
--parents --children
--expand-tabs --expand-tabs= --no-expand-tabs
- --patch
$merge
$__git_diff_common_options
--pickaxe-all --pickaxe-regex
- --patch --no-patch
"
return
;;
@@ -2937,7 +2958,7 @@ _git_show ()
;;
--*)
__gitcomp "--pretty= --format= --abbrev-commit --no-abbrev-commit
- --oneline --show-signature --patch
+ --oneline --show-signature
--expand-tabs --expand-tabs= --no-expand-tabs
$__git_diff_common_options
"
@@ -3020,7 +3041,10 @@ _git_stash ()
list,--*)
__gitcomp "--name-status --oneline --patch-with-stat"
;;
- show,--*|branch,--*)
+ show,--*)
+ __gitcomp "$__git_diff_common_options"
+ ;;
+ branch,--*)
;;
branch,*)
if [ $cword -eq 3 ]; then
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 54e123d632..4640a1535d 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -138,6 +138,7 @@ __git_ps1_show_upstream ()
done <<< "$output"
# parse configuration values
+ local option
for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in
git|svn) upstream="$option" ;;
diff --git a/contrib/git-resurrect.sh b/contrib/git-resurrect.sh
index 8c171dd959..d843df3afd 100755
--- a/contrib/git-resurrect.sh
+++ b/contrib/git-resurrect.sh
@@ -27,7 +27,7 @@ n,dry-run don't recreate the branch"
search_reflog () {
sed -ne 's~^\([^ ]*\) .* checkout: moving from '"$1"' .*~\1~p' \
- < "$GIT_DIR"/logs/HEAD
+ < "$GIT_DIR"/logs/HEAD
}
search_reflog_merges () {
@@ -37,19 +37,18 @@ search_reflog_merges () {
)
}
-_x40="[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]"
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+oid_pattern=$(git hash-object --stdin </dev/null | sed -e 's/./[0-9a-f]/g')
search_merges () {
- git rev-list --all --grep="Merge branch '$1'" \
- --pretty=tformat:"%P %s" |
- sed -ne "/^$_x40 \($_x40\) Merge .*/ {s//\1/p;$early_exit}"
+ git rev-list --all --grep="Merge branch '$1'" \
+ --pretty=tformat:"%P %s" |
+ sed -ne "/^$oid_pattern \($oid_pattern\) Merge .*/ {s//\1/p;$early_exit}"
}
search_merge_targets () {
git rev-list --all --grep="Merge branch '[^']*' into $branch\$" \
--pretty=tformat:"%H %s" --all |
- sed -ne "/^\($_x40\) Merge .*/ {s//\1/p;$early_exit} "
+ sed -ne "/^\($oid_pattern\) Merge .*/ {s//\1/p;$early_exit} "
}
dry_run=