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 <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Wong committed
Nov 19, 2022 at 20:12 UTC
69747653523afa3322e0f8dd6a5a7d30184694c3
2 files changed
+11
-1
builtin/prune.c
+3
-1
@@ -127,7 +127,9 @@ static void remove_temporary_files(const char *path)
127
128
dir = opendir(path);
129
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));
133
return;
134
}
135
while ((de = readdir(dir)) != NULL)
t/t5304-prune.sh
+8
@@ -29,6 +29,14 @@ test_expect_success setup '
29
git gc
30
'
31
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
+
40
test_expect_success 'prune stale packs' '
41
orig_pack=$(echo .git/objects/pack/*.pack) &&
42
>.git/objects/tmp_1.pack &&