Thread (2 messages) 2 messages, 2 authors, 2016-06-15

Re: [PATCH 2/2] Don't clean any untracked submodule's .git dir by default in git-clean

From: Jason Holden <hidden>
Date: 2016-06-15 22:47:00

Possibly related (same subject, not in this thread)

Junio C Hamano wrote:
quoted hunk ↗ jump to hunk
Junio C Hamano [off-list ref] 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help