{"thread":{"id":"43447","subject":"Re: [PATCH] git-diff: don't add trailing blanks (i.e., do what GNU diff -u now does)","startedAt":"2006-12-17T19:32:14Z","lastAt":"2006-12-18T12:06:08Z","messageCount":6,"participants":["Jakub Narebski","Junio C Hamano","Jim Meyering","Johannes Schindelin","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"295249","messageId":"87y7p6nwsh.fsf@rho.meyering.net","threadId":"43447","inReplyTo":null,"subject":"[PATCH] git-diff: don't add trailing blanks (i.e., do what GNU diff -u now does)","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2006-12-17T19:32:14Z","receivedAt":"2006-12-17T19:32:14Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"You may recall that GNU diff -u changed recently so that it no\nlonger outputs any trailing space unless the input data has it.\nThis means that blank context lines are now blank also in diff -u output.\nBefore, they would have a single trailing space.\n\nThen, git was changed to allow that new diff output format.\nNow that git-diff generates output using its internal diff, its\noutput is no longer identical to what you get when using GNU diff.\n\nThis patch makes the output of git-diff the same as GNU diff's.\n\nSigned-off-by: Jim Meyering <jim@meyering.net>\n---\n t/t4016-diff-trailing-space.sh |   31 +++++++++++++++++++++++++++++++\n xdiff/xutils.c                 |    3 +++\n 2 files changed, 34 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t4016-diff-trailing-space.sh b/t/t4016-diff-trailing-space.sh\nnew file mode 100755\nindex 0000000..95c4674\n--- /dev/null\n+++ b/t/t4016-diff-trailing-space.sh\n@@ -0,0 +1,31 @@\n+#!/bin/bash\n+#\n+# Copyright (c) Jim Meyering\n+#\n+test_description='diff does not add trailing spaces'\n+\n+. ./test-lib.sh\n+\n+cat <<\\EOF > exp ||\n+diff --git a/f b/f\n+index 5f6a263..8cb8bae 100644\n+--- a/f\n++++ b/f\n+@@ -1,2 +1,2 @@\n+\n+-x\n++y\n+EOF\n+exit 1\n+\n+test_expect_success \\\n+    \"$test_description\" \\\n+    '(echo; echo x) > f &&\n+     git-add f &&\n+     git-commit -q -m. f &&\n+     (echo; echo y) > f &&\n+     git-diff f > actual &&\n+     cmp exp actual\n+     '\n+\n+test_done\ndiff --git a/xdiff/xutils.c b/xdiff/xutils.c\nindex 1b899f3..8b7380a 100644\n--- a/xdiff/xutils.c\n+++ b/xdiff/xutils.c\n@@ -51,6 +51,9 @@ int xdl_emit_diffrec(char const *rec, long size, char const *pre, long psize,\n \tmb[0].size = psize;\n \tmb[1].ptr = (char *) rec;\n \tmb[1].size = size;\n+\t/* Don't emit a trailing space for an empty context line.  */\n+\tif (size == 1 && rec[0] == '\\n' && psize == 1 && *pre == ' ')\n+\t\tmb[0].size = 0;\n \tif (size > 0 && rec[size - 1] != '\\n') {\n \t\tmb[2].ptr = (char *) \"\\n\\\\ No newline at end of file\\n\";\n \t\tmb[2].size = strlen(mb[2].ptr);\n--\n"},{"id":"297989","messageId":"Pine.LNX.4.64.0612171200290.3479@woody.osdl.org","threadId":"43447","inReplyTo":"87y7p6nwsh.fsf@rho.meyering.net","subject":"Re: [PATCH] git-diff: don't add trailing blanks (i.e., do what GNU diff -u now does)","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-12-17T20:00:59Z","receivedAt":"2006-12-17T20:00:59Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 17 Dec 2006, Jim Meyering wrote:\n>\n> You may recall that GNU diff -u changed recently so that it no\n> longer outputs any trailing space unless the input data has it.\n\nI still consider that to be a bug in GNU \"diff -u\".\n\nWe work around that bug when applying patches, but I don't think we should \nreplicate it.\n\n"},{"id":"294955","messageId":"7vtzzu5lp1.fsf@assigned-by-dhcp.cox.net","threadId":"43447","inReplyTo":"Pine.LNX.4.64.0612171200290.3479@woody.osdl.org","subject":"Re: [PATCH] git-diff: don't add trailing blanks (i.e., do what GNU diff -u now does)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-17T20:09:14Z","receivedAt":"2006-12-17T20:09:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@osdl.org> writes:\n\n> On Sun, 17 Dec 2006, Jim Meyering wrote:\n>>\n>> You may recall that GNU diff -u changed recently so that it no\n>> longer outputs any trailing space unless the input data has it.\n>\n> I still consider that to be a bug in GNU \"diff -u\".\n>\n> We work around that bug when applying patches, but I don't think we should \n> replicate it.\n\nMe neither.\n"},{"id":"296655","messageId":"87psainttt.fsf@rho.meyering.net","threadId":"43447","inReplyTo":"7vtzzu5lp1.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-diff: don't add trailing blanks (i.e., do what GNU diff -u now does)","fromName":"Jim Meyering","fromEmail":"jim@meyering.net","sentAt":"2006-12-17T20:36:14Z","receivedAt":"2006-12-17T20:36:14Z","isPatch":true,"sender":{"key":"jim@meyering.net","avatar":"https://avatars.githubusercontent.com/u/710630?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Linus Torvalds <torvalds@osdl.org> writes:\n>> On Sun, 17 Dec 2006, Jim Meyering wrote:\n>>> You may recall that GNU diff -u changed recently so that it no\n>>> longer outputs any trailing space unless the input data has it.\n>>\n>> I still consider that to be a bug in GNU \"diff -u\".\n>>\n>> We work around that bug when applying patches, but I don't think we should\n>> replicate it.\n>\n> Me neither.\n\nI can't say I didn't expect this.\n"},{"id":"294836","messageId":"em4all$b2c$1@sea.gmane.org","threadId":"43447","inReplyTo":"7vtzzu5lp1.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] git-diff: don't add trailing blanks (i.e., do what GNU diff -u now does)","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-17T20:54:41Z","receivedAt":"2006-12-17T20:54:41Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Linus Torvalds <torvalds@osdl.org> writes:\n> \n>> On Sun, 17 Dec 2006, Jim Meyering wrote:\n>>>\n>>> You may recall that GNU diff -u changed recently so that it no\n>>> longer outputs any trailing space unless the input data has it.\n>>\n>> I still consider that to be a bug in GNU \"diff -u\".\n>>\n>> We work around that bug when applying patches, but I don't think we should \n>> replicate it.\n> \n> Me neither.\n\nPerhaps with --gnu-diff-compatibility then? \n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"296751","messageId":"Pine.LNX.4.63.0612181305500.3635@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43447","inReplyTo":"em4all$b2c$1@sea.gmane.org","subject":"Re: [PATCH] git-diff: don't add trailing blanks (i.e., do what GNU diff -u now does)","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-18T12:06:08Z","receivedAt":"2006-12-18T12:06:08Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 17 Dec 2006, Jakub Narebski wrote:\n\n> Junio C Hamano wrote:\n> \n> > Linus Torvalds <torvalds@osdl.org> writes:\n> > \n> >> On Sun, 17 Dec 2006, Jim Meyering wrote:\n> >>>\n> >>> You may recall that GNU diff -u changed recently so that it no\n> >>> longer outputs any trailing space unless the input data has it.\n> >>\n> >> I still consider that to be a bug in GNU \"diff -u\".\n> >>\n> >> We work around that bug when applying patches, but I don't think we should \n> >> replicate it.\n> > \n> > Me neither.\n> \n> Perhaps with --gnu-diff-compatibility then? \n\nRather --braindead-gnu-bug-compatibility.\n\nCiao,\nDscho\n"}]}