{"thread":{"id":"6230","subject":"[PATCH 1/2] diff-index --cached --raw: show tree entry on the LHS for unmerged entries.","startedAt":"2007-01-05T09:42:22Z","lastAt":"2007-01-05T09:42:22Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"30868","messageId":"7vr6u9izcx.fsf@assigned-by-dhcp.cox.net","threadId":"6230","inReplyTo":null,"subject":"[PATCH 1/2] diff-index --cached --raw: show tree entry on the LHS for unmerged entries.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-05T09:42:22Z","receivedAt":"2007-01-05T09:42:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This updates the way diffcore represents an unmerged pair\nsomewhat.  It used to be that entries with mode=0 on both sides\nwere used to represent an unmerged pair, but now it has an\nexplicit flag.  This is to allow diff-index --cached to report\nthe entry from the tree when the path is unmerged in the index.\n\nThis is used in updating \"git reset <tree> -- <path>\" to restore\nabsense of the path in the index from the tree.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * This is rather subtle but touches fairly core part of the\n   plumbing, which I tried to stay away from doing these days.\n   I do not think it would break anything, but please holler if\n   it breaks your scripts...\n\n diff-lib.c |    9 ++++++---\n diff.c     |    6 ++++--\n diff.h     |    4 +++-\n diffcore.h |    4 ++--\n 4 files changed, 15 insertions(+), 8 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex fc69fb9..2c9be60 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -97,7 +97,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)\n \t\t\t * Show the diff for the 'ce' if we found the one\n \t\t\t * from the desired stage.\n \t\t\t */\n-\t\t\tdiff_unmerge(&revs->diffopt, ce->name);\n+\t\t\tdiff_unmerge(&revs->diffopt, ce->name, 0, null_sha1);\n \t\t\tif (ce_stage(ce) != diff_unmerged_stage)\n \t\t\t\tcontinue;\n \t\t}\n@@ -297,9 +297,12 @@ static int diff_cache(struct rev_info *revs,\n \t\t\t    !show_modified(revs, ce, ac[1], 0,\n \t\t\t\t\t   cached, match_missing))\n \t\t\t\tbreak;\n-\t\t\t/* fallthru */\n+\t\t\tdiff_unmerge(&revs->diffopt, ce->name,\n+\t\t\t\t     ntohl(ce->ce_mode), ce->sha1);\n+\t\t\tbreak;\n \t\tcase 3:\n-\t\t\tdiff_unmerge(&revs->diffopt, ce->name);\n+\t\t\tdiff_unmerge(&revs->diffopt, ce->name,\n+\t\t\t\t     0, null_sha1);\n \t\t\tbreak;\n \n \t\tdefault:\ndiff --git a/diff.c b/diff.c\nindex f14288b..2c2e9dc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2875,10 +2875,12 @@ void diff_change(struct diff_options *options,\n }\n \n void diff_unmerge(struct diff_options *options,\n-\t\t  const char *path)\n+\t\t  const char *path,\n+\t\t  unsigned mode, const unsigned char *sha1)\n {\n \tstruct diff_filespec *one, *two;\n \tone = alloc_filespec(path);\n \ttwo = alloc_filespec(path);\n-\tdiff_queue(&diff_queued_diff, one, two);\n+\tfill_filespec(one, sha1, mode);\n+\tdiff_queue(&diff_queued_diff, one, two)->is_unmerged = 1;\n }\ndiff --git a/diff.h b/diff.h\nindex eff4455..7a347cf 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -144,7 +144,9 @@ extern void diff_change(struct diff_options *,\n \t\t\tconst char *base, const char *path);\n \n extern void diff_unmerge(struct diff_options *,\n-\t\t\t const char *path);\n+\t\t\t const char *path,\n+\t\t\t unsigned mode,\n+\t\t\t const unsigned char *sha1);\n \n extern int diff_scoreopt_parse(const char *opt);\n \ndiff --git a/diffcore.h b/diffcore.h\nindex 2249bc2..1ea8067 100644\n--- a/diffcore.h\n+++ b/diffcore.h\n@@ -54,9 +54,9 @@ struct diff_filepair {\n \tunsigned source_stays : 1; /* all of R/C are copies */\n \tunsigned broken_pair : 1;\n \tunsigned renamed_pair : 1;\n+\tunsigned is_unmerged : 1;\n };\n-#define DIFF_PAIR_UNMERGED(p) \\\n-\t(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))\n+#define DIFF_PAIR_UNMERGED(p) ((p)->is_unmerged)\n \n #define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)\n \n-- \n1.5.0.rc0.ge0f6\n"}]}