diff options
author | Johan Herland <johan@herland.net> | 2011-04-11 00:48:51 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-04-11 10:12:24 -0700 |
commit | 0133dab75d8b15c559aa9df66134d72dce0e0476 (patch) | |
tree | e49bd774366c6423641afb8aa38bb7f1bd6cd5f9 /t | |
parent | 204f01a2f734fddab95b09123b04b1305620e7b6 (diff) | |
download | git-0133dab75d8b15c559aa9df66134d72dce0e0476.tar.gz git-0133dab75d8b15c559aa9df66134d72dce0e0476.tar.xz |
--dirstat-by-file: Make it faster and more correct
Currently, when using --dirstat-by-file, it first does the full --dirstat
analysis (using diffcore_count_changes()), and then resets 'damage' to 1,
if any damage was found by diffcore_count_changes().
But --dirstat-by-file is not interested in the file damage per se. It only
cares if the file changed at all. In that sense it only cares if the blob
object for a file has changed. We therefore only need to compare the
object names of each file pair in the diff queue and we can skip the
entire --dirstat analysis and simply set 'damage' to 1 for each entry
where the object name has changed.
This makes --dirstat-by-file faster, and also bypasses --dirstat's practice
of ignoring rearranged lines within a file.
The patch also contains an added testcase verifying that --dirstat-by-file
now detects changes that only rearrange lines within a file.
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>
Diffstat (limited to 't')
-rwxr-xr-x | t/t4013-diff-various.sh | 2 | ||||
-rw-r--r-- | t/t4013/diff.diff_--dirstat-by-file_initial_rearrange | 3 |
2 files changed, 5 insertions, 0 deletions
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 3b1b392a5..6428a905a 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -302,6 +302,8 @@ diff master master^ side diff --dirstat master~1 master~2 # --dirstat doesn't notice changes that simply rearrange existing lines diff --dirstat initial rearrange +# ...but --dirstat-by-file does notice changes that only rearrange lines +diff --dirstat-by-file initial rearrange EOF test_expect_success 'log -S requires an argument' ' diff --git a/t/t4013/diff.diff_--dirstat-by-file_initial_rearrange b/t/t4013/diff.diff_--dirstat-by-file_initial_rearrange new file mode 100644 index 000000000..e48e33f67 --- /dev/null +++ b/t/t4013/diff.diff_--dirstat-by-file_initial_rearrange @@ -0,0 +1,3 @@ +$ git diff --dirstat-by-file initial rearrange + 100.0% dir/ +$ |