169cd8b6ca803721071795c6a207aa97265c8528
- Author
- Felipe Contreras <felipe.contreras@gmail.com>
- Committer
- Felipe Contreras <felipe.contreras@gmail.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
2index c75b0be7f1f1c826206ba2079ea378d3a5d5504f..7ed3e3c26e317b2352da0507c032d437a72d4000 100644
3--- a/plugins/gitfast/_git
4+++ b/plugins/gitfast/_git
5@@ -104,6 +104,7 @@ __git_zsh_bash_func ()
6
7 local expansion=$(__git_aliased_command "$command")
8 if [ -n "$expansion" ]; then
9+ words[1]=$expansion
10 completion_func="_git_${expansion//-/_}"
11 declare -f $completion_func >/dev/null && $completion_func
12 fi
13diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
14index 9525343fcd34ce5009fcfd9b2bf2c6356282e259..5944c824abe9aa4dee8b63b0e91a047125722b22 100644
15--- a/plugins/gitfast/git-completion.bash
16+++ b/plugins/gitfast/git-completion.bash
17@@ -16,11 +16,17 @@
18 #
19 # To use these routines:
20 #
21-# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
22+# 1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
23 # 2) Add the following line to your .bashrc/.zshrc:
24-# source ~/.git-completion.sh
25+# source ~/.git-completion.bash
26 # 3) Consider changing your PS1 to also show the current branch,
27 # see git-prompt.sh for details.
28+#
29+# If you use complex aliases of form '!f() { ... }; f', you can use the null
30+# command ':' as the first command in the function body to declare the desired
31+# completion style. For example '!f() { : git commit ; ... }; f' will
32+# tell the completion to use commit completion. This also works with aliases
33+# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
34
35 case "$COMP_WORDBREAKS" in
36 *:*) : great ;;
37@@ -180,7 +186,7 @@ fi
38
39 __gitcompappend ()
40 {
41- local i=${#COMPREPLY[@]}
42+ local x i=${#COMPREPLY[@]}
43 for x in $1; do
44 if [[ "$x" == "$3"* ]]; then
45 COMPREPLY[i++]="$2$x$4"
46@@ -275,16 +281,12 @@ __gitcomp_file ()
47 # argument, and using the options specified in the second argument.
48 __git_ls_files_helper ()
49 {
50- (
51- test -n "${CDPATH+set}" && unset CDPATH
52- cd "$1"
53- if [ "$2" == "--committable" ]; then
54- git diff-index --name-only --relative HEAD
55- else
56- # NOTE: $2 is not quoted in order to support multiple options
57- git ls-files --exclude-standard $2
58- fi
59- ) 2>/dev/null
60+ if [ "$2" == "--committable" ]; then
61+ git -C "$1" diff-index --name-only --relative HEAD
62+ else
63+ # NOTE: $2 is not quoted in order to support multiple options
64+ git -C "$1" ls-files --exclude-standard $2
65+ fi 2>/dev/null
66 }
67
68
69@@ -382,7 +384,8 @@ __git_refs ()
70 ;;
71 *)
72 echo "HEAD"
73- git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##"
74+ git for-each-ref --format="%(refname:short)" -- \
75+ "refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##"
76 ;;
77 esac
78 }
79@@ -408,12 +411,9 @@ __git_refs_remotes ()
80
81 __git_remotes ()
82 {
83- local i IFS=$'\n' d="$(__gitdir)"
84+ local d="$(__gitdir)"
85 test -d "$d/remotes" && ls -1 "$d/remotes"
86- for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
87- i="${i#remote.}"
88- echo "${i/.url*/}"
89- done
90+ git --git-dir="$d" remote
91 }
92
93 __git_list_merge_strategies ()
94@@ -516,7 +516,7 @@ __git_complete_index_file ()
95 ;;
96 esac
97
98- __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_"
99+ __gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
100 }
101
102 __git_complete_file ()
103@@ -781,6 +781,10 @@ __git_aliased_command ()
104 -*) : option ;;
105 *=*) : setting env ;;
106 git) : git itself ;;
107+ \(\)) : skip parens of shell function definition ;;
108+ {) : skip start of shell helper function ;;
109+ :) : skip null command ;;
110+ \'*) : skip opening quote after sh -c ;;
111 *)
112 echo "$word"
113 return
114@@ -973,7 +977,7 @@ _git_branch ()
115
116 case "$cur" in
117diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
118index 9d684b10a67ea663410db3ba68482c1a52bbc367..f18aedc73be9daf4aab564beecb7bae29ea759c9 100644
119--- a/plugins/gitfast/git-prompt.sh
120+++ b/plugins/gitfast/git-prompt.sh
121@@ -84,6 +84,11 @@
122 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
123 # the colored output of "git status -sb" and are available only when
124 # using __git_ps1 for PROMPT_COMMAND or precmd.
125+#
126+# If you would like __git_ps1 to do nothing in the case when the current
127+# directory is set up to be ignored by git, then set
128+# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the
129+# repository level by setting bash.hideIfPwdIgnored to "false".
130
131 # check whether printf supports -v
132 __git_printf_supports_v=
133@@ -270,7 +275,7 @@ __git_ps1_colorize_gitstring ()
134
135 __git_eread ()
136 {
137- f="$1"
138+ local f="$1"
139 shift
140 test -r "$f" && read "$@" <"$f"
141 }
142@@ -288,6 +293,8 @@ __git_eread ()
143 # In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
144 __git_ps1 ()
145 {
146+ # preserve exit status
147+ local exit=$?
148 local pcmode=no
149 local detached=no
150 local ps1pc_start='\u@\h:\w '
151@@ -299,10 +306,14 @@ __git_ps1 ()
152 ps1pc_start="$1"
153 ps1pc_end="$2"
154 printf_format="${3:-$printf_format}"
155+ # set PS1 to a plain prompt so that we can
156+ # simply return early if the prompt should not
157+ # be decorated
158+ PS1="$ps1pc_start$ps1pc_end"
159 ;;
160 0|1) printf_format="${1:-$printf_format}"
161 ;;
162- *) return
163+ *) return $exit
164 ;;
165 esac
166
167@@ -350,11 +361,7 @@ __git_ps1 ()
168 rev_parse_exit_code="$?"
169
170 if [ -z "$repo_info" ]; then
171- if [ $pcmode = yes ]; then
172- #In PC mode PS1 always needs to be set
173- PS1="$ps1pc_start$ps1pc_end"
174- fi
175- return
176+ return $exit
177 fi
178
179 local short_sha
180@@ -369,6 +376,14 @@ __git_ps1 ()
181 local inside_gitdir="${repo_info##*$'\n'}"
182 local g="${repo_info%$'\n'*}"
183
184+ if [ "true" = "$inside_worktree" ] &&
185+ [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] &&
186+ [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
187+ git check-ignore -q .
188+ then
189+ return $exit
190+ fi
191+
192 local r=""
193 local b=""
194 local step=""
195@@ -412,10 +427,7 @@ __git_ps1 ()
196 else
197 local head=""
198 if ! __git_eread "$g/HEAD" head; then
199- if [ $pcmode = yes ]; then
200- PS1="$ps1pc_start$ps1pc_end"
201- fi
202- return
203+ return $exit
204 fi
205 # is it a symbolic ref?
206 b="${head#ref: }"
207@@ -468,13 +480,14 @@ __git_ps1 ()
208 fi
209 fi
210 if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
211- [ -r "$g/refs/stash" ]; then
212+ git rev-parse --verify --quiet refs/stash >/dev/null
213+ then
214 s="$"
215 fi
216
217 if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
218 [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
219- git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
220+ git ls-files --others --exclude-standard --error-unmatch -- ':/*' >/dev/null 2>/dev/null