From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCHv3 1/3] diff.c: omit hidden entries from namelen calculation with --stat
Date: Fri, 27 May 2011 14:36:40 +0200 [thread overview]
Message-ID: <b47e2f0865bac1ad0e7b777ce9f27493292c502c.1306499600.git.git@drmicha.warpmail.net> (raw)
In-Reply-To: <4DC0FD3D.9010004@drmicha.warpmail.net>
In-Reply-To: <cover.1306499600.git.git@drmicha.warpmail.net>
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>
---
This optimizes (tightens) the display potentially, but we never had tests
which are sensitive to that.
---
diff.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/diff.c b/diff.c
index feced34..4541939 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
--
1.7.5.2.657.g62c2
next prev parent reply other threads:[~2011-05-27 12:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-29 14:57 [PATCH 1/2] diff: introduce --stat-lines to limit the stat lines Michael J Gruber
2011-04-29 14:57 ` [PATCH 2/2] diff-options.txt: describe --stat-{width,name-width,lines} Michael J Gruber
2011-04-29 15:12 ` [PATCH 1/2] diff: introduce --stat-lines to limit the stat lines Michael J Gruber
2011-04-29 16:15 ` Junio C Hamano
2011-05-01 8:27 ` Michael J Gruber
2011-05-01 18:33 ` Junio C Hamano
2011-05-03 10:46 ` [PATCHv2 " Michael J Gruber
2011-05-03 10:46 ` [PATCHv2 2/2] diff-options.txt: describe --stat-{width,name-width,count} Michael J Gruber
2011-05-03 18:47 ` [PATCHv2 1/2] diff: introduce --stat-lines to limit the stat lines Junio C Hamano
2011-05-04 7:16 ` Michael J Gruber
2011-05-27 12:36 ` [PATCHv3 0/3] diff.c: --stat-count=<n> Michael J Gruber
2011-05-27 12:36 ` Michael J Gruber [this message]
2011-05-27 17:43 ` [PATCHv3 1/3] diff.c: omit hidden entries from namelen calculation with --stat Junio C Hamano
2011-05-27 20:19 ` Michael J Gruber
2011-05-27 22:45 ` Junio C Hamano
2011-05-27 12:36 ` [PATCHv3 2/3] diff: introduce --stat-lines to limit the stat lines Michael J Gruber
2011-05-28 4:46 ` Junio C Hamano
2011-05-30 6:40 ` Michael J Gruber
2011-05-30 7:36 ` Junio C Hamano
2011-05-27 12:36 ` [PATCHv3 3/3] diff-options.txt: describe --stat-{width,name-width,count} Michael J Gruber
2011-05-04 4:37 ` [PATCHv2 1/2] diff: introduce --stat-lines to limit the stat lines Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b47e2f0865bac1ad0e7b777ce9f27493292c502c.1306499600.git.git@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).