All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Duy Nguyen <pclouds@gmail.com>,
	Kirill Likhodedov <kirill.likhodedov@jetbrains.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	git <git@vger.kernel.org>
Subject: Re: git show doesn't work on file names with square brackets
Date: Wed, 10 Feb 2016 09:35:46 -0800	[thread overview]
Message-ID: <xmqqpow4zcwd.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160210161548.GC19867@sigill.intra.peff.net> (Jeff King's message of "Wed, 10 Feb 2016 11:15:49 -0500")

Jeff King <peff@peff.net> writes:

> Yes, because ":/" is treated specially in check_filename(), and avoids
> kicking in the wildcard behavior. That is certainly preferring revs to
> pathspecs, but I think preferring one over the other is preferable to
> barfing. If the user wants carefulness, they should use "--"
> unconditionally. If they want to DWIM, we should make it as painless as
> possible, even if we sometimes guess wrong.

OK, I think that is sensible.

> But I have a feeling from what you've written that you do not agree with
> the "err and allow something possibly ambiguous" philosophy.

Not anymore ;-)

>> I actually think that no_wildcard() check added in check_filename()
>> was the original mistake.  If we revert the check_filename() to a
>> simple "Is this a filename?" and move the "does this thing have a
>> wildcard" aka "can this be a pathspec even when check_filename()
>> says there is no file with that exact name?" to the code that tries
>> to allow users omit "--", i.e. the caller of check_filename(), would
>> that make the code structure and the semantics much cleaner, I
>> wonder...
>
> Yes. After writing the above, I was envisioning pushing the "err on this
> side" logic into check_filename() with a flag. The main callers are
> verify_filename() and verify_non_filename(), and they would use opposite
> flags from each other.  But pulling that logic out to the caller would
> be fine, too.
>
> IOW, something like this implements the "permissive" thing I wrote above
> (i.e., be inclusive when seeing if something could plausibly be a
> filename, but exclusive when complaining that it _could_ be one):

Yup, I think that is probably a better first step.

> diff --git a/setup.c b/setup.c
> index 2c4b22c..995e924 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -139,9 +139,7 @@ int check_filename(const char *prefix, const char *arg)
>  		if (arg[2] == '\0') /* ":/" is root dir, always exists */
>  			return 1;
>  		name = arg + 2;
> -	} else if (!no_wildcard(arg))
> -		return 1;
> -	else if (prefix)
> +	} else if (prefix)
>  		name = prefix_filename(prefix, strlen(prefix), arg);
>  	else
>  		name = arg;
> @@ -202,7 +200,7 @@ void verify_filename(const char *prefix,
>  {
>  	if (*arg == '-')
>  		die("bad flag '%s' used after filename", arg);
> -	if (check_filename(prefix, arg))
> +	if (check_filename(prefix, arg) || !no_wildcard(arg))
>  		return;
>  	die_verify_filename(prefix, arg, diagnose_misspelt_rev);
>  }

  reply	other threads:[~2016-02-10 17:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-06 13:16 git show doesn't work on file names with square brackets Kirill Likhodedov
2016-02-06 14:21 ` Johannes Schindelin
2016-02-06 14:29   ` Kirill Likhodedov
2016-02-06 16:10     ` Johannes Schindelin
2016-02-06 23:48       ` Duy Nguyen
2016-02-07 15:11         ` Kirill Likhodedov
2016-02-08  5:06           ` Duy Nguyen
2016-02-08 14:15             ` Jeff King
2016-02-08 14:24               ` Jeff King
2016-02-08 15:07               ` Jeff King
2016-02-08 19:35                 ` Junio C Hamano
2016-02-08 19:52                   ` Jeff King
2016-02-08 20:20                     ` Jeff King
2016-02-08 20:56                       ` Jeff King
2016-02-08 22:36                         ` Junio C Hamano
2016-02-10 15:45                           ` Jeff King
2016-02-09 20:37                     ` Junio C Hamano
2016-02-10 16:15                       ` Jeff King
2016-02-10 17:35                         ` Junio C Hamano [this message]
2016-02-10 21:12                           ` Jeff King
2016-02-10 21:12                             ` [PATCH 1/3] checkout: reorder check_filename conditional Jeff King
2016-02-10 21:31                               ` Junio C Hamano
2016-02-10 21:14                             ` [PATCH 2/3] check_filename: tighten dwim-wildcard ambiguity Jeff King
2016-02-10 21:19                             ` [PATCH 3/3] get_sha1: don't die() on bogus search strings Jeff King
2016-02-10 21:52                               ` Junio C Hamano
2016-02-07 15:09       ` git show doesn't work on file names with square brackets Kirill Likhodedov
2016-02-07 17:10         ` Johannes Schindelin

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

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

  git send-email \
    --in-reply-to=xmqqpow4zcwd.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=kirill.likhodedov@jetbrains.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.