3
3
4
4
dashless=$( basename " $0 " | sed -e ' s/-/ /' )
5
5
USAGE=" list [<options>]
6
- or: $dashless ( show | drop ) [<stash>]
7
- or: $dashless ( pop | apply ) [--index] [<stash>]
6
+ or: $dashless show [<stash>]
7
+ or: $dashless drop [-q|--quiet] [<stash>]
8
+ or: $dashless ( pop | apply ) [--index] [-q|--quiet] [<stash>]
8
9
or: $dashless branch <branchname> [<stash>]
9
- or: $dashless [save [--keep-index] [<message>]]
10
+ or: $dashless [save [--keep-index] [-q|--quiet] [ <message>]]
10
11
or: $dashless clear"
11
12
12
13
SUBDIRECTORY_OK=Yes
@@ -94,18 +95,28 @@ create_stash () {
94
95
95
96
save_stash () {
96
97
keep_index=
97
- case " $1 " in
98
- --keep-index)
99
- keep_index=t
98
+ while test $# ! = 0
99
+ do
100
+ case " $1 " in
101
+ --keep-index)
102
+ keep_index=t
103
+ ;;
104
+ -q|--quiet)
105
+ GIT_QUIET=t
106
+ ;;
107
+ * )
108
+ break
109
+ ;;
110
+ esac
100
111
shift
101
- esac
112
+ done
102
113
103
114
stash_msg=" $* "
104
115
105
116
git update-index -q --refresh
106
117
if no_changes
107
118
then
108
- echo ' No local changes to save'
119
+ say ' No local changes to save'
109
120
exit 0
110
121
fi
111
122
test -f " $GIT_DIR /logs/$ref_stash " ||
@@ -118,9 +129,9 @@ save_stash () {
118
129
119
130
git update-ref -m " $stash_msg " $ref_stash $w_commit ||
120
131
die " Cannot save the current status"
121
- printf ' Saved working directory and index state "%s"\n ' " $stash_msg "
132
+ say Saved working directory and index state " $stash_msg "
122
133
123
- git reset --hard
134
+ git reset --hard ${GIT_QUIET : +-q}
124
135
125
136
if test -n " $keep_index " && test -n $i_tree
126
137
then
@@ -156,11 +167,22 @@ apply_stash () {
156
167
die ' Cannot apply to a dirty working tree, please stage your changes'
157
168
158
169
unstash_index=
159
- case " $1 " in
160
- --index)
161
- unstash_index=t
170
+
171
+ while test $# ! = 0
172
+ do
173
+ case " $1 " in
174
+ --index)
175
+ unstash_index=t
176
+ ;;
177
+ -q|--quiet)
178
+ GIT_QUIET=t
179
+ ;;
180
+ * )
181
+ break
182
+ ;;
183
+ esac
162
184
shift
163
- esac
185
+ done
164
186
165
187
# current index state
166
188
c_tree=$( git write-tree) ||
@@ -193,6 +215,10 @@ apply_stash () {
193
215
export GITHEAD_$w_tree GITHEAD_$c_tree GITHEAD_$b_tree
194
216
"
195
217
218
+ if test -n " $GIT_QUIET "
219
+ then
220
+ export GIT_MERGE_VERBOSITY=0
221
+ fi
196
222
if git-merge-recursive $b_tree -- $c_tree $w_tree
197
223
then
198
224
# No conflict
@@ -207,7 +233,12 @@ apply_stash () {
207
233
die " Cannot unstage modified files"
208
234
rm -f " $a "
209
235
fi
210
- git status || :
236
+ squelch=
237
+ if test -n " $GIT_QUIET "
238
+ then
239
+ squelch=' >/dev/null 2>&1'
240
+ fi
241
+ eval " git status $squelch " || :
211
242
else
212
243
# Merge conflict; keep the exit status from merge-recursive
213
244
status=$?
@@ -222,6 +253,19 @@ apply_stash () {
222
253
drop_stash () {
223
254
have_stash || die ' No stash entries to drop'
224
255
256
+ while test $# ! = 0
257
+ do
258
+ case " $1 " in
259
+ -q|--quiet)
260
+ GIT_QUIET=t
261
+ ;;
262
+ * )
263
+ break
264
+ ;;
265
+ esac
266
+ shift
267
+ done
268
+
225
269
if test $# = 0
226
270
then
227
271
set x " $ref_stash @{0}"
@@ -235,7 +279,7 @@ drop_stash () {
235
279
die " $* : not a valid stashed state"
236
280
237
281
git reflog delete --updateref --rewrite " $@ " &&
238
- echo " Dropped $* ($s )" || die " $* : Could not drop stash entry"
282
+ say " Dropped $* ($s )" || die " $* : Could not drop stash entry"
239
283
240
284
# clear_stash if we just dropped the last stash entry
241
285
git rev-parse --verify " $ref_stash @{0}" > /dev/null 2>&1 || clear_stash
@@ -312,7 +356,7 @@ branch)
312
356
if test $# -eq 0
313
357
then
314
358
save_stash &&
315
- echo ' (To restore them type "git stash apply")'
359
+ say ' (To restore them type "git stash apply")'
316
360
else
317
361
usage
318
362
fi
0 commit comments