Code

merge-recursive::removeFile: remove empty directories
authorJunio C Hamano <junkio@cox.net>
Sun, 20 Nov 2005 03:50:44 +0000 (19:50 -0800)
committerJunio C Hamano <junkio@cox.net>
Sun, 20 Nov 2005 03:57:54 +0000 (19:57 -0800)
When the last file in a directory is removed as the result of a
merge, try to rmdir the now-empty directory.

Signed-off-by: Junio C Hamano <junkio@cox.net>
git-merge-recursive.py

index d7d36aa7d11299d3a1e91dce1bc9572ac56a7c08..37258ad77481fb0edaf2b084b7be173d8da8c586 100755 (executable)
@@ -293,6 +293,10 @@ def removeFile(clean, path):
         except OSError, e:
             if e.errno != errno.ENOENT and e.errno != errno.EISDIR:
                 raise
+        try:
+            os.removedirs(os.path.dirname(path))
+        except:
+            pass
 
 def uniquePath(path, branch):
     def fileExists(path):