mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
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>
This commit is contained in:
parent
13e86efbea
commit
e9c8409900
|
@ -97,7 +97,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
|
||||||
* Show the diff for the 'ce' if we found the one
|
* Show the diff for the 'ce' if we found the one
|
||||||
* from the desired stage.
|
* from the desired stage.
|
||||||
*/
|
*/
|
||||||
diff_unmerge(&revs->diffopt, ce->name);
|
diff_unmerge(&revs->diffopt, ce->name, 0, null_sha1);
|
||||||
if (ce_stage(ce) != diff_unmerged_stage)
|
if (ce_stage(ce) != diff_unmerged_stage)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -297,9 +297,12 @@ static int diff_cache(struct rev_info *revs,
|
||||||
!show_modified(revs, ce, ac[1], 0,
|
!show_modified(revs, ce, ac[1], 0,
|
||||||
cached, match_missing))
|
cached, match_missing))
|
||||||
break;
|
break;
|
||||||
/* fallthru */
|
diff_unmerge(&revs->diffopt, ce->name,
|
||||||
|
ntohl(ce->ce_mode), ce->sha1);
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
diff_unmerge(&revs->diffopt, ce->name);
|
diff_unmerge(&revs->diffopt, ce->name,
|
||||||
|
0, null_sha1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
6
diff.c
6
diff.c
|
@ -2875,10 +2875,12 @@ void diff_change(struct diff_options *options,
|
||||||
}
|
}
|
||||||
|
|
||||||
void diff_unmerge(struct diff_options *options,
|
void diff_unmerge(struct diff_options *options,
|
||||||
const char *path)
|
const char *path,
|
||||||
|
unsigned mode, const unsigned char *sha1)
|
||||||
{
|
{
|
||||||
struct diff_filespec *one, *two;
|
struct diff_filespec *one, *two;
|
||||||
one = alloc_filespec(path);
|
one = alloc_filespec(path);
|
||||||
two = alloc_filespec(path);
|
two = alloc_filespec(path);
|
||||||
diff_queue(&diff_queued_diff, one, two);
|
fill_filespec(one, sha1, mode);
|
||||||
|
diff_queue(&diff_queued_diff, one, two)->is_unmerged = 1;
|
||||||
}
|
}
|
||||||
|
|
4
diff.h
4
diff.h
|
@ -144,7 +144,9 @@ extern void diff_change(struct diff_options *,
|
||||||
const char *base, const char *path);
|
const char *base, const char *path);
|
||||||
|
|
||||||
extern void diff_unmerge(struct diff_options *,
|
extern void diff_unmerge(struct diff_options *,
|
||||||
const char *path);
|
const char *path,
|
||||||
|
unsigned mode,
|
||||||
|
const unsigned char *sha1);
|
||||||
|
|
||||||
extern int diff_scoreopt_parse(const char *opt);
|
extern int diff_scoreopt_parse(const char *opt);
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,9 @@ struct diff_filepair {
|
||||||
unsigned source_stays : 1; /* all of R/C are copies */
|
unsigned source_stays : 1; /* all of R/C are copies */
|
||||||
unsigned broken_pair : 1;
|
unsigned broken_pair : 1;
|
||||||
unsigned renamed_pair : 1;
|
unsigned renamed_pair : 1;
|
||||||
|
unsigned is_unmerged : 1;
|
||||||
};
|
};
|
||||||
#define DIFF_PAIR_UNMERGED(p) \
|
#define DIFF_PAIR_UNMERGED(p) ((p)->is_unmerged)
|
||||||
(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
|
|
||||||
|
|
||||||
#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
|
#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue