@matheusbsbs / matheus-bagliano / commits / 41f13af558
Fork 0

Remove empty directories in recursive merge

The code was actually supposed to do that, but was accidentally broken. Noticed by Anders Melchiorsen. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Alex Riesen committed Sep 25, 2008 at 22:12 UTC 41f13af558db1018250ade4d99a51f0b76f65bc8
2 files changed +12 -3
builtin-merge-recursive.c
+1 -3
@@ -444,10 +444,8 @@ static int remove_file(int clean, const char *path, int no_wd)
444 return -1;
445 }
446 if (update_working_directory) {
447 - unlink(path);
448 - if (errno != ENOENT || errno != EISDIR)
447 + if (remove_path(path) && errno != ENOENT)
448 return -1;
450 - remove_path(path);
449 }
450 return 0;
451 }
t/t3030-merge-recursive.sh
+11
@@ -535,4 +535,15 @@ test_expect_success 'reset and bind merge' '
535
536 '
537
538 +test_expect_success 'merge removes empty directories' '
539 +
540 + git reset --hard master &&
541 + git checkout -b rm &&
542 + git rm d/e &&
543 + git commit -mremoved-d/e &&
544 + git checkout master &&
545 + git merge -s recursive rm &&
546 + test_must_fail test -d d
547 +'
548 +
549 test_done