Skip to content

Commit e6c7c2c

Browse files
committed
Merge branch 'sb/quiet-porcelains'
* sb/quiet-porcelains: stash: teach quiet option am, rebase: teach quiet option submodule, repack: migrate to git-sh-setup's say() git-sh-setup: introduce say() for quiet options am: suppress apply errors when using 3-way t4150: test applying with a newline in subject
2 parents 4197195 + fcdd0e9 commit e6c7c2c

File tree

12 files changed

+225
-74
lines changed

12 files changed

+225
-74
lines changed

Documentation/git-am.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SYNOPSIS
1313
[--3way] [--interactive] [--committer-date-is-author-date]
1414
[--ignore-date]
1515
[--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
16-
[--reject]
16+
[--reject] [-q | --quiet]
1717
[<mbox> | <Maildir>...]
1818
'git am' (--skip | --resolved | --abort)
1919

@@ -39,6 +39,10 @@ OPTIONS
3939
--keep::
4040
Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
4141

42+
-q::
43+
--quiet::
44+
Be quiet. Only print error messages.
45+
4246
-u::
4347
--utf8::
4448
Pass `-u` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).

Documentation/git-rebase.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ OPTIONS
236236
is used instead ('git-merge-recursive' when merging a single
237237
head, 'git-merge-octopus' otherwise). This implies --merge.
238238

239+
-q::
240+
--quiet::
241+
Be quiet. Implies --no-stat.
242+
239243
-v::
240244
--verbose::
241245
Be verbose. Implies --stat.

Documentation/git-stash.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'git stash' list [<options>]
12-
'git stash' ( show | drop ) [<stash>]
13-
'git stash' ( pop | apply ) [--index] [<stash>]
12+
'git stash' show [<stash>]
13+
'git stash' drop [-q|--quiet] [<stash>]
14+
'git stash' ( pop | apply ) [--index] [-q|--quiet] [<stash>]
1415
'git stash' branch <branchname> [<stash>]
15-
'git stash' [save [--keep-index] [<message>]]
16+
'git stash' [save [--keep-index] [-q|--quiet] [<message>]]
1617
'git stash' clear
1718
'git stash' create
1819

@@ -41,7 +42,7 @@ is also possible).
4142
OPTIONS
4243
-------
4344

44-
save [--keep-index] [<message>]::
45+
save [--keep-index] [-q|--quiet] [<message>]::
4546

4647
Save your local modifications to a new 'stash', and run `git reset
4748
--hard` to revert them. This is the default action when no
@@ -75,7 +76,7 @@ show [<stash>]::
7576
it will accept any format known to 'git-diff' (e.g., `git stash show
7677
-p stash@\{1}` to view the second most recent stash in patch form).
7778

78-
pop [<stash>]::
79+
pop [--index] [-q|--quiet] [<stash>]::
7980

8081
Remove a single stashed state from the stash list and apply it
8182
on top of the current working tree state, i.e., do the inverse
@@ -93,7 +94,7 @@ longer apply the changes as they were originally).
9394
+
9495
When no `<stash>` is given, `stash@\{0}` is assumed.
9596

96-
apply [--index] [<stash>]::
97+
apply [--index] [-q|--quiet] [<stash>]::
9798

9899
Like `pop`, but do not remove the state from the stash list.
99100

@@ -115,7 +116,7 @@ clear::
115116
Remove all the stashed states. Note that those states will then
116117
be subject to pruning, and may be difficult or impossible to recover.
117118

118-
drop [<stash>]::
119+
drop [-q|--quiet] [<stash>]::
119120

120121
Remove a single stashed state from the stash list. When no `<stash>`
121122
is given, it removes the latest one. i.e. `stash@\{0}`

git-am.sh

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ git am [options] (--resolved | --skip | --abort)
1111
i,interactive run interactively
1212
b,binary* (historical option -- no-op)
1313
3,3way allow fall back on 3way merging if needed
14+
q,quiet be quiet
1415
s,signoff add a Signed-off-by line to the commit message
1516
u,utf8 recode into utf8 (default)
1617
k,keep pass -k flag to git-mailinfo
@@ -99,7 +100,7 @@ fall_back_3way () {
99100
git write-tree >"$dotest/patch-merge-base+" ||
100101
cannot_fallback "Repository lacks necessary blobs to fall back on 3-way merge."
101102

102-
echo Using index info to reconstruct a base tree...
103+
say Using index info to reconstruct a base tree...
103104
if GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
104105
git apply --cached <"$dotest/patch"
105106
then
@@ -115,7 +116,7 @@ It does not apply to blobs recorded in its index."
115116
orig_tree=$(cat "$dotest/patch-merge-base") &&
116117
rm -fr "$dotest"/patch-merge-* || exit 1
117118

118-
echo Falling back to patching base and 3-way merge...
119+
say Falling back to patching base and 3-way merge...
119120

120121
# This is not so wrong. Depending on which base we picked,
121122
# orig_tree may be wildly different from ours, but his_tree
@@ -125,6 +126,10 @@ It does not apply to blobs recorded in its index."
125126

126127
eval GITHEAD_$his_tree='"$FIRSTLINE"'
127128
export GITHEAD_$his_tree
129+
if test -n "$GIT_QUIET"
130+
then
131+
export GIT_MERGE_VERBOSITY=0
132+
fi
128133
git-merge-recursive $orig_tree -- HEAD $his_tree || {
129134
git rerere
130135
echo Failed to merge in the changes.
@@ -181,6 +186,8 @@ do
181186
committer_date_is_author_date=t ;;
182187
--ignore-date)
183188
ignore_date=t ;;
189+
-q|--quiet)
190+
GIT_QUIET=t ;;
184191
--)
185192
shift; break ;;
186193
*)
@@ -279,14 +286,15 @@ else
279286
exit 1
280287
}
281288

