git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Multiple line ranges and files in line level history browser

From
Junio C Hamano <gitster@pobox.com>
Date
May 9, 2010, 18:20 UTC
Message-ID
<7v1vdl9btm.fsf@alter.siamese.dyndns.org>
In-Reply-To
<p2q41f08ee11005090700xdb6070dajab0e2d77b1d0f9fc@mail.gmail.com>
Bo Yang <struggleyb.nku@gmail.com> writes:
Show 7 quoted lines
> git log <revision> -L1,8 -L45,+6 <file1> -L/some/,/end/ -L9,29 <file2> <file3>
> ...
> Since '-L' option is also used by many other command, I don't know the
> exact impact of this, anyway we can use another name anytime...
>
> If there is no opposition for this kind of option syntax, I will try
> to implement it in revision.c. ;-)

I'd rather not to see this in revision.c at all. The revision.c parser has always been options and then pathspecs and never takes individual filnames, except for "--follow" that is an afterthought checkbox hack that lets the main parser parse and then reject a generic pathspec after the fact.

I think the right place to do this sort of thing is in the incremental output of "blame". The command only takes individual filenames and never takes general pathspecs, it knows about -L as line-range (and as far as I see, it is the only command that does so) and I think its output routine already has the right infrastructure for doing this. The "--incremental" output itself is designed for porcelain scripts to interpret and do the UI around it, but that does not mean it can have another mode that gives human readable output. When "blame --incremental" emits the record that says "these lines are blamed to this path in this commit", it has already run internally necessary "diff" between blobs to find that information---you should be able to re-run the diff (or keep the output from "diff" around, but I would suggest against it) and show something like "git log -p" output but is limited to the hunks that actually touch the areas that we are following.

Previous: Bo YangNext: Bo Yang
Message 2 of 9 in “Multiple line ranges and files in line level history browser”
  1. Bo YangMay 9, 2010
  2. Junio C HamanoMay 9, 2010
  3. Bo YangMay 11, 2010
  4. Thomas RastMay 12, 2010
  5. Jonathan NiederMay 9, 2010
  6. Jonathan NiederMay 10, 2010
  7. Bo YangMay 11, 2010
  8. Bo YangMay 11, 2010
  9. Jonathan NiederMay 11, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.