@matheusbsbs / matheus-bagliano / commits / 204f01a2f7
Fork 0

--dirstat: Describe non-obvious differences relative to --stat or regular diff

Also add a testcase documenting the current behavior. Improved-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Johan Herland <johan@herland.net> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johan Herland committed Apr 11, 2011 at 00:48 UTC 204f01a2f734fddab95b09123b04b1305620e7b6
6 files changed +40 -7
Documentation/diff-options.txt
+4
@@ -72,6 +72,10 @@ endif::git-format-patch[]
72 a cut-off percent (3% by default) are not shown. The cut-off percent
73 can be set with `--dirstat=<limit>`. Changes in a child directory are not
74 counted for the parent directory, unless `--cumulative` is used.
75 ++
76 +Note that the `--dirstat` option computes the changes while ignoring
77 +pure code movements within a file. In other words, rearranging lines
78 +in a file is not counted as a change.
79
80 --dirstat-by-file[=<limit>]::
81 Same as `--dirstat`, but counts changed files instead of lines.
t/t4013-diff-various.sh
+21 -6
@@ -80,18 +80,31 @@ test_expect_success setup '
80
81 git config log.showroot false &&
82 git commit --amend &&
83 +
84 + GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
85 + GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
86 + export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
87 + git checkout -b rearrange initial &&
88 + for i in B A; do echo $i; done >dir/sub &&
89 + git add dir/sub &&
90 + git commit -m "Rearranged lines in dir/sub" &&
91 + git checkout master &&
92 +
93 git show-branch
94 '
95
96 : <<\EOF
97 ! [initial] Initial
98 * [master] Merge branch 'side'
89 - ! [side] Side
90 ----
91 - - [master] Merge branch 'side'
92 - *+ [side] Side
93 - * [master^] Second
94 -+*+ [initial] Initial
99 + ! [rearrange] Rearranged lines in dir/sub
100 + ! [side] Side
101 +----
102 + + [rearrange] Rearranged lines in dir/sub
103 + - [master] Merge branch 'side'
104 + * + [side] Side
105 + * [master^] Third
106 + * [master~2] Second
107 ++*++ [initial] Initial
108 EOF
109
110 V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
@@ -287,6 +300,8 @@ diff --no-index --name-status -- dir2 dir
300 diff --no-index dir dir3
301 diff master master^ side
302 diff --dirstat master~1 master~2
303 +# --dirstat doesn't notice changes that simply rearrange existing lines
304 +diff --dirstat initial rearrange
305 EOF
306
307 test_expect_success 'log -S requires an argument' '
t/t4013/diff.diff_--dirstat_initial_rearrange new
+2
@@ -0,0 +1,2 @@
1 +$ git diff --dirstat initial rearrange
2 +$
t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^
+1 -1
@@ -1,7 +1,7 @@
1 $ git format-patch --stdout --cover-letter -n initial..master^
2 From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001
3 From: C O Mitter <committer@example.com>
4 -Date: Mon, 26 Jun 2006 00:05:00 +0000
4 +Date: Mon, 26 Jun 2006 00:06:00 +0000
5 Subject: [DIFFERENT_PREFIX 0/2] *** SUBJECT HERE ***
6
7 *** BLURB HERE ***
t/t4013/diff.log_--decorate=full_--all
+6
@@ -1,4 +1,10 @@
1 $ git log --decorate=full --all
2 +commit cd4e72fd96faed3f0ba949dc42967430374e2290 (refs/heads/rearrange)
3 +Author: A U Thor <author@example.com>
4 +Date: Mon Jun 26 00:06:00 2006 +0000
5 +
6 + Rearranged lines in dir/sub
7 +
8 commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD, refs/heads/master)
9 Merge: 9a6d494 c7a2ab9
10 Author: A U Thor <author@example.com>
t/t4013/diff.log_--decorate_--all
+6
@@ -1,4 +1,10 @@
1 $ git log --decorate --all
2 +commit cd4e72fd96faed3f0ba949dc42967430374e2290 (rearrange)
3 +Author: A U Thor <author@example.com>
4 +Date: Mon Jun 26 00:06:00 2006 +0000
5 +
6 + Rearranged lines in dir/sub
7 +
8 commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD, master)
9 Merge: 9a6d494 c7a2ab9
10 Author: A U Thor <author@example.com>