Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Dana How <danahow@gmail.com>, Eric Raible <raible@gmail.com>,
	git@vger.kernel.org
Subject: Re: ':/<oneline prefix>' notation doesn't support full file syntax
Date: Fri, 4 Jul 2008 02:14:34 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.1.00.0807040206360.2849@eeepc-johanness> (raw)
In-Reply-To: <7v7ic2zmjp.fsf@gitster.siamese.dyndns.org>

Hi,

On Thu, 3 Jul 2008, Junio C Hamano wrote:

> "Dana How" <danahow@gmail.com> writes:
> 
> > I was surprised to see Dscho advocating removing this feature 
> > altogether. Others proposed other command sequences which avoided :/ . 
> > If :/ is now going to be extended and thus perhaps more likely to 
> > appear in scripts, is now the time to change it to ? which has no 
> > other special meaning to git?
> 
> There are number of problems with ":/" notation, but my biggest gripe is 
> that it is only slightly better than "give back a random commit".

Well, it _is_ better than that: it gives you the _newest_ matching commit, 
provided that the people involved in those commits maintained their NTP 
settings correctly.

The _real_ gripe you should have with the notation is what I pointed out 
already: it is _ill_-defined.  It _could_ match more than one commit, but 
matches only _one_.

> As Dscho mentioned, --grep works much better and instead of saying:
> 
>     $ git diff ':/send-email' HEAD
> 
> we can say:
> 
>     $ git diff \
>       $(git log --pretty=format:%H -1 --grep=send-email master next) HEAD
> 
> The error behaviour is somewhat different between the two, though.  
> When you misspell what to grep, the command substitution will give empty 
> and you would get an unexpected result.  Being built-in, ':/' syntax can 
> say "I do not find anything that match" fairly easily, and the command 
> substitution version has to say something ugly like:
> 
>     $ git diff \
>         $(
>             x=$(git log --pretty=format:%H -1 --grep=send-email master next)
>             case "$x" in
>             ('') echo 0000000000000000000000000000000000000000 ;;
>             (?) echo $x ;; esac
>         ) HEAD
> 
> to get a similar effect.

Again, this is the wrong way to think about it.  If you grep for things, 
you can get 0..infty matches, not necessarily 1.

To assume that you get at least one match is already an error.

Letting that funny "case" syntax slip by, I would suggest this command 
line instead:

$ $(git log --pretty=format:'git diff %H..;' --grep=send-email \
	master next)

> But the point is that you can extend it easily with the :path suffix if 
> you wanted to:
> 
>     $ git show \
>         $(git log --pretty=format:%H -1 \
>         --grep=send-email):git-send-email.perl

Again, I would rather suggest pulling the ":<path>" into the format, as I 
did _already_ in another mail, robustifying the whole command.

> So in short, ':/' is limited (cannot be suffixed with :path, cannot be 
> told to dig down from named revs, etc.) but you can do what ':/' cannot 
> do fairly easily with command substitution.
> 
> However, $(git pick --all --grep=something), without suffixed modifiers
> such as ~$N and :$path, may still be common enough that it might deserve a
> short-hand ':/' (and that is why we have it).
> 
> If people do not find that short-hand useful, I am not strongly opposed to
> the idea of dropping it.  I personally find the notation not very useful
> cute hack anyway ;-).

It was a cute hack, and before --grep it was actually useful.

Now it is not any more,
Dscho

  reply	other threads:[~2008-07-04  0:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-03  5:42 ':/<oneline prefix>' notation doesn't support full file syntax Eric Raible
2008-07-03  8:34 ` Junio C Hamano
2008-07-03  8:50   ` Eric Raible
2008-07-03 12:38     ` Johannes Schindelin
2008-07-03 18:27     ` Dana How
2008-07-03 21:26       ` Junio C Hamano
2008-07-04  0:14         ` Johannes Schindelin [this message]
2008-07-04  0:33       ` Johannes Schindelin
2008-07-03 10:47 ` Jeff King

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=alpine.DEB.1.00.0807040206360.2849@eeepc-johanness \
    --to=johannes.schindelin@gmx.de \
    --cc=danahow@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=raible@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox