From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Tom Cook <tom.k.cook@gmail.com>,
"brian m . carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH] setup: only die on invalid .git under RUN_SETUP
Date: Thu, 22 Jul 2021 23:08:23 +0200 [thread overview]
Message-ID: <87mtqet5aw.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <xmqq5yx29nj3.fsf@gitster.g>
On Thu, Jul 22 2021, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> Change RUN_SETUP_GENTLY to stop dying if e.g. the .git is "not a
>> repo". This means that we now recover in cases like:
>>
>> $ echo "gitdir: /foo/bar" > .git
>> $ git ls-remote https://github.com/torvalds/linux
>> [... ls-remote output ...]
>>
>> But not (as intended):
>>
>> $ git rev-parse HEAD
>> fatal: not a git repository: /foo/bar
>
> I am of two minds. ls-remote is benign in that it behaves more or
> less identically when given certain types of args, and the above may
> be a strict improvement (but it does fail if you did not use URL but
> use a remote nickname you thought you configured in the repository
> in such a situation). There however are a few niche commands that
> work inside and outside a repository and they work differently. For
> example, if you do
>
> $ git diff file1 file2
>
> in such a corrupt repository, I'd prefer to see the command _fail_
> to nudge the user to look into the situation, instead of taking the
> output (which degenerates to "git diff --no-index file1 file2"
> outside a repository) blindly as a patch that shows the changes
> relative to the index for these two paths.
Yes it comes down to what we think RUN_SETUP_GENTLY and
setup_git_directory_gently() should be doing.
I.e. is &nongit_ok supposed to be a binary "repo you can use"/"[...]
can't use", or a tri-state of that plus "this looks like it's supposed
to be a repo, but it's broken, so let's die".
Anyway, if you're not happy with this pretty much as-is consider it
dropped from my side, because I think the next step would be to do some
more work on e.g. split up RUN_SETUP_GENTLY into a mode that makes sense
for "diff", and another for "bugreport" and "ls-remote". I figured this
was an easy bugfix, but if not perhaps Tom Cooks wants to pick this
up...
I guess another easy alternative would be to issue a warning() in this
case, which is a relatively light refactoring of passing an error
message up from the relevant function(s) instead of having it die()
directly.
next prev parent reply other threads:[~2021-07-22 21:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 9:17 Bug: All git operations fail when .git contains a non-existent gitdir Tom Cook
2021-07-21 22:58 ` brian m. carlson
2021-07-22 13:13 ` Tom Cook
2021-07-22 14:07 ` [PATCH] setup: only die on invalid .git under RUN_SETUP Ævar Arnfjörð Bjarmason
2021-07-22 19:06 ` Junio C Hamano
2021-07-22 21:08 ` Ævar Arnfjörð Bjarmason [this message]
2021-07-23 1:59 ` Junio C Hamano
2021-07-23 8:42 ` Tom Cook
2021-07-22 20:50 ` Andrei Rybak
2021-07-23 9:33 ` Ævar Arnfjörð Bjarmason
2021-07-23 15:21 ` Junio C Hamano
2021-07-23 8:23 ` Bug: All git operations fail when .git contains a non-existent gitdir Atharva Raykar
2021-07-23 8:39 ` Tom Cook
2021-07-23 15:47 ` Ævar Arnfjörð Bjarmason
2021-07-23 17:02 ` Atharva Raykar
2021-08-30 0:38 ` David Aguilar
2021-08-31 14:16 ` Tom Cook
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=87mtqet5aw.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sandals@crustytoothpaste.net \
--cc=tom.k.cook@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).