git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Eric Wong <e@80x24.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] prune: quiet ENOENT on missing directories
Date: Mon, 21 Nov 2022 12:16:27 +0100	[thread overview]
Message-ID: <221121.86bkp0czz2.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <20221119201213.2398081-1-e@80x24.org>


On Sat, Nov 19 2022, Eric Wong wrote:

> $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>
> ---
>  builtin/prune.c  | 4 +++-
>  t/t5304-prune.sh | 8 ++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/prune.c b/builtin/prune.c
> index df376b2ed1..2719220108 100644
> --- a/builtin/prune.c
> +++ b/builtin/prune.c
> @@ -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));

We sometimes use fprintf() instead of "error" or "warning" for output
compatibility with an older version, or because it's written in an old
style.

But as you're changing the anyway let's not re-invent error_errno() or
warning_errno(), but just use those.

We could also s/^Unable/unable/ in the message while at it, per
CodingGuidelines.

>  		return;
>  	}
>  	while ((de = readdir(dir)) != NULL)
> diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
> index 8ae314af58..d65a5f94b4 100755
> --- a/t/t5304-prune.sh
> +++ b/t/t5304-prune.sh
> @@ -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 &&

This seems like a good isolated change, but FWIW I think what we really
should be doing here is using the "report_garbage" facility added in
543c5caa6c9 (count-objects: report garbage files in pack directory too,
2013-02-15) and 478f34d2b6e (gc: remove garbage .idx files from pack
dir, 2015-11-03) for "pack".

I.e. we have already iterated over "pack" and found all the files
therein, and in packfile.c error_errno() etc. That we're
re-opendir()-ing the "pack", walking it again etc. doesn't make much
sense, or does it?

Then the:

	remove_temporary_files(get_object_directory());

Also seems odd, just a few lines above we passed "prune_cruft" to
"for_each_loose_file_in_objdir()", haven't we already walked the loose
object dir & removed temporary cruft there?




      parent reply	other threads:[~2022-11-21 11:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-19 20:12 [PATCH] prune: quiet ENOENT on missing directories Eric Wong
2022-11-21  6:02 ` Junio C Hamano
2022-11-21 10:44   ` Eric Wong
2022-11-21 13:08     ` Junio C Hamano
2022-11-21 23:09       ` Junio C Hamano
2022-11-22  0:09         ` [PATCH] prune: recursively prune objects directory Eric Wong
2022-11-22  1:28           ` Junio C Hamano
2022-11-22  9:59             ` Eric Wong
2022-11-22 23:16               ` Junio C Hamano
2022-11-21 11:16 ` Ævar Arnfjörð Bjarmason [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=221121.86bkp0czz2.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=e@80x24.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).