git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] merge-recursive::removeFile: remove empty directories

From
Junio C Hamano <junkio@cox.net>
Date
Nov 20, 2005, 04:14 UTC
Message-ID
<7vy83k2bwn.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0511190957320.13959@g5.osdl.org>

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>
---
 And this is the one for 'git pull -s recursive' which is the
 default these days.
 git-merge-recursive.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

applies-to: ea62f7003bb2769fa23d5ca371d84cee9d2ec46f 80e21a9ed809d98788ff6fb705d911bee37d460b

diff --git a/git-merge-recursive.py b/git-merge-recursive.py
index d7d36aa..37258ad 100755
--- a/git-merge-recursive.py
+++ b/git-merge-recursive.py
@@ -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):
---
0.99.9.GIT
Previous: Johannes SchindelinNext: Fredrik Kuivinen
Message 7 of 8 in “Re: please pull powerpc-merge.git”
  1. Linus TorvaldsNov 19, 2005
  2. merge-one-file: remove empty directoriesJunio C Hamano, Nov 20, 2005
  3. Linus TorvaldsNov 20, 2005
  4. H. Peter AnvinNov 20, 2005
  5. Alex RiesenNov 21, 2005
  6. Johannes SchindelinNov 21, 2005
  7. merge-recursive::removeFile: remove empty directoriesJunio C Hamano, Nov 20, 2005
  8. Fredrik KuivinenNov 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.