dac07b2652b10386e0b0c1ffc874c9a0a451ea10
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
2index fac5e711ebbbd074366d89848165e0f9dbc36c36..6b779685722916f8032dce9b3b46220eb6a19414 100644
3--- a/plugins/gitfast/_git
4+++ b/plugins/gitfast/_git
5@@ -30,10 +30,10 @@ if [ -z "$script" ]; then
6 local -a locations
7 local e
8 locations=(
9+ $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
10 '/etc/bash_completion.d/git' # fedora, old debian
11 '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
12 '/usr/share/bash-completion/git' # gentoo
13- $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
14 )
15 for e in $locations; do
16 test -f $e && script="$e" && break
17@@ -76,6 +76,14 @@ __gitcomp_nl ()
18 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
19 }
20
21+__gitcomp_nl_append ()
22+{
23+ emulate -L zsh
24+
25+ local IFS=$'\n'
26+ compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
27+}
28+
29 __gitcomp_file ()
30 {
31 emulate -L zsh
32diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
33index 5da920ecd9ec1b64760db863d266fdc9c47502de..9525343fcd34ce5009fcfd9b2bf2c6356282e259 100644
34--- a/plugins/gitfast/git-completion.bash
35+++ b/plugins/gitfast/git-completion.bash
36@@ -1,5 +1,3 @@
37-#!bash
38-#
39 # bash/zsh completion support for core Git.
40 #
41 # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
42@@ -180,9 +178,9 @@ _get_comp_words_by_ref ()
43 }
44 fi
45
46-__gitcompadd ()
47+__gitcompappend ()
48 {
49- local i=0
50+ local i=${#COMPREPLY[@]}
51 for x in $1; do
52 if [[ "$x" == "$3"* ]]; then
53 COMPREPLY[i++]="$2$x$4"
54@@ -190,6 +188,12 @@ __gitcompadd ()
55 done
56 }
57
58+__gitcompadd ()
59+{
60+ COMPREPLY=()
61+ __gitcompappend "$@"
62+}
63+
64 # Generates completion reply, appending a space to possible completion words,
65 # if necessary.
66 # It accepts 1 to 4 arguments:
67@@ -220,6 +224,14 @@ __gitcomp ()
68 esac
69 }
70
71+# Variation of __gitcomp_nl () that appends to the existing list of
72+# completion candidates, COMPREPLY.
73+__gitcomp_nl_append ()
74+{
75+ local IFS=$'\n'
76+ __gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
77+}
78+
79 # Generates completion reply from newline-separated possible completion words
80 # by appending a space to all of them.
81 # It accepts 1 to 4 arguments:
82@@ -231,8 +243,8 @@ __gitcomp ()
83 # appended.
84 __gitcomp_nl ()
85 {
86- local IFS=$'\n'
87- __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
88+ COMPREPLY=()
89+ __gitcomp_nl_append "$@"
90 }
91
92 # Generates completion reply with compgen from newline-separated possible
93@@ -673,7 +685,6 @@ __git_list_porcelain_commands ()
94 index-pack) : plumbing;;
95 init-db) : deprecated;;
96 local-fetch) : plumbing;;
97- lost-found) : infrequent;;
98 ls-files) : plumbing;;
99 ls-remote) : plumbing;;
100 ls-tree) : plumbing;;
101@@ -687,14 +698,12 @@ __git_list_porcelain_commands ()
102 pack-refs) : plumbing;;
103 parse-remote) : plumbing;;
104 patch-id) : plumbing;;
105- peek-remote) : plumbing;;
106 prune) : plumbing;;
107 prune-packed) : plumbing;;
108 quiltimport) : import;;
109 read-tree) : plumbing;;
110 receive-pack) : plumbing;;
111 remote-*) : transport;;
112- repo-config) : deprecated;;
113 rerere) : plumbing;;
114 rev-list) : plumbing;;
115 rev-parse) : plumbing;;
116@@ -707,7 +716,6 @@ __git_list_porcelain_commands ()
117 ssh-*) : transport;;
118 stripspace) : plumbing;;
119 symbolic-ref) : plumbing;;
120- tar-tree) : deprecated;;
121 unpack-file) : plumbing;;
122 unpack-objects) : plumbing;;
123 update-index) : plumbing;;
124@@ -901,7 +909,7 @@ _git_add ()
125 esac
126
127 # XXX should we check for --update and --all options ?
128- __git_complete_index_file "--others --modified"
129+ __git_complete_index_file "--others --modified --directory --no-empty-directory"
130 }
131
132 _git_archive ()
133@@ -1063,7 +1071,7 @@ _git_clean ()
134 esac
135
136diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh
137index a81ef5a482d48b114a81e242109e2f0dec0839ed..54489080f8ae25a4483cd4bae076942f47f53031 100644
138--- a/plugins/gitfast/git-prompt.sh
139+++ b/plugins/gitfast/git-prompt.sh
140@@ -60,6 +60,7 @@
141 # of values:
142 #
143 # verbose show number of commits ahead/behind (+/-) upstream
144+# name if verbose, then also show the upstream abbrev name
145 # legacy don't use the '--count' option available in recent
146 # versions of git-rev-list
147 # git always compare HEAD to @{upstream}
148@@ -84,13 +85,17 @@
149 # the colored output of "git status -sb" and are available only when
150 # using __git_ps1 for PROMPT_COMMAND or precmd.
151
152+# check whether printf supports -v
153+__git_printf_supports_v=
154+printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
155+
156 # stores the divergence from upstream in $p
157 # used by GIT_PS1_SHOWUPSTREAM
158 __git_ps1_show_upstream ()
159 {
160 local key value
161 local svn_remote svn_url_pattern count n
162- local upstream=git legacy="" verbose=""
163+ local upstream=git legacy="" verbose="" name=""
164
165 svn_remote=()
166 # get some config options from git-config
167@@ -106,7 +111,7 @@ __git_ps1_show_upstream ()
168 ;;
169 svn-remote.*.url)
170 svn_remote[$((${#svn_remote[@]} + 1))]="$value"
171- svn_url_pattern+="\\|$value"
172+ svn_url_pattern="$svn_url_pattern\\|$value"
173 upstream=svn+git # default upstream is SVN if available, else git
174 ;;
175 esac
176@@ -118,6 +123,7 @@ __git_ps1_show_upstream ()
177 git|svn) upstream="$option" ;;
178 verbose) verbose=1 ;;
179 legacy) legacy=1 ;;
180+ name) name=1 ;;
181 esac
182 done
183
184@@ -200,6 +206,9 @@ __git_ps1_show_upstream ()
185 *) # diverged from upstream
186 p=" u+${count#* }-${count% *}" ;;
187 esac
188+ if [[ -n "$count" && -n "$name" ]]; then
189+ p="$p $(git rev-parse --abbrev-ref "$upstream" 2>/dev/null)"
190+ fi
191 fi
192
193 }
194@@ -250,6 +259,13 @@ __git_ps1_colorize_gitstring ()
195 r="$c_clear$r"
196 }
197
198+eread ()
199+{
200+ f="$1"
201+ shift
202+ test -r "$f" && read "$@" <"$f"
203+}
204+
205 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
206 # when called from PS1 using command substitution
207 # in this mode it prints text to add to bash PS1 prompt (includes branch name)
208@@ -312,9 +328,9 @@ __git_ps1 ()
209 local step=""
210 local total=""
211 if [ -d "$g/rebase-merge" ]; then
212- read b 2>/dev/null <"$g/rebase-merge/head-name"
213- read step 2>/dev/null <"$g/rebase-merge/msgnum"
214- read total 2>/dev/null <"$g/rebase-merge/end"
215+ eread "$g/rebase-merge/head-name" b
216+ eread "$g/rebase-merge/msgnum" step
217+ eread "$g/rebase-merge/end" total
218 if [ -f "$g/rebase-merge/interactive" ]; then
219 r="|REBASE-i"
220 else
221@@ -322,10 +338,10 @@ __git_ps1 ()
222 fi
223 else
224 if [ -d "$g/rebase-apply" ]; then
225- read step 2>/dev/null <"$g/rebase-apply/next"
226- read total 2>/dev/null <"$g/rebase-apply/last"
227+ eread "$g/rebase-apply/next" step
228+ eread "$g/rebase-apply/last" total
229 if [ -f "$g/rebase-apply/rebasing" ]; then
230- read b 2>/dev/null <"$g/rebase-apply/head-name"
231+ eread "$g/rebase-apply/head-name" b
232 r="|REBASE"
233 elif [ -f "$g/rebase-apply/applying" ]; then
234 r="|AM"
235@@ -349,7 +365,7 @@ __git_ps1 ()
236 b="$(git symbolic-ref HEAD 2>/dev/null)"
237 else
238 local head=""
239- if ! read head 2>/dev/null <"$g/HEAD"; then