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: Mon, 08 Feb 2016 11:35:10 -0800	[thread overview]
Message-ID: <xmqqpow7807l.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160208150709.GA13664@sigill.intra.peff.net> (Jeff King's message of "Mon, 8 Feb 2016 10:07:09 -0500")

Jeff King <peff@peff.net> writes:

> The patch for that might look like this. I like it for its relative
> simplicity, though it does make the rules even harder to explain to a
> user...

True.

To be bluntly honest, I do not see the current "string containing
wildcard characters are taken as path, not rev, unless you use the
double dash to disambiguate." all bad.  Isn't it sort of crazy to
have square brackets in paths and if it requires clarification by
the user, I do not particulasrly see it as a problem.

Having said that, I do not think of a big reason to say this patch
is a wrong thing to do, either.

> This breaks the second test in t2019 added by ae454f6, but I am not sure
> that test is doing the right thing (I'm also not sure t2019 is the best
> place for these tests; I added new ones here in a separate script).

I am inclined to agree that that particular test is casting an
implementation limitation in stone.

> We can afford to be fairly slack in our parsing here. We are
> not making a real decision on "this is or is not definitely
> a revision" here, but rather just deciding whether or not
> the extra "wildcards mean pathspecs" magic kicks in.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  setup.c                      | 21 ++++++++++++++++++++-
>  t/t6133-pathspec-rev-dwim.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 64 insertions(+), 1 deletion(-)
>  create mode 100755 t/t6133-pathspec-rev-dwim.sh
>
> diff --git a/setup.c b/setup.c
> index 2c4b22c..03ee4eb 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -130,6 +130,25 @@ int path_inside_repo(const char *prefix, const char *path)
>  	return 0;
>  }
>  
> +static int dwim_as_wildcard(const char *arg)
> +{
> +	const char *p;
> +
> +	if (no_wildcard(arg))
> +		return 0;
> +	if (strstr(arg, "^{"))
> +		return 0; /* probably "^{something}" */
> +	if (strstr(arg, "@{"))
> +		return 0; /* probably "ref@{something}" */
> +
> +	/* catch "tree:path", but not ":(magic)" */
> +	p = strchr(arg, ':');
> +	if (p && p[1] != '(')
> +		return 0;

You seem to reject ":(" specifically, but I am not sure whom is it
designed to help to special case ":(".  Those who write ":(top)"
would not have to disambiguate with "--", but their preference is to
spell things in longhand for more explicit control, so I do not
think they mind typing "--".  On the other hand, those who write
":/" and ":!" (":(top)" and ":(exclude)") would need to disambiguate
with "--" with the change.

That somehow feels backwards.

"A pathspec element with the magic prefix" is hard to tell from
"Look for a path in the index" but not from "Look for a path in a
tree-ish", so if you get (p && p != arg), you know it is tree:path,
I think.

  reply	other threads:[~2016-02-08 19: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 [this message]
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
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=xmqqpow7807l.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.