]> git.ipfire.org Git - thirdparty/git.git/commitdiff
prune: close directory earlier during loose-object directory traversal
authorJohannes Sixt <j6t@kdbg.org>
Wed, 12 Aug 2015 17:43:01 +0000 (19:43 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2015 19:06:00 +0000 (12:06 -0700)
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>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c

index bf1bdbcdf5e4f20c58c338decbaa7506d02c3217..7ea7a93359312c376d6f091d4965eacedab39606 100644 (file)
@@ -3356,12 +3356,12 @@ static int for_each_file_in_obj_subdir(int subdir_nr,
                                break;
                }
        }
-       strbuf_setlen(path, baselen);
+       closedir(dir);
 
+       strbuf_setlen(path, baselen);
        if (!r && subdir_cb)
                r = subdir_cb(subdir_nr, path->buf, data);
 
-       closedir(dir);
        return r;
 }