Create object subdirectories on demand (phase II)
This removes the unoptimization. The previous round does not mind missing fan-out directories, but still makes sure they exist, lest older versions choke on a repository created/packed by it. This round does not play that nicely anymore -- empty fan-out directories are not created by init-db, and will stay removed by prune-packed. The prune command also removes empty fan-out directories. Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Oct 9, 2005 at 02:30 UTC
9106c097ad87577019544f45fda11c4d73986597
4 files changed
+6
-10
git-prune.sh
+1
@@ -22,6 +22,7 @@ sed -ne '/unreachable /{
22
}' | {
23
cd "$GIT_OBJECT_DIRECTORY" || exit
24
xargs $echo rm -f
25
+ rmdir 2>/dev/null [0-9a-f][0-9a-f]
26
}
27
28
git-prune-packed $dryrun
init-db.c
-4
@@ -281,10 +281,6 @@ int main(int argc, char **argv)
281
memcpy(path, sha1_dir, len);
282
283
safe_create_dir(sha1_dir);
284
- for (i = 0; i < 256; i++) {
285
- sprintf(path+len, "/%02x", i);
286
- safe_create_dir(path);
287
- }
284
strcpy(path+len, "/pack");
285
safe_create_dir(path);
286
strcpy(path+len, "/info");
prune-packed.c
+1
-2
@@ -27,8 +27,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len)
27
error("unable to unlink %s", pathname);
28
}
29
pathname[len] = 0;
30
- if (!rmdir(pathname))
31
- mkdir(pathname, 0777);
30
+ rmdir(pathname);
31
}
32
33
static void prune_packed_objects(void)
t/t0000-basic.sh
+4
-4
@@ -28,12 +28,12 @@ test_expect_success \
28
'.git/objects should be empty after git-init-db in an empty repo.' \
29
'cmp -s /dev/null should-be-empty'
30
31
-# also it should have 258 subdirectories; 256 fan-out anymore, pack, and info.
32
-# 259 is counting "objects" itself
31
+# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
32
+# 3 is counting "objects" itself
33
find .git/objects -type d -print >full-of-directories
34
test_expect_success \
35
- '.git/objects should have 258 subdirectories.' \
36
- 'test $(wc -l < full-of-directories) = 259'
35
+ '.git/objects should have 3 subdirectories.' \
36
+ 'test $(wc -l < full-of-directories) = 3'
37
38
################################################################
39
# Basics of the basics