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

[PATCH jk/prune-mtime] prune: close directory earlier during loose-object directory traversal

From
Johannes Sixt <j6t@kdbg.org>
Date
Aug 12, 2015, 17:43 UTC
Message-ID
<55CB85A5.5040802@kdbg.org>
In-Reply-To
<b9cf9e2168c3b2476bb5bb134a1528be@www.dscho.org>

27e1e22d (prune: factor out loose-object directory traversal, 2014-10-16) introduced a new function for_each_loose_file_in_objdir() with a helper for_each_file_in_obj_subdir(). The latter calls callbacks for each file found during a directory traversal and finally also a callback for the directory itself.

git-prune uses the function to clean up the object directory. In particular, in the directory callback it calls rmdir(). On Windows XP, this rmdir call fails, because the directory is still open while the callback is called. Close the directory before calling the callback.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 My Windows 8.1 machine does not require this fix for some unkonwn
 reason. But we still cater for Windows XP users, where this change
 is a real improvement.
 sha1_file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sha1_file.c b/sha1_file.c
index 4d1b26f..5cecc68 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -3473,12 +3473,12 @@ static int for_each_file_in_obj_subdir(int subdir_nr,
 				break;
 		}
 	}
+	closedir(dir);
+
 	strbuf_setlen(path, baselen);
-
 	if (!r && subdir_cb)
 		r = subdir_cb(subdir_nr, path->buf, data);
 
-	closedir(dir);
 	return r;
 }
 
-- 
2.3.2.245.gb5bf9d3

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Next: Jeff King
Message 1 of 7 in “prune: close directory earlier during loose-object directory traversal”
  1. prune: close directory earlier during loose-object directory traversalJohannes Sixt, Aug 12, 2015
  2. Jeff KingAug 12, 2015
  3. Junio C HamanoDec 11, 2015
  4. Jeff KingDec 11, 2015
  5. Johannes SchindelinDec 13, 2015
  6. Junio C HamanoDec 14, 2015
  7. Johannes SchindelinAug 13, 2015

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.