Code

--dirstat: In case of renames, use target filename instead of source filename
authorJohan Herland <johan@herland.net>
Tue, 12 Apr 2011 09:24:34 +0000 (11:24 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Apr 2011 18:29:34 +0000 (11:29 -0700)
This changes --dirstat analysis to count "damage" toward the target filename,
rather than the source filename. For renames within a directory, this won't
matter to the final output, but when moving files between diretories, the
output now lists the target directory rather than the source directory.

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>
diff.c

diff --git a/diff.c b/diff.c
index 1f44cb4237317fd2e36bc9b00047b67f7e844e17..abd9cd5f33d40bc236f6e1d2946992cc967f0341 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1541,7 +1541,7 @@ static void show_dirstat(struct diff_options *options)
                unsigned long copied, added, damage;
                int content_changed;
 
-               name = p->one->path ? p->one->path : p->two->path;
+               name = p->two->path ? p->two->path : p->one->path;
 
                if (p->one->sha1_valid && p->two->sha1_valid)
                        content_changed = hashcmp(p->one->sha1, p->two->sha1);