summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2006-05-08 16:46:53 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-05-08 17:54:30 (GMT)
commit5d6a9f45e1ba78693cb0fbd5e9724b05d4e30e37 (patch)
tree75e8f9f7b224a1f1bd1f68e1760da90773484b46
parentf8ba655ee4131e5c73c28a4ea854b24ce4058e1e (diff)
downloadgit-5d6a9f45e1ba78693cb0fbd5e9724b05d4e30e37.zip
git-5d6a9f45e1ba78693cb0fbd5e9724b05d4e30e37.tar.gz
git-5d6a9f45e1ba78693cb0fbd5e9724b05d4e30e37.tar.bz2
Fix "git diff --stat" with long filenames
When we cut off the front of a filename to make it fit on the line, we add a "..." in front. However, the way the "git diff" code was written, we will never reset the prefix back to the empty string, so every single filename afterwards will have the "..." prefix, whether appropriate or not. You can see this with "git diff v2.6.16.." on the current kernel tree, since there are filenames with long names that changed there: [ snip snip ] Documentation/filesystems/vfs.txt | 229 .../firmware_class/firmware_sample_driver.c | 3 .../firmware_sample_firmware_class.c | 1 ...Documentation/fujitsu/frv/kernel-ABI.txt | 192 ...Documentation/hwmon/w83627hf | 4 [ snip snip ] notice how the two Documentation/firmware** filenames caused the "..." to be added, but then the later filenames don't want it, and it also screws up the alignment of the line numbering afterwards. Trivially fixed by moving the declaration (and initial setting) of the "prefix" variable into the for-loop where it is used. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--diff.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 903afa1..afaa648 100644
--- a/diff.c
+++ b/diff.c
@@ -239,7 +239,6 @@ static const char minuses[]= "--------------------------------------------------
static void show_stats(struct diffstat_t* data)
{
- char *prefix = "";
int i, len, add, del, total, adds = 0, dels = 0;
int max, max_change = 0, max_len = 0;
int total_files = data->nr;
@@ -261,6 +260,7 @@ static void show_stats(struct diffstat_t* data)
}
for (i = 0; i < data->nr; i++) {
+ char *prefix = "";
char *name = data->files[i]->name;
int added = data->files[i]->added;
int deleted = data->files[i]->deleted;