summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-02-19 17:04:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-02-19 18:13:31 (GMT)
commitfb1c18fc466c6a9c6ea1b072c9db93c0046f4cbd (patch)
treecdfbb1797f22a09505afd92d0e17e1cc22c3a837
parent73113c592222eac40dfdf76d9b2bbc2137d73783 (diff)
downloadgit-fb1c18fc466c6a9c6ea1b072c9db93c0046f4cbd.zip
git-fb1c18fc466c6a9c6ea1b072c9db93c0046f4cbd.tar.gz
git-fb1c18fc466c6a9c6ea1b072c9db93c0046f4cbd.tar.bz2
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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--merge-recursive.c7
-rwxr-xr-xt/t3433-rebase-across-mode-change.sh2
2 files changed, 6 insertions, 3 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 10dca56..9657adc 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -998,10 +998,13 @@ static int update_file_flags(struct merge_options *opt,
free(buf);
}
update_index:
- if (!ret && update_cache)
- if (add_cacheinfo(opt, contents, path, 0, update_wd,
+ if (!ret && update_cache) {
+ int refresh = (!opt->priv->call_depth &&
+ contents->mode != S_IFGITLINK);
+ if (add_cacheinfo(opt, contents, path, 0, refresh,
ADD_CACHE_OK_TO_ADD))
return -1;
+ }
return ret;
}
diff --git a/t/t3433-rebase-across-mode-change.sh b/t/t3433-rebase-across-mode-change.sh
index f11fc35..05df964 100755
--- a/t/t3433-rebase-across-mode-change.sh
+++ b/t/t3433-rebase-across-mode-change.sh
@@ -33,7 +33,7 @@ test_expect_success 'rebase changes with the apply backend' '
git rebase side1
'
-test_expect_failure 'rebase changes with the merge backend' '
+test_expect_success 'rebase changes with the merge backend' '
test_when_finished "git rebase --abort || true" &&
git checkout -b merge-backend side2 &&
git rebase -m side1