git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Jonathan Nieder" <jrnieder@gmail.com>,
	"Zero King" <l2dy@macports.org>,
	"Git Mailing List" <git@vger.kernel.org>
Subject: Re: [PATCH 8/8] t0012: test "-h" with builtins
Date: Thu, 1 Jun 2017 01:35:36 -0400	[thread overview]
Message-ID: <20170601053536.zflna2bzclhvbeso@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqinkg734c.fsf@gitster.mtv.corp.google.com>

On Thu, Jun 01, 2017 at 01:17:55PM +0900, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > Anyway, the problem is sk/dash-is-previous, specifically fc5684b47
> > (revision.c: args starting with "-" might be a revision, 2017-02-25). It
> > looks like the revision parser used to just bail on "-h", because
> > revision.c would say "I don't recognize this" and then cmd_rev_list()
> > would similarly say "I don't recognize this" and call usage(). But now
> > we actually try to read it as a ref, which obviously requires being
> > inside a repository.
> 
> Heh, I found another ;-)  
> 
> 95e98cd9 ("revision.c: use refs_for_each*() instead of
> for_each_*_submodule()", 2017-04-19), which is in the middle of
> Duy's nd/prune-in-worktree series, does this:

Hrm, yeah. The problem is that handle_revision_pseudo_opt() initializes
the ref store at the top of the function, even if we don't see any
arguments that require us to use it (and obviously in the "-h" case, we
don't).

That's an implementation detail that we could fix, but I do think in
general that we should probably just declare it forbidden to call
setup_revisions() when the repo hasn't been discovered.

> I guess anything that calls setup_revisions() from the "git cmd -h"
> bypass need to be prepared with that
> 
>   check_help_option(argc, argv, usage, options);
> 
> thing.  Which is a bit sad, but I tend to agree with you that
> restructuring to make usage[] of everybody available to git.c
> is probably too noisy for the benefit it would give us.

The other options are:

  - reverting the "-h" magic in git.c. It really is the source of most
    of this confusion, I think, because functions which assume RUN_SETUP
    are having that assumption broken. But at the same time I do think
    it makes "-h" a lot friendlier, and I'd prefer to keep it.

  - reverting the BUG() in setup_git_env(); this has been flushing out a
    lot of bugs, and I think is worth keeping

I did look at writing something like check_help_option(). One of the
annoyances is that we have two different usage formats: one that's a
straight string for usage(), and one that's an array-of-strings for
parse_options(). We could probably unify those.

It doesn't actually save that much code, though. The real value is that
it abstracts the "did git.c decide to skip RUN_SETUP?" logic.

-Peff

  reply	other threads:[~2017-06-01  5:35 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-29 11:45 [Bug] setup_git_env called without repository Zero King
2017-05-29 13:01 ` Ævar Arnfjörð Bjarmason
2017-05-29 15:32   ` Jeff King
2017-05-30  5:09     ` [PATCH 0/8] consistent "-h" handling in builtins Jeff King
2017-05-30  5:11       ` [PATCH 1/8] am: handle "-h" argument earlier Jeff King
2017-05-30  5:43         ` Junio C Hamano
2017-05-30  5:12       ` [PATCH 2/8] credential: handle invalid arguments earlier Jeff King
2017-05-30  5:13       ` [PATCH 3/8] upload-archive: handle "-h" option early Jeff King
2017-05-30  5:15       ` [PATCH 4/8] remote-{ext,fd}: print usage message on invalid arguments Jeff King
2017-05-30  5:16       ` [PATCH 5/8] submodule--helper: show usage for "-h" Jeff King
2017-05-30  5:17       ` [PATCH 6/8] version: convert to parse-options Jeff King
2017-05-30 20:45         ` [PATCH 6.5?/8] version: move --build-options to a test helper Ævar Arnfjörð Bjarmason
2017-05-30 21:05           ` Jeff King
2017-05-31 15:27             ` Johannes Schindelin
2017-05-31 15:31               ` Jeff King
2017-05-31 15:46                 ` Johannes Schindelin
2017-05-31 17:51                   ` Ævar Arnfjörð Bjarmason
2017-05-31 21:06                     ` Jeff King
2017-05-30  5:18       ` [PATCH 7/8] git: add hidden --list-builtins option Jeff King
2017-05-30  5:19       ` [PATCH 8/8] t0012: test "-h" with builtins Jeff King
2017-05-30  6:03         ` Junio C Hamano
2017-05-30  6:05           ` Jeff King
2017-05-30  6:08             ` Junio C Hamano
2017-05-30  6:15               ` Jeff King
2017-05-30 13:23                 ` Junio C Hamano
2017-05-30 15:27                   ` Jeff King
2017-05-30 15:44                     ` Jeff King
2017-05-30 22:39                       ` Junio C Hamano
2017-06-01  4:17                     ` Junio C Hamano
2017-06-01  5:35                       ` Jeff King [this message]
2017-06-01  5:42                       ` Junio C Hamano
2017-06-01  5:54                         ` Junio C Hamano
2017-06-01  6:25                           ` Jeff King
2017-06-01  7:51                             ` Junio C Hamano
2017-06-01  6:10                         ` Jeff King
2017-06-13 23:08         ` Jonathan Nieder
2017-06-14 10:03           ` Jeff King
2017-05-30  5:52       ` [PATCH 0/8] consistent "-h" handling in builtins Junio C Hamano

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=20170601053536.zflna2bzclhvbeso@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=l2dy@macports.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).