git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "Wolfgang Müller" <wolf@oriole.systems>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 1/2] rev-parse: fix segfault with missing --path-format argument
Date: Wed, 19 May 2021 10:21:25 -0400	[thread overview]
Message-ID: <YKUe5WD3ci3J4roO@coredump.intra.peff.net> (raw)
In-Reply-To: <20210519095235.cydjlj2qoko6xm4v@nabokov.fritz.box>

On Wed, May 19, 2021 at 11:52:35AM +0200, Wolfgang Müller wrote:

> On 2021-05-17 04:16, Jeff King wrote:
> 
> > I don't have a strong preference for one or the other. It is maybe
> > helpful to diagnose "--path-format" without an equals as an error, as
> > your patch would, rather than quietly passing it along as an unknown
> > (as the hunk above would). I dunno. That perhaps applies to the rest
> > of the options, too. :)
> 
> I have a very slight preference for throwing an error: that is what I
> expected to happen as a user. At the same time, passing it along as an
> unknown seems more consistent with the other options that take equals.
> I'm split on this, and would defer to what people here prefer.

Yeah, I don't feel strongly at all. I like consistency, but noticing
bogus input is good, too. ;)

> Short of fully migrating to the parse-options API, I do not see a
> perfect solution for this, especially since there are options that take
> optional arguments which are not delimited by equals. These seem to be
> sprinkled throughout and all error out if no argument is given.

Ultimately I think using the parse-options API would be nice. In the
meantime, I suspect (but didn't think too hard on it) that you could get
by with two helpers:

  - rename the current opt_with_value() to opt_with_optional_value()
    to make its assumptions clear.

  - add a new helper opt_with_required_value() that accepts either:

      --default <arg>
      --default=<arg>
      --disambiguate <arg>
      --disambiguate=<arg>
      etc...

     and complains when the "=" is missing, or there is no extra "<arg>"
     available.

The second helper is a little tricky to write, because it sometimes
needs to advance argv (and decrement argc) to account for the extra
consumed arg.

That's definitely something we can leave off for now, though.

> So it turns out that my hunch was not really correct. Maybe there's also
> a pattern that I am not seeing.

I don't find it hard to believe that there's no obvious pattern. :) I
would say that rev-parse is one of the messiest and most "organically
grown" parts of Git.

Thanks for digging, though. It is always nice to see contributors going
the extra mile to figure out how their solutions fit into the bigger
picture of the project.

-Peff

  parent reply	other threads:[~2021-05-19 14:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16 12:04 [RFC PATCH] rev-parse: fix segfault with missing --path-format argument Wolfgang Müller
2021-05-16 12:53 ` Junio C Hamano
2021-05-16 14:31   ` Wolfgang Müller
2021-05-16 21:59     ` Junio C Hamano
2021-05-17  7:19       ` Wolfgang Müller
2021-05-17  8:02 ` [PATCH v2 0/2] rev-parse: Fix segfault and translate messages Wolfgang Müller
2021-05-17  8:02   ` [PATCH v2 1/2] rev-parse: fix segfault with missing --path-format argument Wolfgang Müller
2021-05-17  8:16     ` Jeff King
2021-05-19  9:52       ` Wolfgang Müller
2021-05-19 10:19         ` Wolfgang Müller
2021-05-19 14:21         ` Jeff King [this message]
2021-05-17  8:02   ` [PATCH v2 2/2] rev-parse: Mark die() messages for translation Wolfgang Müller

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=YKUe5WD3ci3J4roO@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=wolf@oriole.systems \
    /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).