282-
# -s, -u, -k, --whitespace, -3, -C and -p flags are kept
289+
# -s, -u, -k, --whitespace, -3, -C, -q and -p flags are kept
283290
# for the resuming session after a patch failure.
284291
# -i can and must be given when resuming.
285292
echo " $git_apply_opt" >"$dotest/apply-opt"
286293
echo "$threeway" >"$dotest/threeway"
287294
echo "$sign" >"$dotest/sign"
288295
echo "$utf8" >"$dotest/utf8"
289296
echo "$keep" >"$dotest/keep"
297+
echo "$GIT_QUIET" >"$dotest/quiet"
290298
echo 1 >"$dotest/next"
291299
if test -n "$rebasing"
292300
then
@@ -327,6 +335,10 @@ if test "$(cat "$dotest/keep")" = t
327335
then
328336
keep=-k
329337
fi
338+
if test "$(cat "$dotest/quiet")" = t
339+
then
340+
GIT_QUIET=t
341+
fi
330342
if test "$(cat "$dotest/threeway")" = t
331343
then
332344
threeway=t
@@ -352,7 +364,7 @@ fi
352364

353365
if test "$this" -gt "$last"
354366
then
355-
echo Nothing to do.
367+
say Nothing to do.
356368
rm -fr "$dotest"
357369
exit
358370
fi
@@ -498,11 +510,18 @@ do
498510
stop_here $this
499511
fi
500512

501-
printf 'Applying: %s\n' "$FIRSTLINE"
513+
say "Applying: $FIRSTLINE"
502514

503515
case "$resolved" in
504516
'')
505-
eval 'git apply '"$git_apply_opt"' --index "$dotest/patch"'
517+
# When we are allowed to fall back to 3-way later, don't give
518+
# false errors during the initial attempt.
519+
squelch=
520+
if test "$threeway" = t
521+
then
522+
squelch='>/dev/null 2>&1 '
523+
fi
524+
eval "git apply $squelch$git_apply_opt"' --index "$dotest/patch"'
506525
apply_status=$?
507526
;;
508527
t)
@@ -534,7 +553,7 @@ do
534553
# Applying the patch to an earlier tree and merging the
535554
# result may have produced the same tree as ours.
536555
git diff-index --quiet --cached HEAD -- && {
537-
echo No changes -- Patch already applied.
556+
say No changes -- Patch already applied.
538557
go_next
539558
continue
540559
}
@@ -560,7 +579,7 @@ do
560579
GIT_AUTHOR_DATE=
561580
fi
562581
parent=$(git rev-parse --verify -q HEAD) ||
563-
echo >&2 "applying to an empty history"
582+
say >&2 "applying to an empty history"
564583
565584
if test -n "$committer_date_is_author_date"
566585
then

git-rebase.sh

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2005 Junio C Hamano.
44
#
55

