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

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

From
Fredrik Kuivinen <freku045@student.liu.se>
Date
Nov 20, 2005, 11:51 UTC
Message-ID
<20051120115102.GC4946@c165.ib.student.liu.se>
In-Reply-To
<7vy83k2bwn.fsf@assigned-by-dhcp.cox.net>
On Sat, Nov 19, 2005 at 08:14:48PM -0800, Junio C Hamano wrote:
Show 28 quoted lines
> 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
>  

Looks good, but I would prefer to have 'except OSError:' instead of the except without any exception class. A plain 'except:' will catch every kind of exception which includes things such as NameError and AttributeError and we really don't want to silently ignore those two.

A plain 'except:' exists in one other place (actually two, but one of them is ok) in git-merge-recursive.py. I will send a patch to remove that one.

- Fredrik
Previous: Junio C Hamano
Message 8 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.