All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Bo Yang <struggleyb.nku@gmail.com>
Cc: git@vger.kernel.org, Thomas Rast <trast@student.ethz.ch>,
	Jens Lehmann <Jens.Lehmann@web.de>,
	Jakub Narebski <jnareb@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: Multiple line ranges and files in line level history browser
Date: Sun, 9 May 2010 16:06:54 -0500	[thread overview]
Message-ID: <20100509210654.GA1637@progeny.tock> (raw)
In-Reply-To: <p2q41f08ee11005090700xdb6070dajab0e2d77b1d0f9fc@mail.gmail.com>

Hi,

Bo Yang wrote:

> git log <revision> -L1,8 -L45,+6 <file1> -L/some/,/end/ -L9,29 <file2> <file3>

I like it.  It looks like paranoid script authors would have to check
for paths like ‘--’ and ‘-L’ and quote them as ‘./--’ and ‘./-L’, a
small price to pay for a nice syntax.

Unfortunately, this is completely incompatible with the existing blame
option syntax.  i.e., existing scripts might do things like this:

  git blame -L1,8 -C <file>

or

  git blame -L1,8 <rev> <file>

Maybe there should be a line range required before every file
specifier in this syntax, to avoid trouble.  Borrowing syntax from sed,
this makes

 git log <rev> -L1,8 -L45,+6 <file1> -L/some/,/end/ -L9,29 <file2> -L1,$ <file3>

which is also a little clearer to look at, I think.

> 'git log -L1,8 <revision> -- -L1,8' .

This provides a single line range specifier for all files?  Sounds
convenient.

  # who wrote the opening comments?
  git blame -L '/^[/][*]/,/^ [*][/]/' -- '*.c'

Summing up, with my refinement above, a human would parse args like
this:

  When an -L option is encountered, remember the current state.

  Try to parse the remaining arguments as ((-L range)* filespec)*,
  where filespec has some appropriately strict meaning that forbids
  ‘-L’ and ‘--’.  If that succeeds, we’re done.

  Otherwise, rewind.  Look for an upcoming ‘--’.  If -- is found, any
  -L arguments before the -- apply to all files specified.  Unclaimed
  arguments before the -- are revision specifiers.

  If no -- is found either, any -L arguments before the first
  unclaimed argument that is not unambiguously a revision apply to all
  files specified.  Arguments from that point on must be unambiguously
  paths.

A little hairy.  Maybe you can do better, but already it seems okay.
Maybe the last case ought to disallow multiple -L arguments and
multiple files, to encourage people to use the first syntax or an
explicit ‘--’.

Hope that helps,
Jonathan

  parent reply	other threads:[~2010-05-09 21:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-09 14:00 Multiple line ranges and files in line level history browser Bo Yang
2010-05-09 18:20 ` Junio C Hamano
2010-05-11  5:43   ` Bo Yang
2010-05-12  7:57     ` Thomas Rast
2010-05-09 21:06 ` Jonathan Nieder [this message]
2010-05-10  9:31   ` Jonathan Nieder
2010-05-11  6:28     ` Bo Yang
2010-05-11  6:16   ` Bo Yang
2010-05-11  6:28     ` Jonathan Nieder

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=20100509210654.GA1637@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=struggleyb.nku@gmail.com \
    --cc=trast@student.ethz.ch \
    /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.