{"thread":{"id":"848","subject":"[PATCH] Make git-diff-tree --pretty","startedAt":"2005-06-06T21:16:31Z","lastAt":"2005-06-06T21:16:31Z","messageCount":1,"participants":["Dan Holmsand"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4657","messageId":"d82e8d$km9$1@sea.gmane.org","threadId":"848","inReplyTo":null,"subject":"[PATCH] Make git-diff-tree --pretty","fromName":"Dan Holmsand","fromEmail":"holmsand@gmail.com","sentAt":"2005-06-06T21:16:31Z","receivedAt":"2005-06-06T21:16:31Z","isPatch":true,"sender":{"key":"holmsand@gmail.com","avatar":"https://gravatar.com/avatar/5c722084bafd85e754a02efad01fe69107eb6f393253c49232c5c9f7faa974df?d=mp&s=160"},"body":"Make git-diff-tree --pretty[=[short|medium|raw]] work as in\ngit-rev-list.\n\nAlso suppress duplicate newline in 'git-diff-tree -s' output.\n\nSigned-off-by: Dan Holmsand <holmsand@gmail.com>\n---\n\n\n diff-tree.c |   22 +++++++++++++++++++++-\n 1 files changed, 21 insertions(+), 1 deletions(-)\n\ndiff --git a/diff-tree.c b/diff-tree.c\n--- a/diff-tree.c\n+++ b/diff-tree.c\n@@ -323,7 +323,8 @@ static char *generate_header(const char \n \toffset = sprintf(this_header, \"%s%s (from %s)\\n\", header_prefix, commit, parent);\n \tif (verbose_header) {\n \t\toffset += pretty_print_commit(commit_format, msg, len, this_header + offset, sizeof(this_header) - offset);\n-\t\tthis_header[offset++] = '\\n';\n+\t\tif (diff_output_format != DIFF_FORMAT_NO_OUTPUT)\n+\t\t\tthis_header[offset++] = '\\n';\n \t\tthis_header[offset++] = 0;\n \t}\n \n@@ -400,6 +401,19 @@ static int diff_tree_stdin(char *line)\n static char *diff_tree_usage =\n \"git-diff-tree [-p] [-r] [-z] [--stdin] [-M] [-C] [-R] [-S<string>] [-O<orderfile>] [-m] [-s] [-v] [-t] <tree-ish> <tree-ish>\";\n \n+static enum cmit_fmt get_commit_format(const char *arg)\n+{\n+\tif (!*arg)\n+\t\treturn CMIT_FMT_DEFAULT;\n+\tif (!strcmp(arg, \"=raw\"))\n+\t\treturn CMIT_FMT_RAW;\n+\tif (!strcmp(arg, \"=medium\"))\n+\t\treturn CMIT_FMT_MEDIUM;\n+\tif (!strcmp(arg, \"=short\"))\n+\t\treturn CMIT_FMT_SHORT;\n+\tusage(diff_tree_usage);\t\n+}\t\t\t\n+\n int main(int argc, const char **argv)\n {\n \tint nr_sha1;\n@@ -492,6 +506,12 @@ int main(int argc, const char **argv)\n \t\t\theader_prefix = \"diff-tree \";\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strncmp(arg, \"--pretty\", 8)) {\n+\t\t\tcommit_format = get_commit_format(arg+8);\n+\t\t\tverbose_header = 1;\n+\t\t\theader_prefix = \"diff-tree \";\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"--stdin\")) {\n \t\t\tread_stdin = 1;\n \t\t\tcontinue;\n"}]}