From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
git@vger.kernel.org, "Derrick Stolee" <stolee@gmail.com>,
"Christian Couder" <christian.couder@gmail.com>
Subject: Re: [PATCH 2/3] sha1-file: emit error if an alternate looks like a repository
Date: Wed, 5 Dec 2018 01:10:35 -0500 [thread overview]
Message-ID: <20181205061035.GB12980@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqzhtkd4sz.fsf@gitster-ct.c.googlers.com>
On Wed, Dec 05, 2018 at 12:35:08PM +0900, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
> > Since 26125f6b9b ("detect broken alternates.", 2006-02-22) we've
> > emitted an error if the alternates directory doesn't exist, but not
> > for the common misstep of adding a path to another git repository as
> > an alternate, as opposed to its "objects" directory.
> >
> > Let's check for this, i.e. whether X/objects or X/.git/objects exists
> > if the user supplies X and print an error (which as a commit leading
> > up to this one shows doesn't change the exit code, just "warns").
>
> I agree that "Let's check for this" is a good idea, but do not
> necessarily agree with "i.e.". Don't we have a helper that takes
> the path to an existing directory and answers "Yup, it does look
> like a Git repository"? Using that is a lot more in line with what
> you claimed to do in the title for this patch.
Hmm. Yeah, one case this does not handle is when ".git" is a git-file
pointing elsewhere, which should trigger the condition, too.
I think we can afford to be a bit loose with this check if it's just
generating a warning for a case that would otherwise not work (and the
worst is that we might fail to correctly diagnose a broken setup). But
that I think points to another issue: this kicks in even if the path is
otherwise usable.
So if had, say, a git repository whose worktree was full of objects and
packfiles, it currently works for me to point to that as an alternate.
But after this patch, we'd complain "wait, this looks like a git repo!".
So I'd much rather see the logic check first for something usable, and
only when we fail to find it, start doing a loose diagnosis. Something
like:
if !is_directory($path)
complain that it does not exist, as now
else if !is_directory($path/pack)
/*
* it doesn't look like an object directory; technically it
* _could_ just have loose objects, and maybe we ought to check
* for directories matching [0-9a-f]{2}, though it seems
* somewhat unlikely these days.
*/
if is_directory($path/objects) || exists($path/.git)
complain that it looks like a git dir
else
complain that it doesn't look like an object dir
fi
Hmm. I managed to write a gross mix of C and shell for my pseudocode,
but hopefully you can read it. ;)
> I haven't read 3/3 yet, but as I said, I suspect it is reasonable to
> DWIM and use the object store associated with the directory we found
> to be a repository.
Yeah, I'm tempted by that, too, though I worry about corner cases. How
much effort should we put into discovery? I guess the rules from
enter_repo() would make sense, though the logic in that function would
need some refactoring to be reused elsewhere.
-Peff
next prev parent reply other threads:[~2018-12-05 6:10 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-29 14:59 How de-duplicate similar repositories with alternates Ævar Arnfjörð Bjarmason
2018-11-29 16:09 ` Ævar Arnfjörð Bjarmason
2018-11-29 18:55 ` Stefan Beller
2018-11-29 20:10 ` Ævar Arnfjörð Bjarmason
2018-11-29 20:43 ` Duy Nguyen
2018-12-04 7:06 ` Jeff King
2018-12-04 12:07 ` Derrick Stolee
2018-12-04 6:59 ` Jeff King
2018-12-04 10:43 ` Ævar Arnfjörð Bjarmason
2018-12-04 13:27 ` [PATCH 0/3] sha1-file: warn if alternate is a git repo (not object dir) Ævar Arnfjörð Bjarmason
2018-12-04 13:27 ` [PATCH 1/3] sha1-file: test the error behavior of alt_odb_usable() Ævar Arnfjörð Bjarmason
2019-03-28 20:04 ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2019-03-29 13:46 ` Jeff King
2019-03-29 13:55 ` Ævar Arnfjörð Bjarmason
2019-04-08 15:57 ` Ævar Arnfjörð Bjarmason
2019-04-09 8:21 ` Junio C Hamano
2019-04-09 8:45 ` Ævar Arnfjörð Bjarmason
2019-04-09 9:43 ` Junio C Hamano
2019-04-09 14:14 ` Jeff King
2019-04-09 8:29 ` Junio C Hamano
2018-12-04 13:27 ` [PATCH 2/3] sha1-file: emit error if an alternate looks like a repository Ævar Arnfjörð Bjarmason
2018-12-05 3:35 ` Junio C Hamano
2018-12-05 6:10 ` Jeff King [this message]
2018-12-04 13:27 ` [PATCH 3/3] sha1-file: change alternate "error:" message to "warning:" Ævar Arnfjörð Bjarmason
2018-12-05 3:37 ` Junio C Hamano
2018-12-05 5:54 ` Jeff King
2018-12-05 3:30 ` How de-duplicate similar repositories with alternates Junio C Hamano
2018-12-04 13:35 ` Ævar Arnfjörð Bjarmason
2018-12-04 14:17 ` Derrick Stolee
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=20181205061035.GB12980@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=avarab@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=stolee@gmail.com \
/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).