minor git-prune optimization
Don't try to remove the containing directory for every pruned object but try only once after the directory has been scanned instead. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Nicolas Pitre committed
Mar 20, 2007 at 23:32 UTC
3254d218b4f9ef1550d1d83670fad8f455b08578
1 file changed
+4
-4
builtin-prune.c
+4
-4
@@ -14,10 +14,8 @@ static int prune_object(char *path, const char *filename, const unsigned char *s
14
enum object_type type = sha1_object_info(sha1, NULL);
15
printf("%s %s\n", sha1_to_hex(sha1),
16
(type > 0) ? typename(type) : "unknown");
17
- return 0;
18
- }
19
- unlink(mkpath("%s/%s", path, filename));
20
- rmdir(path);
17
+ } else
18
+ unlink(mkpath("%s/%s", path, filename));
19
return 0;
20
}
21
@@ -60,6 +58,8 @@ static int prune_dir(int i, char *path)
58
}
59
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);
60
}
61
+ if (!show_only)
62
+ rmdir(path);
63
closedir(dir);
64
return 0;
65
}