{"thread":{"id":"507","subject":"[PATCH] Tweak git-diff-tree -v output further.","startedAt":"2005-05-06T19:27:05Z","lastAt":"2005-05-06T21:54:24Z","messageCount":2,"participants":["Junio C Hamano","Linus Torvalds"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2699","messageId":"7vd5s4cfzq.fsf@assigned-by-dhcp.cox.net","threadId":"507","inReplyTo":null,"subject":"[PATCH] Tweak git-diff-tree -v output further.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-06T19:27:05Z","receivedAt":"2005-05-06T19:27:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The first hunk of this is a pure bugfix---it guards us against a\ncommit message that does not end with a newline.\n\nThis adds the full header information to git-diff-tree -v output\nin addition to the log message it already produces.\n\nMaybe we want to stop indenting so that it matches what\ngit-export produces better.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\ndiff-tree.c |   30 ++++++++++++++++++++----------\n1 files changed, 20 insertions(+), 10 deletions(-)\n\n# - linus-mirror: diff-tree: add \"verbose header\" mode\n# + (working tree)\n--- a/diff-tree.c\n+++ b/diff-tree.c\n@@ -278,7 +278,7 @@ static int get_one_line(const char *msg,\n \n \twhile (len--) {\n \t\tret++;\n-\t\tif (*msg++ == '\\n')\n+\t\tif (!*msg || *msg++ == '\\n')\n \t\t\tbreak;\n \t}\n \treturn ret;\n@@ -287,12 +287,14 @@ static int get_one_line(const char *msg,\n static char *generate_header(const char *commit, const char *parent, const char *msg, unsigned long len)\n {\n \tstatic char this_header[1000];\n-\tint offset;\n \n-\toffset = sprintf(this_header, \"%s%s (from %s)\\n\", header_prefix, commit, parent);\n-\tif (verbose_header) {\n+\tif (!verbose_header)\n+\t\tsprintf(this_header, \"%s%s (from %s)\\n\", header_prefix,\n+\t\t\tcommit, parent);\n+\telse {\n+\t\tint offset;\n \t\tint hdr = 1;\n-\n+\t\toffset = sprintf(this_header, \"Id: %s\\n\", commit);\n \t\tfor (;;) {\n \t\t\tconst char *line = msg;\n \t\t\tint linelen = get_one_line(msg, len);\n@@ -306,11 +308,19 @@ static char *generate_header(const char \n \t\t\tlen -= linelen;\n \t\t\tif (linelen == 1)\n \t\t\t\thdr = 0;\n-\t\t\tif (hdr)\n-\t\t\t\tcontinue;\n-\t\t\tmemset(this_header + offset, ' ', 4);\n-\t\t\tmemcpy(this_header + offset + 4, line, linelen);\n-\t\t\toffset += linelen + 4;\n+\t\t\tif (hdr) {\n+\t\t\t\tmemcpy(this_header + offset, line, linelen);\n+\t\t\t\tif (!strncmp(line, \"parent \", 7) &&\n+\t\t\t\t    !strncmp(line+7, parent, 40))\n+\t\t\t\t\tthis_header[offset + 6] = '*';\n+\t\t\t\toffset += linelen;\n+\t\t\t\t\t\n+\t\t\t}\n+\t\t\telse {\n+\t\t\t\tmemset(this_header + offset, ' ', 4);\n+\t\t\t\tmemcpy(this_header + offset + 4, line, linelen);\n+\t\t\t\toffset += linelen + 4;\n+\t\t\t}\n \t\t}\n \t\tthis_header[offset++] = '\\n';\n \t\tthis_header[offset] = 0;\n\n"},{"id":"2712","messageId":"Pine.LNX.4.58.0505061451530.2233@ppc970.osdl.org","threadId":"507","inReplyTo":"7vd5s4cfzq.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Tweak git-diff-tree -v output further.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-05-06T21:54:24Z","receivedAt":"2005-05-06T21:54:24Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 6 May 2005, Junio C Hamano wrote:\n> \n> This adds the full header information to git-diff-tree -v output\n> in addition to the log message it already produces.\n\nI don't actually like the git internal commit format, it's not very \nreadable. It's designed to be nicely readable by machines, not humans.\n\nIf you want machine-readable output, you shouldn't use \"-v\" (or probably\n-p either) anyway, you'd be better off with the raw file changes.\n\n> Maybe we want to stop indenting so that it matches what\n> git-export produces better.\n\nAgain, it's indented so that it's human-readable, and I was planning on\nadding _some_ human-readable output from the headers (author and a\nhuman-readable date or something).\n\n\t\tLinus\n"}]}