Thread (2 messages) flat view 2 messages, 1 author, 2016-08-11

Re: [PATCH] Make cvsexportcommit work with filenames with spaces and non-ascii characters.

From: Junio C Hamano <hidden>
Date: 2016-08-11 20:11:18
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
But all of the above shows deficiency in the current set of
tools -- they are not helping Porcelain writers enough.  I think
we should enhance 'apply --numstat' to let it show binary diffs
differently:

	git diff-tree -p $parent $commit >.tmpfile
        git apply --numstat -z <.tmpfile

would currently say "0 0" for binary files (the primary benefit
of using "--numstat -z" here is that it would give Perl scripts
pathnames parsable without C dequoting).  We should somehow have
a way to show it differently from text files without any
added/deleted lines (e.g. only the mode change), and that would
make the life of Porcelain writers who needs to write something
like the above code much more pleasant.  Perhaps show "- -"
instead of "0 0", since there is no notion of lines in "binary
files differ" case?
That is, something like this...

-- >8 --
[PATCH] apply --numstat: mark binary diffstat with - -, not 0 0

We do not even know number of lines so showing it as 0 0 is
lying.  This would also help Porcelains like cvsexportcommit.

Signed-off-by: Junio C Hamano <redacted>
---
 builtin-apply.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/builtin-apply.c b/builtin-apply.c
index aad5526..b80ad2c 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2116,7 +2116,11 @@ static void numstat_patch_list(struct pa
 	for ( ; patch; patch = patch->next) {
 		const char *name;
 		name = patch->new_name ? patch->new_name : patch->old_name;
-		printf("%d\t%d\t", patch->lines_added, patch->lines_deleted);
+		if (patch->is_binary)
+			printf("-\t-\t");
+		else
+			printf("%d\t%d\t",
+			       patch->lines_added, patch->lines_deleted);
 		if (line_termination && quote_c_style(name, NULL, NULL, 0))
 			quote_c_style(name, NULL, stdout, 0);
 		else
-- 
1.4.4.rc2.g2a54
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help