Skip to content

Commit 9106c09

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
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>
1 parent c1aaa5d commit 9106c09

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

git-prune.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ sed -ne '/unreachable /{
2222
}' | {
2323
cd "$GIT_OBJECT_DIRECTORY" || exit
2424
xargs $echo rm -f
25+
rmdir 2>/dev/null [0-9a-f][0-9a-f]
2526
}
2627

2728
git-prune-packed $dryrun

init-db.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,6 @@ int main(int argc, char **argv)
281281
memcpy(path, sha1_dir, len);
282282

283283
safe_create_dir(sha1_dir);
284-
for (i = 0; i < 256; i++) {
285-
sprintf(path+len, "/%02x", i);
286-
safe_create_dir(path);
287-
}
288284
strcpy(path+len, "/pack");
289285
safe_create_dir(path);
290286
strcpy(path+len, "/info");

prune-packed.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len)
2727
error("unable to unlink %s", pathname);
2828
}
2929
pathname[len] = 0;
30-
if (!rmdir(pathname))
31-
mkdir(pathname, 0777);
30+
rmdir(pathname);
3231
}
3332

3433
static void prune_packed_objects(void)

t/t0000-basic.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ test_expect_success \
2828
'.git/objects should be empty after git-init-db in an empty repo.' \
2929
'cmp -s /dev/null should-be-empty'
3030

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
3333
find .git/objects -type d -print >full-of-directories
3434
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'
3737

3838
################################################################
3939
# Basics of the basics

0 commit comments

Comments
 (0)