merge-recursive: Split update_stages_and_entry; only update stages at end
Instead of having the process_renames logic update the stages in the index for the rename destination, have the index updated after process_entry or process_df_entry. This will also allow us to have process_entry determine whether a file was tracked and existed in the working copy before the merge started. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
ed0148a520
commit
b8ddf16424
@ -90,6 +90,7 @@ struct stage_data {
|
|||||||
} stages[4];
|
} stages[4];
|
||||||
struct rename_df_conflict_info *rename_df_conflict_info;
|
struct rename_df_conflict_info *rename_df_conflict_info;
|
||||||
unsigned processed:1;
|
unsigned processed:1;
|
||||||
|
unsigned involved_in_rename:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void setup_rename_df_conflict_info(enum rename_type rename_type,
|
static inline void setup_rename_df_conflict_info(enum rename_type rename_type,
|
||||||
@ -522,15 +523,11 @@ static int update_stages(const char *path, const struct diff_filespec *o,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int update_stages_and_entry(const char *path,
|
static void update_entry(struct stage_data *entry,
|
||||||
struct stage_data *entry,
|
struct diff_filespec *o,
|
||||||
struct diff_filespec *o,
|
struct diff_filespec *a,
|
||||||
struct diff_filespec *a,
|
struct diff_filespec *b)
|
||||||
struct diff_filespec *b,
|
|
||||||
int clear)
|
|
||||||
{
|
{
|
||||||
int options;
|
|
||||||
|
|
||||||
entry->processed = 0;
|
entry->processed = 0;
|
||||||
entry->stages[1].mode = o->mode;
|
entry->stages[1].mode = o->mode;
|
||||||
entry->stages[2].mode = a->mode;
|
entry->stages[2].mode = a->mode;
|
||||||
@ -538,7 +535,6 @@ static int update_stages_and_entry(const char *path,
|
|||||||
hashcpy(entry->stages[1].sha, o->sha1);
|
hashcpy(entry->stages[1].sha, o->sha1);
|
||||||
hashcpy(entry->stages[2].sha, a->sha1);
|
hashcpy(entry->stages[2].sha, a->sha1);
|
||||||
hashcpy(entry->stages[3].sha, b->sha1);
|
hashcpy(entry->stages[3].sha, b->sha1);
|
||||||
return update_stages(path, o, a, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int remove_file(struct merge_options *o, int clean,
|
static int remove_file(struct merge_options *o, int clean,
|
||||||
@ -1097,12 +1093,11 @@ static int process_renames(struct merge_options *o,
|
|||||||
ren2->dst_entry);
|
ren2->dst_entry);
|
||||||
} else {
|
} else {
|
||||||
remove_file(o, 1, ren1_src, 1);
|
remove_file(o, 1, ren1_src, 1);
|
||||||
update_stages_and_entry(ren1_dst,
|
update_entry(ren1->dst_entry,
|
||||||
ren1->dst_entry,
|
ren1->pair->one,
|
||||||
ren1->pair->one,
|
ren1->pair->two,
|
||||||
ren1->pair->two,
|
ren2->pair->two);
|
||||||
ren2->pair->two,
|
ren1->dst_entry->involved_in_rename = 1;
|
||||||
1 /* clear */);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Renamed in 1, maybe changed in 2 */
|
/* Renamed in 1, maybe changed in 2 */
|
||||||
@ -1207,7 +1202,8 @@ static int process_renames(struct merge_options *o,
|
|||||||
b = ren1->pair->two;
|
b = ren1->pair->two;
|
||||||
a = &src_other;
|
a = &src_other;
|
||||||
}
|
}
|
||||||
update_stages_and_entry(ren1_dst, ren1->dst_entry, one, a, b, 1);
|
update_entry(ren1->dst_entry, one, a, b);
|
||||||
|
ren1->dst_entry->involved_in_rename = 1;
|
||||||
if (dir_in_way(ren1_dst, 0 /*check_wc*/)) {
|
if (dir_in_way(ren1_dst, 0 /*check_wc*/)) {
|
||||||
setup_rename_df_conflict_info(RENAME_NORMAL,
|
setup_rename_df_conflict_info(RENAME_NORMAL,
|
||||||
ren1->pair,
|
ren1->pair,
|
||||||
@ -1304,6 +1300,7 @@ static void handle_delete_modify(struct merge_options *o,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int merge_content(struct merge_options *o,
|
static int merge_content(struct merge_options *o,
|
||||||
|
unsigned involved_in_rename,
|
||||||
const char *path,
|
const char *path,
|
||||||
unsigned char *o_sha, int o_mode,
|
unsigned char *o_sha, int o_mode,
|
||||||
unsigned char *a_sha, int a_mode,
|
unsigned char *a_sha, int a_mode,
|
||||||
@ -1344,6 +1341,8 @@ static int merge_content(struct merge_options *o,
|
|||||||
reason = "submodule";
|
reason = "submodule";
|
||||||
output(o, 1, "CONFLICT (%s): Merge conflict in %s",
|
output(o, 1, "CONFLICT (%s): Merge conflict in %s",
|
||||||
reason, path);
|
reason, path);
|
||||||
|
if (involved_in_rename)
|
||||||
|
update_stages(path, &one, &a, &b);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (df_conflict_remains) {
|
if (df_conflict_remains) {
|
||||||
@ -1428,7 +1427,7 @@ static int process_entry(struct merge_options *o,
|
|||||||
} else if (a_sha && b_sha) {
|
} else if (a_sha && b_sha) {
|
||||||
/* Case C: Added in both (check for same permissions) and */
|
/* Case C: Added in both (check for same permissions) and */
|
||||||
/* case D: Modified in both, but differently. */
|
/* case D: Modified in both, but differently. */
|
||||||
clean_merge = merge_content(o, path,
|
clean_merge = merge_content(o, entry->involved_in_rename, path,
|
||||||
o_sha, o_mode, a_sha, a_mode, b_sha, b_mode,
|
o_sha, o_mode, a_sha, a_mode, b_sha, b_mode,
|
||||||
NULL);
|
NULL);
|
||||||
} else if (!o_sha && !a_sha && !b_sha) {
|
} else if (!o_sha && !a_sha && !b_sha) {
|
||||||
@ -1472,7 +1471,7 @@ static int process_df_entry(struct merge_options *o,
|
|||||||
char *src;
|
char *src;
|
||||||
switch (conflict_info->rename_type) {
|
switch (conflict_info->rename_type) {
|
||||||
case RENAME_NORMAL:
|
case RENAME_NORMAL:
|
||||||
clean_merge = merge_content(o, path,
|
clean_merge = merge_content(o, entry->involved_in_rename, path,
|
||||||
o_sha, o_mode, a_sha, a_mode, b_sha, b_mode,
|
o_sha, o_mode, a_sha, a_mode, b_sha, b_mode,
|
||||||
conflict_info->branch1);
|
conflict_info->branch1);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user