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

Re: A new idea to extend git-blame

From
Jeff King <peff@peff.net>
Date
Nov 25, 2019, 14:16 UTC
Message-ID
<20191125141635.GD494@sigill.intra.peff.net>
In-Reply-To
<87o8x06sbw.fsf@sydneypc>
On Mon, Nov 25, 2019 at 11:41:55PM +1100, Chen Bin wrote:
Show 24 quoted lines
> The key algorithm is simple,
> 
> The algorithm only works for one line blame and the user must
> select text inside the line first.
> 
> Step 1, `git blame -L6,1 --porcelain -- hello.js` output,
> 
>     4f87408612e0dacfd89a1cd2515944e21cf68561 6 6 1
>     skip...
>     filename hello.js
>      doit({bad: 'destroy world', good: 'hello world', ...});
> 
> I got the commit id (1st column), the line number (2nd column),
> file name (hello.js) and the code line (last line).
> 
> Step 2, if the code line does not contain the selected text, the
>   recursive search stops
> 
> Step 3, or else use commit id, line number and file name to build
>   new git blame cli, like,
> 
> `git blame -L line-num,1 --porcelain 4f8740^ file-name`
> 
> Step 4, execute new git blame command and start from Step 1

This sounds a lot like how git-log's "-L" option works, which tries to find the history of a line over many changes.

It's also similar to the "re-blame from parent" feature of many blame viewers. There we have a human in the loop saying "no, this is not quite the change I'm looking for; go back further".

-Peff
Previous: Chen BinNext: chen bin
Message 2 of 8 in “A new idea to extend git-blame”
  1. Chen BinNov 25, 2019
  2. Jeff KingNov 25, 2019
  3. chen binNov 26, 2019
  4. chen binNov 26, 2019
  5. chen binNov 27, 2019
  6. Jeff KingNov 27, 2019
  7. chen binNov 27, 2019
  8. chen binNov 27, 2019

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.