git-rebase: Add --stat and --no-stat for producing diffstat on rebase
The behavior of --verbose is unchanged, but uses a different state variable internally, so that the meaning of verbose output may be expanded without affecting the diffstat. This is also reflected in the documentation. The configuration option rebase.stat works the same was as merg.stat, but the default is currently false. Signed-off-by: Tor Arne Vestbø <torarnv@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tor Arne Vestbø committed
Mar 1, 2009 at 23:11 UTC
a9c3821ca2fec065260b4314d61337a7529aba5b
4 files changed
+60
-9
Documentation/config.txt
+4
@@ -1160,6 +1160,10 @@ pull.octopus::
1160
pull.twohead::
1161
The default merge strategy to use when pulling a single branch.
1162
1163
+rebase.stat::
1164
+ Whether to show a diffstat of what changed upstream since the last
1165
+ rebase. False by default.
1166
+
1167
receive.fsckObjects::
1168
If it is set to true, git-receive-pack will check all received
1169
objects. It will abort in the case of a malformed object or a
Documentation/git-rebase.txt
+16
-1
@@ -192,6 +192,13 @@ Alternatively, you can undo the 'git-rebase' with
192
193
git rebase --abort
194
195
+CONFIGURATION
196
+-------------
197
+
198
+rebase.stat::
199
+ Whether to show a diffstat of what changed upstream since the last
200
+ rebase. False by default.
201
+
202
OPTIONS
203
-------
204
<newbase>::
@@ -232,7 +239,15 @@ OPTIONS
239
240
-v::
241
--verbose::
235
- Display a diffstat of what changed upstream since the last rebase.
242
+ Be verbose. Implies --stat.
243
+
244
+--stat::
245
+ Show a diffstat of what changed upstream since the last rebase. The
246
+ diffstat is also controlled by the configuration option rebase.stat.
247
+
248
+-n::
249
+--no-stat::
250
+ Do not show a diffstat as part of the rebase process.
251
252
--no-verify::
253
This option bypasses the pre-rebase hook. See also linkgit:githooks[5].
git-rebase.sh
+18
-7
@@ -46,6 +46,7 @@ do_merge=
46
dotest="$GIT_DIR"/rebase-merge
47
prec=4
48
verbose=
49
+diffstat=$(git config --bool rebase.stat)
50
git_am_opt=
51
rebase_root=
52
@@ -289,8 +290,15 @@ do
290
esac
291
do_merge=t
292
;;
293
+ -n|--no-stat)
294
+ diffstat=
295
+ ;;
296
+ --stat)
297
+ diffstat=t
298
+ ;;
299
-v|--verbose)
300
verbose=t
301
+ diffstat=t
302
;;
303
--whitespace=*)
304
git_am_opt="$git_am_opt $1"
@@ -426,18 +434,21 @@ then
434
exit 0
435
fi
436
429
-if test -n "$verbose"
430
-then
431
- echo "Changes from $mb to $onto:"
432
- # We want color (if set), but no pager
433
- GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
434
-fi
435
-
437
# Detach HEAD and reset the tree
438
echo "First, rewinding head to replay your work on top of it..."
439
git checkout -q "$onto^0" || die "could not detach HEAD"
440
git update-ref ORIG_HEAD $branch
441
442
+if test -n "$diffstat"
443
+then
444
+ if test -n "$verbose"
445
+ then
446
+ echo "Changes from $mb to $onto:"
447
+ fi
448
+ # We want color (if set), but no pager
449
+ GIT_PAGER='' git diff --stat --summary "$mb" "$onto"
450
+fi
451
+
452
# If the $onto is a proper descendant of the tip of the branch, then
453
# we just fast forwarded.
454
if test "$mb" = "$branch"
t/t3406-rebase-message.sh
+22
-1
@@ -22,7 +22,8 @@ test_expect_success setup '
22
git checkout topic &&
23
quick_one A &&
24
quick_one B &&
25
- quick_one Z
25
+ quick_one Z &&
26
+ git tag start
27
28
'
29
@@ -41,4 +42,24 @@ test_expect_success 'rebase -m' '
42
43
'
44
45
+test_expect_success 'rebase --stat' '
46
+ git reset --hard start
47
+ git rebase --stat master >diffstat.txt &&
48
+ grep "^ fileX | *1 +$" diffstat.txt
49
+'
50
+
51
+test_expect_success 'rebase w/config rebase.stat' '
52
+ git reset --hard start
53
+ git config rebase.stat true &&
54
+ git rebase master >diffstat.txt &&
55
+ grep "^ fileX | *1 +$" diffstat.txt
56
+'
57
+
58
+test_expect_success 'rebase -n overrides config rebase.stat config' '
59
+ git reset --hard start
60
+ git config rebase.stat true &&
61
+ git rebase -n master >diffstat.txt &&
62
+ ! grep "^ fileX | *1 +$" diffstat.txt
63
+'
64
+
65
test_done