{"thread":{"id":"607","subject":"[PATCH 1/3] Update mode-change strings in diff output.","startedAt":"2005-05-14T01:40:14Z","lastAt":"2005-05-14T01:40:14Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"3274","messageId":"7vhdh660w1.fsf@assigned-by-dhcp.cox.net","threadId":"607","inReplyTo":null,"subject":"[PATCH 1/3] Update mode-change strings in diff output.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-14T01:40:14Z","receivedAt":"2005-05-14T01:40:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This updates the mode change strings to be a bit more machine\nfriendly.  Although this might go against the spirit of\nreadability for human consumption, these mode bits strings are\nshown only when unusual things (mode change, file creation and\ndeletion) happens, output normalized for machine consumption\nwould be permissible.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\ndiff.c |   22 ++++++++++++----------\n1 files changed, 12 insertions(+), 10 deletions(-)\n\n--- a/diff.c\n+++ b/diff.c\n@@ -83,6 +83,7 @@\n \t\t\t struct diff_tempfile *temp)\n {\n \tint i, next_at;\n+\tconst char *git_prefix = \"# mode: \";\n \tconst char *diff_cmd = \"diff -L'%s%s' -L'%s%s'\";\n \tconst char *diff_arg  = \"'%s' '%s'||:\"; /* \"||:\" is to return 0 */\n \tconst char *input_name_sq[2];\n@@ -123,17 +124,18 @@\n \t\t\t    diff_arg, input_name_sq[0], input_name_sq[1]);\n \n \tif (!path1[0][0])\n-\t\tprintf(\"Created: %s (mode:%s)\\n\", name, temp[1].mode);\n+\t\tprintf(\"%s. %s %s\\n\", git_prefix, temp[1].mode, name);\n \telse if (!path1[1][0])\n-\t\tprintf(\"Deleted: %s\\n\", name);\n-\telse if (strcmp(temp[0].mode, temp[1].mode)) {\n-\t\tprintf(\"Mode changed: %s (%s->%s)\\n\", name,\n-\t\t       temp[0].mode, temp[1].mode);\n-\t\t/* Be careful.  We do not want to diff between\n-\t\t * symlink and a file.\n-\t\t */\n-\t\tif (strncmp(temp[0].mode, \"120\", 3) !=\n-\t\t    strncmp(temp[1].mode, \"120\", 3))\n+\t\tprintf(\"%s%s . %s\\n\", git_prefix, temp[0].mode, name);\n+\telse {\n+\t\tif (strcmp(temp[0].mode, temp[1].mode))\n+\t\t\tprintf(\"%s%s %s %s\\n\", git_prefix,\n+\t\t\t       temp[0].mode, temp[1].mode, name);\n+\n+\t\tif (strncmp(temp[0].mode, temp[1].mode, 3))\n+\t\t\t/* we do not run diff between different kind\n+\t\t\t * of objects.\n+\t\t\t */\n \t\t\texit(0);\n \t}\n \tfflush(NULL);\n\n"}]}