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