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

Re: blame -L questions

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 9, 2010, 03:32 UTC
Message-ID
<7vtytrulr1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<76718491002081903s2e37875bs85eeb55779167ce7@mail.gmail.com>
Jay Soffian <jaysoffian@gmail.com> writes:
Show 11 quoted lines
> My use case is emitting blocks that are wrapped in
>
> #if defined(WHATEVER)
> ....
> #endif
>
> I was going to use the syntax -L /start/../end/ for this.
>
> I naively thought I might just be able to setup multiple blame_entry's
> linked through the next/prev pointers at the start, but that clearly
> does not work.

The current -L parser is prepared to take only one range, but the underlying data structure should be able to support what you want to do.

The scoreboard holds one final image (final_buf, final_buf_size) that is the whole blob in the revision being annotated. Without -L, we start with one blame entry in ent that covers the whole lines in this image. With a single -L (i.e. the current implementation), this single ent covers a bit narrower range of lines than the whole file.

    A blame_entry records a range of lines (lno, num_lines) and which path
    from what commit is the current suspect.  We iteratively compare this
    with parents of the suspect to see if we can pass blame for some lines
    in the given range to some parents.  When we can pass blame for the
    whole range, we just update the "suspect" to parent; when we can pass
    blame for some but not for other lines in the range, we break the
    blame_entry into pieces, pass blame to parents for lines that came
    from those parents and declare the current suspect for lines that did
    not appear in any of the parents.
    But this part does not concern you very much.  The only thing you need
    to know for what you want to do is how an ent must be initialized.

You should be able to start with more than one blame entry queued in ent member of the scoreboard, each representing one range given by an -L option, and as long as you prime these blame entries correctly, everything should work just fine. sb->ent is supposed to be sorted by line number and not have overlap, but I don't think they have to be contiguous.

Previous: Jay Soffian
Message 2 of 2 in “blame -L questions”
  1. Jay SoffianFeb 9, 2010
  2. Junio C HamanoFeb 9, 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.