git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: david@lang.hm
Cc: git@vger.kernel.org
Subject: Re: how to track the history of a line in a file
Date: Fri, 2 Jan 2009 16:26:56 -0500	[thread overview]
Message-ID: <20090102212655.GA24082@coredump.intra.peff.net> (raw)
In-Reply-To: <alpine.DEB.1.10.0901021405460.21567@asgard.lang.hm>

On Fri, Jan 02, 2009 at 02:13:32PM -0800, david@lang.hm wrote:

> I have a need to setup a repository where I'm storing config files, and I  
> need to be able to search the history of a particular line, not just when  
> the last edit of the line was (which is what I see from git blame)

As you figured out, the "manual" way is to just keep reblaming from the
parent of each blame. Recent versions of "git gui blame" have a "reblame
from parent" option in the context menu which makes this a lot less
painful.

> 57f8f7b6 (Linus Torvalds 2008-10-23 20:06:52 -0700 3) SUBLEVEL = 28
>
> what I would want it to show would be a list of the commits that have  
> changed this line.

The tricky thing here is what is "this line"? Using the line number
isn't right, since it will change based on other content coming in and
out of the file. You can keep drilling down by reblaming parent commits,
but remember that each time you do that you are manually looking at the
content and saying "Oh, this is the line I am still interested in." So I
a script would have to correlate the old version and new version of the
line and realize how to follow the "interesting" thing.

In your case, I think you want to see any commit in Makefile which
changed a line with SUBLEVEL in it. Which is maybe easiest done as:

  git log -z -p Makefile |
    perl -0ne 'print if /\n[+-]SUBLEVEL/' |
    tr '\0' '\n'

and is pretty fast. But obviously we're leveraging some content-specific
knowledge about what's in the Makefile.

-Peff

  reply	other threads:[~2009-01-02 21:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-02 22:13 how to track the history of a line in a file david
2009-01-02 21:26 ` Jeff King [this message]
2009-01-02 22:43   ` david
2009-01-02 21:49     ` Jeff Whiteside
2009-01-02 22:58       ` david
2009-01-02 23:01   ` david
2009-01-02 23:48     ` david
2009-01-02 22:54       ` Junio C Hamano
2009-01-03  0:59         ` david
2009-01-03  0:07           ` Thomas Rast
2009-01-03  2:05             ` david
2009-01-02 23:56       ` david
2009-01-03  4:25         ` david
2009-01-06 15:48 ` Bernt Hansen
2009-01-06 16:08   ` Miklos Vajna
2009-01-06 16:21     ` Bernt Hansen
2009-01-06 16:28       ` Bernt Hansen

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=20090102212655.GA24082@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=david@lang.hm \
    --cc=git@vger.kernel.org \
    /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).