From: Jason Holden Date: Wed, 01 Jul 2009 01:44:01 GMT Subject: Re: [PATCH 2/2] Don't clean any untracked submodule's .git dir by default in git-clean Message-ID: <4A4ABF61.7040009@gmail.com> In-Reply-To: <7vws6t490z.fsf@alter.siamese.dyndns.org> Junio C Hamano wrote: > Junio C Hamano writes: > > diff --git a/dir.c b/dir.c > index bbfcb56..d0cfe74 100644 > --- a/dir.c > +++ b/dir.c > @@ -800,12 +800,20 @@ int is_empty_dir(const char *path) > return ret; > } > > -int remove_dir_recursively(struct strbuf *path, int only_empty) > +int remove_dir_recursively(struct strbuf *path, int flag) > { > - DIR *dir = opendir(path->buf); > + DIR *dir; > struct dirent *e; > int ret = 0, original_len = path->len, len; > + int only_empty = (flag & REMOVE_DIR_EMPTY_ONLY); > + unsigned char submodule_head[20]; > > + if ((flag & REMOVE_DIR_KEEP_NESTED_GIT) && > + !resolve_gitlink_ref(path->buf, "HEAD", submodule_head)) > + /* Do not descend and nuke a nested git work tree. */ Add a printout here to indicate that we didn't end up removing the directory. Otherwise when you run git clean -f -d you just end up with something like: "Removing attachement_fu/" even when we didn't actually end up removing it. Paolo noticed this same issue in my original patch. > + return 0; > + > + dir = opendir(path->buf); > if (!dir) I was able to test this patch and everything seems to behave as expected. If this becomes the final fix, don't forget to update Documentation/git-clean.txt I'm leaving for vacation tomorrow, so you won't hear any more from me until ~July 8th. Thanks for the quick responses. -- Regards, Jason Holden Get my PGP Key at http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x6B7FBC8D