Skip to content

Commit fb1c18f

Browse files
newrengitster
authored andcommitted
merge-recursive: fix the refresh logic in update_file_flags
If we need to delete a higher stage entry in the index to place the file at stage 0, then we'll lose that file's stat information. In such situations we may still be able to detect that the file on disk is the version we want (as noted by our comment in the code: /* do not overwrite file if already present */ ), but we do still need to update the mtime since we are creating a new cache_entry for that file. Update the logic used to determine whether we refresh a file's mtime. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 73113c5 commit fb1c18f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

merge-recursive.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,10 +998,13 @@ static int update_file_flags(struct merge_options *opt,
998998
free(buf);
999999
}
10001000
update_index:
1001-
if (!ret && update_cache)
1002-
if (add_cacheinfo(opt, contents, path, 0, update_wd,
1001+
if (!ret && update_cache) {
1002+
int refresh = (!opt->priv->call_depth &&
1003+
contents->mode != S_IFGITLINK);
1004+
if (add_cacheinfo(opt, contents, path, 0, refresh,
10031005
ADD_CACHE_OK_TO_ADD))
10041006
return -1;
1007+
}
10051008
return ret;
10061009
}
10071010

t/t3433-rebase-across-mode-change.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test_expect_success 'rebase changes with the apply backend' '
3333
git rebase side1
3434
'
3535

36-
test_expect_failure 'rebase changes with the merge backend' '
36+
test_expect_success 'rebase changes with the merge backend' '
3737
test_when_finished "git rebase --abort || true" &&
3838
git checkout -b merge-backend side2 &&
3939
git rebase -m side1

0 commit comments

Comments
 (0)