Do not record unstaged deleted file upon recursive merge if file was moved outside of working tree with enabled sparse-checkout.
PATCH 1/1 Do not record unstaged deleted file upon recursive merge if file was moved outside of working tree with enabled sparse-checkout.
It's a very unexpected behaviour when a user sees a deleted file after a merge with enabled sparse-checkout. Moreover, when the user resolves merge conflicts and commits the changes with the command "git commit -am xxx", a repository can be broken because all the moved files will be deleted. Finally, it's really hard to find a user who deleted these files because "git log file" doesn't show any merge commits by default. I'm not sure that my fix is correct but I checked all tests and I didn't find a better way to prevent files deleting.
--- merge-recursive.c | 9 +++++--- t/t6042-merge-rename-corner-cases.sh | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-)
merge-recursive.c +6 -3
@@ -1724,9 +1724,12 @@ static int merge_content(struct merge_options *o,*/ path_renamed_outside_HEAD = !path2 || !strcmp (path, path2);if (!path_renamed_outside_HEAD) { -add_cacheinfo (o, mfi.mode, &mfi.oid, path, -0 , (!o->call_depth),0 ); -return mfi.clean; +struct stat st; +if (lstat (path, &st) ==0 ) { +add_cacheinfo (o, mfi.mode, &mfi.oid, path, +0 , (!o->call_depth),0 ); +return mfi.clean; + } } }else output (o,2 ,_ ("Auto-merging %s" ), path);
t/t6042-merge-rename-corner-cases.sh +41 -0
45 lines not on this page · raw message
Signature · 1 line
2.7.4 (Apple Git-66)