]> git.ipfire.org Git - thirdparty/git.git/commitdiff
prune: quiet ENOENT on missing directories
authorEric Wong <e@80x24.org>
Sat, 19 Nov 2022 20:12:13 +0000 (20:12 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Nov 2022 06:58:54 +0000 (15:58 +0900)
$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>
builtin/prune.c
t/t5304-prune.sh

index df376b2ed1e0920e727e5e0a373fbb053ddf3d5a..27192201086877115157d6f5cedb2f8fc1e231a6 100644 (file)
@@ -127,7 +127,9 @@ static void remove_temporary_files(const char *path)
 
        dir = opendir(path);
        if (!dir) {
-               fprintf(stderr, "Unable to open directory %s\n", path);
+               if (errno != ENOENT)
+                       fprintf(stderr, "Unable to open directory %s: %s\n",
+                               path, strerror(errno));
                return;
        }
        while ((de = readdir(dir)) != NULL)
index 8ae314af585482ec240fed353613faf6b23ebb67..d65a5f94b4b557ef9cce4434594729086cb51fad 100755 (executable)
@@ -29,6 +29,14 @@ test_expect_success setup '
        git gc
 '
 
+test_expect_success 'bare repo prune is quiet without $GIT_DIR/objects/pack' '
+       git clone -q --shared --template= --bare . bare.git &&
+       rmdir bare.git/objects/pack &&
+       git --git-dir=bare.git prune --no-progress 2>prune.err &&
+       test_must_be_empty prune.err &&
+       rm -r bare.git prune.err
+'
+
 test_expect_success 'prune stale packs' '
        orig_pack=$(echo .git/objects/pack/*.pack) &&
        >.git/objects/tmp_1.pack &&