Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'ew/prune-with-missing-objects-pack'
"git prune" may try to iterate over .git/objects/pack for trash
files to remove in it, and loudly fail when the directory is
missing, which is not necessary.  The command has been taught to
ignore such a failure.

* ew/prune-with-missing-objects-pack:
  prune: quiet ENOENT on missing directories
  • Loading branch information
gitster committed Nov 28, 2022
2 parents 15a62fb + 6974765 commit 7d7ed48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtin/prune.c
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions t/t5304-prune.sh
Expand Up @@ -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 &&
Expand Down

0 comments on commit 7d7ed48

Please sign in to comment.