summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2011-05-27 14:36:40 +0200
committerJunio C Hamano <gitster@pobox.com>2011-05-27 10:44:02 -0700
commit358e460eebd3c19f228f02461b5f161ea48b0a98 (patch)
tree228b757cce143536603c4660aa04a5e4ae6b528a /diff.c
parent0b9deecf625677cf44058a42c2abd7add5167e81 (diff)
downloadgit-358e460eebd3c19f228f02461b5f161ea48b0a98.tar.gz
diff.c: omit hidden entries from namelen calculation with --stat
Currently, --stat calculates the longest name from all items but then drops some (mode changes) from the output later on. Instead, drop them from the namelen generation and calculation. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/diff.c b/diff.c
index 3b40e597d5..0c69354d0a 100644
--- a/diff.c
+++ b/diff.c
@@ -1278,6 +1278,10 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
for (i = 0; i < data->nr; i++) {
struct diffstat_file *file = data->files[i];
uintmax_t change = file->added + file->deleted;
+ if (!data->files[i]->is_renamed &&
+ (change == 0)) {
+ continue;
+ }
fill_print_name(file);
len = strlen(file->print_name);
if (max_len < len)
@@ -1309,6 +1313,11 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
uintmax_t deleted = data->files[i]->deleted;
int name_len;
+ if (!data->files[i]->is_renamed &&
+ (added + deleted == 0)) {
+ total_files--;
+ continue;
+ }
/*
* "scale" the filename
*/
@@ -1343,11 +1352,6 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
fprintf(options->file, " Unmerged\n");
continue;
}
- else if (!data->files[i]->is_renamed &&
- (added + deleted == 0)) {
- total_files--;
- continue;
- }
/*
* scale the add/delete