diff options
-rw-r--r-- | merge-recursive.c | 17 | ||||
-rwxr-xr-x | t/t6022-merge-rename.sh | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/merge-recursive.c b/merge-recursive.c index 231e5cbd7f..847bc8494f 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -354,10 +354,11 @@ static void make_room_for_directories_of_df_conflicts(struct merge_options *o, * make room for the corresponding directory. Such paths will * later be processed in process_df_entry() at the end. If * the corresponding directory ends up being removed by the - * merge, then the file will be reinstated at that time; - * otherwise, if the file is not supposed to be removed by the - * merge, the contents of the file will be placed in another - * unique filename. + * merge, then the file will be reinstated at that time + * (albeit with a different timestamp!); otherwise, if the + * file is not supposed to be removed by the merge, the + * contents of the file will be placed in another unique + * filename. * * NOTE: This function relies on the fact that entries for a * D/F conflict will appear adjacent in the index, with the @@ -1272,9 +1273,13 @@ static int merge_content(struct merge_options *o, } if (mfi.clean && !df_conflict_remains && - sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode) + sha_eq(mfi.sha, a_sha) && mfi.mode == a.mode && + lstat(path, &st) == 0) { output(o, 3, "Skipped %s (merged same as existing)", path); - else + add_cacheinfo(mfi.mode, mfi.sha, path, + 0 /*stage*/, 1 /*refresh*/, 0 /*options*/); + return mfi.clean; + } else output(o, 2, "Auto-merging %s", path); if (!mfi.clean) { diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh index 6b3e8b8d4b..7d955c1e12 100755 --- a/t/t6022-merge-rename.sh +++ b/t/t6022-merge-rename.sh @@ -728,7 +728,7 @@ test_expect_success 'setup avoid unnecessary update, normal rename' ' git commit -m "Random, unrelated changes" ' -test_expect_failure 'avoid unnecessary update, normal rename' ' +test_expect_success 'avoid unnecessary update, normal rename' ' git checkout -q avoid-unnecessary-update-1^0 && test-chmtime =1000000000 rename && test-chmtime -v +0 rename >expect && |