Code

Remove empty directories in recursive merge
authorAlex Riesen <raa.lkml@gmail.com>
Thu, 25 Sep 2008 20:12:45 +0000 (22:12 +0200)
committerShawn O. Pearce <spearce@spearce.org>
Fri, 26 Sep 2008 15:05:20 +0000 (08:05 -0700)
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>
builtin-merge-recursive.c
t/t3030-merge-recursive.sh

index 43e55bf90154c51b94527b2ab7eb7c60fe36e9ec..f628a62751d25d394c722bbc03f9367d3973fdd0 100644 (file)
@@ -444,10 +444,8 @@ static int remove_file(int clean, const char *path, int no_wd)
                        return -1;
        }
        if (update_working_directory) {
-               unlink(path);
-               if (errno != ENOENT || errno != EISDIR)
+               if (remove_path(path) && errno != ENOENT)
                        return -1;
-               remove_path(path);
        }
        return 0;
 }
index de0cdb1cf4e4dbb6395619bdd2f56c0b027fdea7..0de613dc53d85c01f6d122834e094503a2736507 100755 (executable)
@@ -535,4 +535,15 @@ test_expect_success 'reset and bind merge' '
 
 '
 
+test_expect_success 'merge removes empty directories' '
+
+       git reset --hard master &&
+       git checkout -b rm &&
+       git rm d/e &&
+       git commit -mremoved-d/e &&
+       git checkout master &&
+       git merge -s recursive rm &&
+       test_must_fail test -d d
+'
+
 test_done