Skip to content

Commit 204f01a

Browse files
jherlandgitster
authored andcommitted
--dirstat: Describe non-obvious differences relative to --stat or regular diff
Also add a testcase documenting the current behavior. Improved-by: Junio C Hamano <[email protected]> Signed-off-by: Johan Herland <[email protected]> Acked-by: Linus Torvalds <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5fb41b8 commit 204f01a

6 files changed

+40
-7
lines changed

Documentation/diff-options.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ endif::git-format-patch[]
7272
a cut-off percent (3% by default) are not shown. The cut-off percent
7373
can be set with `--dirstat=<limit>`. Changes in a child directory are not
7474
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.
7579

7680
--dirstat-by-file[=<limit>]::
7781
Same as `--dirstat`, but counts changed files instead of lines.

t/t4013-diff-various.sh

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,31 @@ test_expect_success setup '
8080
8181
git config log.showroot false &&
8282
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+
8393
git show-branch
8494
'
8595

8696
: <<\EOF
8797
! [initial] Initial
8898
* [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
95108
EOF
96109

97110
V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
@@ -287,6 +300,8 @@ diff --no-index --name-status -- dir2 dir
287300
diff --no-index dir dir3
288301
diff master master^ side
289302
diff --dirstat master~1 master~2
303+
# --dirstat doesn't notice changes that simply rearrange existing lines
304+
diff --dirstat initial rearrange
290305
EOF
291306

292307
test_expect_success 'log -S requires an argument' '
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$ git diff --dirstat initial rearrange
2+
$

t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$ git format-patch --stdout --cover-letter -n initial..master^
22
From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001
33
From: C O Mitter <[email protected]>
4-
Date: Mon, 26 Jun 2006 00:05:00 +0000
4+
Date: Mon, 26 Jun 2006 00:06:00 +0000
55
Subject: [DIFFERENT_PREFIX 0/2] *** SUBJECT HERE ***
66

77
*** BLURB HERE ***

t/t4013/diff.log_--decorate=full_--all

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
$ git log --decorate=full --all
2+
commit cd4e72fd96faed3f0ba949dc42967430374e2290 (refs/heads/rearrange)
3+
Author: A U Thor <[email protected]>
4+
Date: Mon Jun 26 00:06:00 2006 +0000
5+
6+
Rearranged lines in dir/sub
7+
28
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD, refs/heads/master)
39
Merge: 9a6d494 c7a2ab9
410
Author: A U Thor <[email protected]>

t/t4013/diff.log_--decorate_--all

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
$ git log --decorate --all
2+
commit cd4e72fd96faed3f0ba949dc42967430374e2290 (rearrange)
3+
Author: A U Thor <[email protected]>
4+
Date: Mon Jun 26 00:06:00 2006 +0000
5+
6+
Rearranged lines in dir/sub
7+
28
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD, master)
39
Merge: 9a6d494 c7a2ab9
410
Author: A U Thor <[email protected]>

0 commit comments

Comments
 (0)