{"thread":{"id":"110","subject":"[PATCH 4/6] show-diff.c: adjust default format for the Linux kernel.","startedAt":"2005-04-18T20:35:42Z","lastAt":"2005-04-18T20:35:42Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"689","messageId":"7vis2ju8kh.fsf@assigned-by-dhcp.cox.net","threadId":"110","inReplyTo":null,"subject":"[PATCH 4/6] show-diff.c: adjust default format for the Linux kernel.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-18T20:35:42Z","receivedAt":"2005-04-18T20:35:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"[PATCH 4/6] show-diff.c: adjust default format for the Linux kernel.\n\nThis patch adjusts the default output format of show-diff to match\nthe Linux kernel style, recommended in Documentation/SubmittingPatches.\n\nTo be applied on top of:\n\n    [PATCH 1/6] show-diff.c: clean up private buffer use.\n    [PATCH 2/6] show-diff.c: check unreadbale blob.\n    [PATCH 3/6] show-diff.c: simplify show_diff_empty.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n show-diff.c |    7 ++++---\n 1 files changed, 4 insertions(+), 3 deletions(-)\n\n--- a/show-diff.c\n+++ b/show-diff.c\n@@ -5,7 +5,7 @@\n  */\n #include \"cache.h\"\n \n-static char *diff_cmd = \"diff -L '%s' -u -N  - '%s'\";\n+static char *diff_cmd = \"diff -L 'a/%s' -L 'b/%s' -p -u - '%s'\";\n \n /* Help to copy the thing properly quoted for the shell safety.\n  * any single quote is replaced with '\\'', and the caller is\n@@ -52,11 +52,12 @@ static void show_differences(char *name,\n \tFILE *f;\n \tchar *name_sq = sq_expand(name);\n \tchar *label_sq = (name != label) ? sq_expand(label) : name_sq;\n-\tint cmd_size = strlen(name_sq) + strlen(label_sq) + strlen(diff_cmd);\n+\tint cmd_size = strlen(name_sq) +\n+\t\tstrlen(label_sq) * 2 + strlen(diff_cmd);\n \tchar *cmd = malloc(cmd_size);\n \n \tfflush(stdout);\n-\tsnprintf(cmd, cmd_size, diff_cmd, label_sq, name_sq);\n+\tsnprintf(cmd, cmd_size, diff_cmd, label_sq, label_sq, name_sq);\n \tf = popen(cmd, \"w\");\n \tif (old_size)\n \t\tfwrite(old_contents, old_size, 1, f);\n\n"}]}