mirror of
https://github.com/git/git.git
synced 2024-06-14 03:06:51 +02:00
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>
This commit is contained in:
parent
c1aaa5d9ea
commit
9106c097ad
|
@ -22,6 +22,7 @@ sed -ne '/unreachable /{
|
||||||
}' | {
|
}' | {
|
||||||
cd "$GIT_OBJECT_DIRECTORY" || exit
|
cd "$GIT_OBJECT_DIRECTORY" || exit
|
||||||
xargs $echo rm -f
|
xargs $echo rm -f
|
||||||
|
rmdir 2>/dev/null [0-9a-f][0-9a-f]
|
||||||
}
|
}
|
||||||
|
|
||||||
git-prune-packed $dryrun
|
git-prune-packed $dryrun
|
||||||
|
|
|
@ -281,10 +281,6 @@ int main(int argc, char **argv)
|
||||||
memcpy(path, sha1_dir, len);
|
memcpy(path, sha1_dir, len);
|
||||||
|
|
||||||
safe_create_dir(sha1_dir);
|
safe_create_dir(sha1_dir);
|
||||||
for (i = 0; i < 256; i++) {
|
|
||||||
sprintf(path+len, "/%02x", i);
|
|
||||||
safe_create_dir(path);
|
|
||||||
}
|
|
||||||
strcpy(path+len, "/pack");
|
strcpy(path+len, "/pack");
|
||||||
safe_create_dir(path);
|
safe_create_dir(path);
|
||||||
strcpy(path+len, "/info");
|
strcpy(path+len, "/info");
|
||||||
|
|
|
@ -27,8 +27,7 @@ static void prune_dir(int i, DIR *dir, char *pathname, int len)
|
||||||
error("unable to unlink %s", pathname);
|
error("unable to unlink %s", pathname);
|
||||||
}
|
}
|
||||||
pathname[len] = 0;
|
pathname[len] = 0;
|
||||||
if (!rmdir(pathname))
|
rmdir(pathname);
|
||||||
mkdir(pathname, 0777);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prune_packed_objects(void)
|
static void prune_packed_objects(void)
|
||||||
|
|
|
@ -28,12 +28,12 @@ test_expect_success \
|
||||||
'.git/objects should be empty after git-init-db in an empty repo.' \
|
'.git/objects should be empty after git-init-db in an empty repo.' \
|
||||||
'cmp -s /dev/null should-be-empty'
|
'cmp -s /dev/null should-be-empty'
|
||||||
|
|
||||||
# also it should have 258 subdirectories; 256 fan-out anymore, pack, and info.
|
# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
|
||||||
# 259 is counting "objects" itself
|
# 3 is counting "objects" itself
|
||||||
find .git/objects -type d -print >full-of-directories
|
find .git/objects -type d -print >full-of-directories
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'.git/objects should have 258 subdirectories.' \
|
'.git/objects should have 3 subdirectories.' \
|
||||||
'test $(wc -l < full-of-directories) = 259'
|
'test $(wc -l < full-of-directories) = 3'
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
# Basics of the basics
|
# Basics of the basics
|
||||||
|
|
Loading…
Reference in New Issue