{"thread":{"id":"3329","subject":"[PATCH] combine-diff: diff-files fix.","startedAt":"2006-02-14T07:53:07Z","lastAt":"2006-02-14T07:53:07Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"16103","messageId":"7virritlzw.fsf@assigned-by-dhcp.cox.net","threadId":"3329","inReplyTo":null,"subject":"[PATCH] combine-diff: diff-files fix.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-14T07:53:07Z","receivedAt":"2006-02-14T07:53:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When showing a conflicted merge from index stages and working\ntree file, we did not fetch the mode from the working tree,\nand mistook that as a deleted file.  Also if the manual\nresolution (or automated resolution by git rerere) ended up\ntaking either parent's version, we did not show _anything_ for\nthat path.  Either was quite bad and confusing.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n * This will be part of 1.2.1 maintenance series.\n\n combine-diff.c |    9 +++++----\n 1 files changed, 5 insertions(+), 4 deletions(-)\n\n713a11fceb662f275b5e1294acc6f38674834941\ndiff --git a/combine-diff.c b/combine-diff.c\nindex a38f01b..d812600 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -630,9 +630,10 @@ static int show_patch_diff(struct combin\n \tint i, show_hunks, shown_header = 0;\n \tchar ourtmp_buf[TMPPATHLEN];\n \tchar *ourtmp = ourtmp_buf;\n+\tint working_tree_file = !memcmp(elem->sha1, null_sha1, 20);\n \n \t/* Read the result of merge first */\n-\tif (memcmp(elem->sha1, null_sha1, 20)) {\n+\tif (!working_tree_file) {\n \t\tresult = grab_blob(elem->sha1, &size);\n \t\twrite_to_temp_file(ourtmp, result, size);\n \t}\n@@ -646,6 +647,7 @@ static int show_patch_diff(struct combin\n \t\t\tint len = st.st_size;\n \t\t\tint cnt = 0;\n \n+\t\t\telem->mode = DIFF_FILE_CANON_MODE(st.st_mode);\n \t\t\tsize = len;\n \t\t\tresult = xmalloc(len + 1);\n \t\t\twhile (cnt < len) {\n@@ -661,6 +663,7 @@ static int show_patch_diff(struct combin\n \t\telse {\n \t\t\t/* deleted file */\n \t\t\tsize = 0;\n+\t\t\telem->mode = 0;\n \t\t\tresult = xmalloc(1);\n \t\t\tresult[0] = 0;\n \t\t\tourtmp = \"/dev/null\";\n@@ -716,7 +719,7 @@ static int show_patch_diff(struct combin\n \n \tshow_hunks = make_hunks(sline, cnt, num_parent, dense);\n \n-\tif (show_hunks || mode_differs) {\n+\tif (show_hunks || mode_differs || working_tree_file) {\n \t\tconst char *abb;\n \n \t\tif (header) {\n@@ -731,8 +734,6 @@ static int show_patch_diff(struct combin\n \t\tputchar('\\n');\n \t\tprintf(\"index \");\n \t\tfor (i = 0; i < num_parent; i++) {\n-\t\t\tif (elem->parent[i].mode != elem->mode)\n-\t\t\t\tmode_differs = 1;\n \t\t\tabb = find_unique_abbrev(elem->parent[i].sha1,\n \t\t\t\t\t\t DEFAULT_ABBREV);\n \t\t\tprintf(\"%s%s\", i ? \",\" : \"\", abb);\n-- \n1.2.0.g45dc\n"}]}