6-
USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>]'
6+
USAGE='[--interactive | -i] [-v] [--force-rebase | -f] [--onto <newbase>] [<upstream>|--root] [<branch>] [--quiet | -q]'
77
LONG_USAGE='git-rebase replaces <branch> with a new branch of the
88
same name. When the --onto option is provided the new branch starts
99
out with a HEAD equal to <newbase>, otherwise it is equal to <upstream>
@@ -72,11 +72,20 @@ continue_merge () {
7272
echo "directly, but instead do one of the following: "
7373
die "$RESOLVEMSG"
7474
fi
75-
printf "Committed: %0${prec}d " $msgnum
75+
if test -z "$GIT_QUIET"
76+
then
77+
printf "Committed: %0${prec}d " $msgnum
78+
fi
7679
else
77-
printf "Already applied: %0${prec}d " $msgnum
80+
if test -z "$GIT_QUIET"
81+
then
82+
printf "Already applied: %0${prec}d " $msgnum
83+
fi
84+
fi
85+
if test -z "$GIT_QUIET"
86+
then
87+
git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
7888
fi
79-
git rev-list --pretty=oneline -1 "$cmt" | sed -e 's/^[^ ]* //'
8089

8190
prev_head=`git rev-parse HEAD^0`
8291
# save the resulting commit so we can read-tree on it later
@@ -97,6 +106,10 @@ call_merge () {
97106
eval GITHEAD_$cmt='"${cmt_name##refs/heads/}~$(($end - $msgnum))"'
98107
eval GITHEAD_$hd='$(cat "$dotest/onto_name")'
99108
export GITHEAD_$cmt GITHEAD_$hd
109+
if test -n "$GIT_QUIET"
110+
then
111+
export GIT_MERGE_VERBOSITY=1
112+
fi
100113
git-merge-$strategy "$cmt^" -- "$hd" "$cmt"
101114
rv=$?
102115
case "$rv" in
@@ -138,7 +151,7 @@ move_to_original_branch () {
138151
finish_rb_merge () {
139152
move_to_original_branch
140153
rm -r "$dotest"
141-
echo "All done."
154+
say All done.
142155
}
143156

144157
is_interactive () {
@@ -207,6 +220,7 @@ do
207220
end=$(cat "$dotest/end")
208221
msgnum=$(cat "$dotest/msgnum")
209222
onto=$(cat "$dotest/onto")
223+
GIT_QUIET=$(cat "$dotest/quiet")
210224
continue_merge
211225
while test "$msgnum" -le "$end"
212226
do
@@ -219,6 +233,7 @@ do
219233
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
220234
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
221235
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
236+
GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
222237
git am --resolved --3way --resolvemsg="$RESOLVEMSG" &&
223238
move_to_original_branch
224239
exit
@@ -236,6 +251,7 @@ do
236251
msgnum=$(cat "$dotest/msgnum")
237252
msgnum=$(($msgnum + 1))
238253
onto=$(cat "$dotest/onto")
254+
GIT_QUIET=$(cat "$dotest/quiet")
239255
while test "$msgnum" -le "$end"
240256
do
241257
call_merge "$msgnum"
@@ -247,6 +263,7 @@ do
247263
head_name=$(cat "$GIT_DIR"/rebase-apply/head-name) &&
248264
onto=$(cat "$GIT_DIR"/rebase-apply/onto) &&
249265
orig_head=$(cat "$GIT_DIR"/rebase-apply/orig-head) &&
266+
GIT_QUIET=$(cat "$GIT_DIR"/rebase-apply/quiet)
250267
git am -3 --skip --resolvemsg="$RESOLVEMSG" &&
251268
move_to_original_branch
252269
exit
@@ -258,9 +275,11 @@ do
258275
git rerere clear
259276
if test -d "$dotest"
260277
then
278+
GIT_QUIET=$(cat "$dotest/quiet")
261279
move_to_original_branch
262280
else
263281
dotest="$GIT_DIR"/rebase-apply
282+
GIT_QUIET=$(cat "$dotest/quiet")
264283
move_to_original_branch
265284
fi
266285
git reset --hard $(cat "$dotest/orig-head")
@@ -298,6 +317,13 @@ do
298317
-v|--verbose)
299318
verbose=t
300319
diffstat=t
320+
GIT_QUIET=
321+
;;
322+
-q|--quiet)
323+
GIT_QUIET=t
324+
git_am_opt="$git_am_opt -q"
325+
verbose=
326+
diffstat=
301327
;;
302328
--whitespace=*)
303329
git_am_opt="$git_am_opt $1"
@@ -442,15 +468,15 @@ then
442468
then
443469
# Lazily switch to the target branch if needed...
444470
test -z "$switch_to" || git checkout "$switch_to"
445-
echo >&2 "Current branch $branch_name is up to date."
471+
say "Current branch $branch_name is up to date."
446472
exit 0
447473
else
448-
echo "Current branch $branch_name is up to date, rebase forced."
474+
say "Current branch $branch_name is up to date, rebase forced."
449475
fi
450476
fi
451477

452478
# Detach HEAD and reset the tree
453-
echo "First, rewinding head to replay your work on top of it..."
479+
say "First, rewinding head to replay your work on top of it..."
454480
git checkout -q "$onto^0" || die "could not detach HEAD"
455481
git update-ref ORIG_HEAD $branch
456482

@@ -468,7 +494,7 @@ fi
468494
# we just fast forwarded.
469495
if test "$mb" = "$branch"
470496
then
471-
echo >&2 "Fast-forwarded $branch_name to $onto_name."
497+
say "Fast-forwarded $branch_name to $onto_name."
472498
move_to_original_branch
473499
exit 0
474500
fi
@@ -490,7 +516,8 @@ then
490516
test 0 != $ret -a -d "$GIT_DIR"/rebase-apply &&
491517
echo $head_name > "$GIT_DIR"/rebase-apply/head-name &&
492518
echo $onto > "$GIT_DIR"/rebase-apply/onto &&
493-
echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head
519+
echo $orig_head > "$GIT_DIR"/rebase-apply/orig-head &&
520+
echo "$GIT_QUIET" > "$GIT_DIR"/rebase-apply/quiet
494521
exit $ret
495522
fi
496523

@@ -504,6 +531,7 @@ prev_head=$orig_head
504531
echo "$prev_head" > "$dotest/prev_head"
505532
echo "$orig_head" > "$dotest/orig-head"
506533
echo "$head_name" > "$dotest/head-name"
534+
echo "$GIT_QUIET" > "$dotest/quiet"
507535

508536
msgnum=0
509537
for cmt in `git rev-list --reverse --no-merges "$revisions"`

0 commit comments

Comments
 (0)