{"thread":{"id":"379","subject":"[PATCH] Built-in diff driver shows Index: line.","startedAt":"2005-04-28T19:14:32Z","lastAt":"2005-04-28T22:41:34Z","messageCount":5,"participants":["Junio C Hamano","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2068","messageId":"7vy8b27lyf.fsf@assigned-by-dhcp.cox.net","threadId":"379","inReplyTo":null,"subject":"[PATCH] Built-in diff driver shows Index: line.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-28T19:14:32Z","receivedAt":"2005-04-28T19:14:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"As suggested by Linus as a workaround to unconfuse diffstat,\nthis patch adds Index: line before the diff output the built-in\ndriver produces.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\ndiff.c |    2 ++\n1 files changed, 2 insertions(+)\n\n# - 04/28 11:20 No need to say diff-tree -p -r in git-export\n# + 04/28 11:25 Show Index: line from built-in diff driver.\nIndex: diff.c\n--- k/diff.c  (mode:100644)\n+++ l/diff.c  (mode:100644)\n@@ -125,6 +125,8 @@ static void builtin_diff(const char *nam\n \tnext_at += snprintf(cmd+next_at, cmd_size-next_at,\n \t\t\t    diff_arg, input_name_sq[0], input_name_sq[1]);\n \n+\tprintf(\"Index: %s\\n\", name);\n+\tfflush(NULL);\n \texeclp(\"/bin/sh\",\"sh\", \"-c\", cmd, NULL);\n }\n \n\n"},{"id":"2071","messageId":"Pine.LNX.4.58.0504281236090.18901@ppc970.osdl.org","threadId":"379","inReplyTo":"7vy8b27lyf.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Built-in diff driver shows Index: line.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-28T20:05:25Z","receivedAt":"2005-04-28T20:05:25Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 28 Apr 2005, Junio C Hamano wrote:\n>\n> As suggested by Linus as a workaround to unconfuse diffstat,\n> this patch adds Index: line before the diff output the built-in\n> driver produces.\n\nActually, I do dislike the Index: line, and think this is a pretty\nintrusive work-around for a problem with diffstat.\n\nThere are other work-arounds for diffstat. In particular, diffstat has \nvarious heuristics for finding the filename from the +++/--- files, and \nthe main one is\n\n\t\"*** %[^\\t]\\t%[^ ] %[^ ] %d %d:%d:%d %d\"\n\n(where \"***\" can be either +++ or ---). If if you match that one, diffstat\nwill pick up the name (first match) on its own.\n\nOh, actually maybe the better pattern to use is the one that GNU diff \nitself ends up matching:\n\n\t\"*** %[^\\t ]%[\\t ]%d%c%d%c%d %d:%d:%d\"\n\nwhere the \"%c\" has to be either '-' or '/' (ie it ends up matching as \n\"numeric date\" + \"numeric time\").\n\nYou can put the \"mode\" thing at the end, and diffstat won't care about it.\n\n\t\tLinus\n"},{"id":"2099","messageId":"7vacni5z9y.fsf@assigned-by-dhcp.cox.net","threadId":"379","inReplyTo":"Pine.LNX.4.58.0504281236090.18901@ppc970.osdl.org","subject":"Re: [PATCH] Built-in diff driver shows Index: line.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-28T22:09:45Z","receivedAt":"2005-04-28T22:09:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"LT\" == Linus Torvalds <torvalds@osdl.org> writes:\n\nLT> Actually, I do dislike the Index: line, and think this is a pretty\nLT> intrusive work-around for a problem with diffstat.\n\nAlright.  Please consider the patch retracted.\n\nLT> Oh, actually maybe the better pattern to use is the one that GNU diff \nLT> itself ends up matching:\nLT> \t\"*** %[^\\t ]%[\\t ]%d%c%d%c%d %d:%d:%d\"\nLT> where the \"%c\" has to be either '-' or '/' (ie it ends up matching as \nLT> \"numeric date\" + \"numeric time\").\n\nLT> You can put the \"mode\" thing at the end, and diffstat won't care about it.\n\nHmph.  Timestamps do not mean anything in most of the intended\nuse of diff-* family, since they are meant to operate on trees,\nexcept:\n\n - comparing against the working tree --- show-diff's <new> and\n   diff-cache's <new>; we can take the timestamp from the\n   filesystem.\n\n - comparing against a tree that comes from a known commit ---\n   we can take the timestamp of the commit that contains the\n   file.\n\nIf we want to show the timestamp of the latter, diff-tree and\ndiff-cache need to be taught to take notice if their\ntree-or-commit parameter is actually a commit and if so needs to\npass the timestamp in the committer field down the path for the\ndiff driver.  There is no way for diff-tree-helper to do this\nbecause the origin information is already stripped out when it\nsees a valid SHA1.\n\nSo I'd say we'd punt this one for now, unless somebody else has\na better idea.\n\n"},{"id":"2105","messageId":"Pine.LNX.4.58.0504281522560.18901@ppc970.osdl.org","threadId":"379","inReplyTo":"7vacni5z9y.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Built-in diff driver shows Index: line.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-28T22:30:36Z","receivedAt":"2005-04-28T22:30:36Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 28 Apr 2005, Junio C Hamano wrote:\n> \n> So I'd say we'd punt this one for now, unless somebody else has\n> a better idea.\n\nIt's trivially easy to do it with a external diff helper.\n\nSo you can do it with a few lines of GIT_EXTERNAL_DIFF, and the hardest \npart is showing it in a nice format (ie do the normalization of the \nresults that diffstat does).\n\nThe external diff program can _literally_ just do something like\n\n\t#!/bin/sh\n\tname=\"$1\"\n\tsrc=\"$2\"\n\tdst=\"$5\"\n\tdiff \"$src\" \"$dst\" | cut -c1 | grep '[<>]' | sort | uniq -c\n\nand the output should be something like\n\n    458 <\n    104 >\n\nwhich means \"458 lines removed, 104 lines added\". Pretty-print it some, \nand you're done.\n\nHacky hacky,\n\n\t\tLinus\n"},{"id":"2106","messageId":"7v3bta5xsx.fsf@assigned-by-dhcp.cox.net","threadId":"379","inReplyTo":"Pine.LNX.4.58.0504281522560.18901@ppc970.osdl.org","subject":"Re: [PATCH] Built-in diff driver shows Index: line.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-28T22:41:34Z","receivedAt":"2005-04-28T22:41:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"LT\" == Linus Torvalds <torvalds@osdl.org> writes:\n\nLT> On Thu, 28 Apr 2005, Junio C Hamano wrote:\n>> \n>> So I'd say we'd punt this one for now, unless somebody else has\n>> a better idea.\n\nLT> It's trivially easy to do it with a external diff helper.\n\nWhat I meant to _punt_ is trying to show meaningful dates, not\nsatisfying the diffstat.\n\nLT> So you can do it with a few lines of GIT_EXTERNAL_DIFF ...\n\nHeh.  I am the one who wrote that stuff and you already know how\nto use that effectively far better than I do ;-).\n\n"}]}