From: chen bin <chenbin.sh@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Git ML <git@vger.kernel.org>
Subject: Re: A new idea to extend git-blame
Date: Tue, 26 Nov 2019 15:55:14 +1100 [thread overview]
Message-ID: <CAAE-R+8betprfFOH+m_mMATX2mODHQ8pFUpLo4tyLVBVAVtySg@mail.gmail.com> (raw)
In-Reply-To: <20191125141635.GD494@sigill.intra.peff.net>
I re-tested `git log -L20,20:README.md` in git's own repo with HEAD
d01d26f2df. Looks git log is not what I expected. The output contains
many unrelated commits. So it will be slow in real project.
A recursive blame with the algorithm I suggest will get correct commit
in short time. So my suggestion still hold.
I could submit a patch to enhance blame.
On Tue, Nov 26, 2019 at 1:16 AM Jeff King <peff@peff.net> wrote:
>
> On Mon, Nov 25, 2019 at 11:41:55PM +1100, Chen Bin wrote:
>
> > 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
--
help me, help you.
next prev parent reply other threads:[~2019-11-26 4:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-25 12:41 A new idea to extend git-blame Chen Bin
2019-11-25 14:16 ` Jeff King
2019-11-26 4:55 ` chen bin [this message]
2019-11-26 5:36 ` chen bin
2019-11-27 7:32 ` chen bin
2019-11-27 11:30 ` Jeff King
2019-11-27 12:18 ` chen bin
2019-11-27 13:38 ` chen bin
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=CAAE-R+8betprfFOH+m_mMATX2mODHQ8pFUpLo4tyLVBVAVtySg@mail.gmail.com \
--to=chenbin.sh@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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;
as well as URLs for NNTP newsgroup(s).