Skip to content

Commit 6974765

Browse files
Eric Wonggitster
authored andcommitted
prune: quiet ENOENT on missing directories
$GIT_DIR/objects/pack may be removed to save inodes in shared repositories. Quiet down prune in cases where either $GIT_DIR/objects or $GIT_DIR/objects/pack is non-existent, but emit the system error in other cases to help users diagnose permissions problems or resource constraints. Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3dcec76 commit 6974765

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

builtin/prune.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ static void remove_temporary_files(const char *path)
127127

128128
dir = opendir(path);
129129
if (!dir) {
130-
fprintf(stderr, "Unable to open directory %s\n", path);
130+
if (errno != ENOENT)
131+
fprintf(stderr, "Unable to open directory %s: %s\n",
132+
path, strerror(errno));
131133
return;
132134
}
133135
while ((de = readdir(dir)) != NULL)

t/t5304-prune.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ test_expect_success setup '
2929
git gc
3030
'
3131

32+
test_expect_success 'bare repo prune is quiet without $GIT_DIR/objects/pack' '
33+
git clone -q --shared --template= --bare . bare.git &&
34+
rmdir bare.git/objects/pack &&
35+
git --git-dir=bare.git prune --no-progress 2>prune.err &&
36+
test_must_be_empty prune.err &&
37+
rm -r bare.git prune.err
38+
'
39+
3240
test_expect_success 'prune stale packs' '
3341
orig_pack=$(echo .git/objects/pack/*.pack) &&
3442
>.git/objects/tmp_1.pack &&

0 commit comments

Comments
 (0)