Browse Source

merge-recursive: Delay content merging for renames

Move the handling of content merging for renames from process_renames() to
process_df_entry().

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Elijah Newren 14 years ago committed by Junio C Hamano
parent
commit
882fd11aff
  1. 51
      merge-recursive.c
  2. 2
      t/t6022-merge-rename.sh

51
merge-recursive.c

@ -1073,7 +1073,6 @@ static int process_renames(struct merge_options *o,


if (try_merge) { if (try_merge) {
struct diff_filespec *one, *a, *b; struct diff_filespec *one, *a, *b;
struct merge_file_info mfi;
src_other.path = (char *)ren1_src; src_other.path = (char *)ren1_src;


one = ren1->pair->one; one = ren1->pair->one;
@ -1084,41 +1083,16 @@ static int process_renames(struct merge_options *o,
b = ren1->pair->two; b = ren1->pair->two;
a = &src_other; a = &src_other;
} }
mfi = merge_file(o, one, a, b, update_stages_and_entry(ren1_dst, ren1->dst_entry, one, a, b, 1);
o->branch1, o->branch2); if (string_list_has_string(&o->current_directory_set, ren1_dst)) {

setup_rename_df_conflict_info(RENAME_NORMAL,
if (mfi.clean && ren1->pair,
sha_eq(mfi.sha, ren1->pair->two->sha1) && NULL,
mfi.mode == ren1->pair->two->mode) { branch1,
/* NULL,
* This message is part of ren1->dst_entry,
* t6022 test. If you change NULL);
* it update the test too. remove_file(o, 0, ren1_dst, 0);
*/
output(o, 3, "Skipped %s (merged same as existing)", ren1_dst);

/* There may be higher stage entries left
* in the index (e.g. due to a D/F
* conflict) that need to be resolved.
*/
if (!ren1->dst_entry->stages[2].mode !=
!ren1->dst_entry->stages[3].mode)
ren1->dst_entry->processed = 0;
} else {
if (mfi.merge || !mfi.clean)
output(o, 1, "Renaming %s => %s", ren1_src, ren1_dst);
if (mfi.merge)
output(o, 2, "Auto-merging %s", ren1_dst);
if (!mfi.clean) {
output(o, 1, "CONFLICT (rename/modify): Merge conflict in %s",
ren1_dst);
clean_merge = 0;

if (!o->call_depth)
update_stages(ren1_dst,
one, a, b, 1);
}
update_file(o, mfi.clean, mfi.sha, mfi.mode, ren1_dst);
} }
} }
} }
@ -1358,6 +1332,11 @@ static int process_df_entry(struct merge_options *o,
struct rename_df_conflict_info *conflict_info = entry->rename_df_conflict_info; struct rename_df_conflict_info *conflict_info = entry->rename_df_conflict_info;
char *src; char *src;
switch (conflict_info->rename_type) { switch (conflict_info->rename_type) {
case RENAME_NORMAL:
clean_merge = merge_content(o, path,
o_sha, o_mode, a_sha, a_mode, b_sha, b_mode,
conflict_info->branch1);
break;
case RENAME_DELETE: case RENAME_DELETE:
clean_merge = 0; clean_merge = 0;
conflict_rename_delete(o, conflict_info->pair1, conflict_rename_delete(o, conflict_info->pair1,

2
t/t6022-merge-rename.sh

@ -455,7 +455,7 @@ cat >expected <<\EOF &&
>>>>>>> dir-not-in-way >>>>>>> dir-not-in-way
EOF EOF


test_expect_failure 'Rename+D/F conflict; renamed file cannot merge, dir not in way' ' test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in way' '
git reset --hard && git reset --hard &&
rm -rf dir~* && rm -rf dir~* &&
git checkout -q renamed-file-has-conflicts^0 && git checkout -q renamed-file-has-conflicts^0 &&

Loading…
Cancel
Save