diff-index --cached --raw: show tree entry on the LHS for unmerged entries.
This updates the way diffcore represents an unmerged pair somewhat. It used to be that entries with mode=0 on both sides were used to represent an unmerged pair, but now it has an explicit flag. This is to allow diff-index --cached to report the entry from the tree when the path is unmerged in the index. This is used in updating "git reset <tree> -- <path>" to restore absense of the path in the index from the tree. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Jan 5, 2007 at 01:25 UTC
e9c8409900fc84cd7721117c98dfe01acd535aa2
4 files changed
+15
-8
diff-lib.c
+6
-3
@@ -97,7 +97,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
97
* Show the diff for the 'ce' if we found the one
98
* from the desired stage.
99
*/
100
- diff_unmerge(&revs->diffopt, ce->name);
100
+ diff_unmerge(&revs->diffopt, ce->name, 0, null_sha1);
101
if (ce_stage(ce) != diff_unmerged_stage)
102
continue;
103
}
@@ -297,9 +297,12 @@ static int diff_cache(struct rev_info *revs,
297
!show_modified(revs, ce, ac[1], 0,
298
cached, match_missing))
299
break;
300
- /* fallthru */
300
+ diff_unmerge(&revs->diffopt, ce->name,
301
+ ntohl(ce->ce_mode), ce->sha1);
302
+ break;
303
case 3:
302
- diff_unmerge(&revs->diffopt, ce->name);
304
+ diff_unmerge(&revs->diffopt, ce->name,
305
+ 0, null_sha1);
306
break;
307
308
default:
diff.c
+4
-2
@@ -2875,10 +2875,12 @@ void diff_change(struct diff_options *options,
2875
}
2876
2877
void diff_unmerge(struct diff_options *options,
2878
- const char *path)
2878
+ const char *path,
2879
+ unsigned mode, const unsigned char *sha1)
2880
{
2881
struct diff_filespec *one, *two;
2882
one = alloc_filespec(path);
2883
two = alloc_filespec(path);
2883
- diff_queue(&diff_queued_diff, one, two);
2884
+ fill_filespec(one, sha1, mode);
2885
+ diff_queue(&diff_queued_diff, one, two)->is_unmerged = 1;
2886
}
diff.h
+3
-1
@@ -144,7 +144,9 @@ extern void diff_change(struct diff_options *,
144
const char *base, const char *path);
145
146
extern void diff_unmerge(struct diff_options *,
147
- const char *path);
147
+ const char *path,
148
+ unsigned mode,
149
+ const unsigned char *sha1);
150
151
extern int diff_scoreopt_parse(const char *opt);
152
diffcore.h
+2
-2
@@ -54,9 +54,9 @@ struct diff_filepair {
54
unsigned source_stays : 1; /* all of R/C are copies */
55
unsigned broken_pair : 1;
56
unsigned renamed_pair : 1;
57
+ unsigned is_unmerged : 1;
58
};
58
-#define DIFF_PAIR_UNMERGED(p) \
59
- (!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
59
+#define DIFF_PAIR_UNMERGED(p) ((p)->is_unmerged)
60
61
#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
62