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

Fredrik Kuivinen freku045 at student.liu.se
Sun Nov 20 22:51:02 EST 2005


On Sat, Nov 19, 2005 at 08:14:48PM -0800, Junio C Hamano wrote:
> 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 at 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



More information about the Linuxppc64-dev mailing list