mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Wong <>
To: Junio C Hamano <>
Subject: Re: [PATCH] prune: quiet ENOENT on missing directories
Date: Mon, 21 Nov 2022 10:44:27 +0000	[thread overview]
Message-ID: <20221121104427.M268307@dcvr> (raw)
In-Reply-To: <xmqq5yf8yhe0.fsf@gitster.g>

Junio C Hamano <> wrote:
> Eric Wong <> writes:
> > $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,
> Wouldn't setup.c::is_git_directory() say "nope, you do not have a
> repository there" if you are missing $GIT_DIR/objects?  So I suspect
> that the only case this matters in practice is a missing pack/
> subdirectory.

Right.  Removing $GIT_DIR/objects isn't currently OK, but maybe
someday it could be...  Supporting missing pack/ is the primary
reason for this change, but making a small step towards allowing
objects/-free $GIT_DIR doesn't seem harmful.

> I agree that silently ignoring missing objects/pack/ is perfectly
> fine, whether we auto-vivify it when we actually create a pack.
> > but emit the system error in other cases to help users diagnose
> > permissions problems or resource constraints.
> OK.
> > @@ -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;
> >  	}
> This is called twice, with $GIT_OBJECT_DIRECTORY and its pack
> subdirectory, as it does not recurse.  


> This is a tangent, I have to wonder how effective the first call
> would be, though.  When writing a loose object file, we compute its
> object name first in-core and determine the final filename, create a
> temporary file in the same directory as the final file, write into
> it and then finally rename the temporary to the final name.  The
> fan-out $GIT_OBJECT_DIRECTORY/??/ directories may have temporary
> files left when such a process crashed, but do we create cruft "git
> prune" should remove in $GIT_OBJECT_DIRECTORY/ itself?

Good question, perhaps this could be a followup:

diff --git a/builtin/prune.c b/builtin/prune.c
index 2719220108..041c45ecbe 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -188,7 +188,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
 				      prune_cruft, prune_subdir, &revs);
 	prune_packed_objects(show_only ? PRUNE_PACKED_DRY_RUN : 0);
-	remove_temporary_files(get_object_directory());
 	s = mkpathdup("%s/pack", get_object_directory());

OTOH, perhaps there's some 3rd-party tools (e.g. backup tools)
that leave stuff in top-level objects/ and we'd risk breaking
a rare setup via ENOSPC.

  reply	other threads:[~2022-11-21 10:44 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 [this message]
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 ` [PATCH] prune: quiet ENOENT on missing directories Ævar Arnfjörð Bjarmason

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:

  List information:

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

  git send-email \
    --in-reply-to=20221121104427.M268307@dcvr \ \ \ \

* 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

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).