* Is there any efficient way to track history of a piece of code?
@ 2014-05-08 6:54 Jianyu Zhan
2014-05-08 7:00 ` Jeff King
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jianyu Zhan @ 2014-05-08 6:54 UTC (permalink / raw)
To: git; +Cc: gitster
Usually, a trivial change(like coding style fix) may bury a
original change of the code, and thus git blame is of less
help. And to address this situation, I have to do like this:
git blame -s REF^ <file-in-question> > temp
to dig into the history recursively by hand, to find out
the original change.
Here, REF is commit-id that git blame reports.
git log -L is a good alternative option, but sometimes it seems
too cubersome, as I care only one line of code.
Is there any current solution or suggestion?
Thanks,
Jianyu Zhan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is there any efficient way to track history of a piece of code?
2014-05-08 6:54 Is there any efficient way to track history of a piece of code? Jianyu Zhan
@ 2014-05-08 7:00 ` Jeff King
2014-05-08 7:32 ` Jianyu Zhan
2014-05-08 7:06 ` David Kastrup
2014-05-08 7:35 ` Chris Packham
2 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2014-05-08 7:00 UTC (permalink / raw)
To: Jianyu Zhan; +Cc: git
On Thu, May 08, 2014 at 02:54:56PM +0800, Jianyu Zhan wrote:
> Usually, a trivial change(like coding style fix) may bury a
> original change of the code, and thus git blame is of less
> help. And to address this situation, I have to do like this:
>
> git blame -s REF^ <file-in-question> > temp
>
> to dig into the history recursively by hand, to find out
> the original change.
>
> Here, REF is commit-id that git blame reports.
>
> git log -L is a good alternative option, but sometimes it seems
> too cubersome, as I care only one line of code.
>
> Is there any current solution or suggestion?
Try "tig blame"[1]; from the blame view, the "," command will restart
the blame at REF^ automatically. If you don't mind a more graphical
interface, I think "git gui blame" can also reblame from the parent from
the right-click context menu.
-Peff
[1] http://jonas.nitro.dk/tig/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is there any efficient way to track history of a piece of code?
2014-05-08 6:54 Is there any efficient way to track history of a piece of code? Jianyu Zhan
2014-05-08 7:00 ` Jeff King
@ 2014-05-08 7:06 ` David Kastrup
2014-05-08 7:35 ` Chris Packham
2 siblings, 0 replies; 7+ messages in thread
From: David Kastrup @ 2014-05-08 7:06 UTC (permalink / raw)
To: Jianyu Zhan; +Cc: git, gitster
Jianyu Zhan <nasa4836@gmail.com> writes:
> Usually, a trivial change(like coding style fix) may bury a
> original change of the code, and thus git blame is of less
> help. And to address this situation, I have to do like this:
>
> git blame -s REF^ <file-in-question> > temp
>
> to dig into the history recursively by hand, to find out
> the original change.
>
> Here, REF is commit-id that git blame reports.
>
> git log -L is a good alternative option, but sometimes it seems
> too cubersome, as I care only one line of code.
>
> Is there any current solution or suggestion?
git blame -w
might help with a number of "coding style fixes".
--
David Kastrup
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is there any efficient way to track history of a piece of code?
2014-05-08 7:00 ` Jeff King
@ 2014-05-08 7:32 ` Jianyu Zhan
2014-05-08 18:34 ` Junio C Hamano
2014-05-09 6:56 ` David Lang
0 siblings, 2 replies; 7+ messages in thread
From: Jianyu Zhan @ 2014-05-08 7:32 UTC (permalink / raw)
To: Jeff King; +Cc: git
On Thu, May 8, 2014 at 3:00 PM, Jeff King <peff@peff.net> wrote:
> Try "tig blame"[1]; from the blame view, the "," command will restart
> the blame at REF^ automatically. If you don't mind a more graphical
> interface, I think "git gui blame" can also reblame from the parent from
> the right-click context menu.
Thanks! It helps!
Hmm, but you know, we are cli people so we met git ;-)
My by-hand recursive digging history works for me and I've consider automate
this but failed since the pattern match to find the correct line of
code in each recursion
is a big problem.
The root cause of this problem maybe that git is not semantic-aware. It if is,
then we could easily weed out the trivial-change or grammatical-change
in git blame.
Here a structural program comparison tool may be a direction.
http://yinwang0.wordpress.com/2012/01/03/ydiff/
That being said, storing abstract syntax tree, instead of raw object in git.
But that goes too far...
Thanks,
Jianyu Zhan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is there any efficient way to track history of a piece of code?
2014-05-08 6:54 Is there any efficient way to track history of a piece of code? Jianyu Zhan
2014-05-08 7:00 ` Jeff King
2014-05-08 7:06 ` David Kastrup
@ 2014-05-08 7:35 ` Chris Packham
2 siblings, 0 replies; 7+ messages in thread
From: Chris Packham @ 2014-05-08 7:35 UTC (permalink / raw)
To: Jianyu Zhan, git; +Cc: gitster
On 08/05/14 18:54, Jianyu Zhan wrote:
> Usually, a trivial change(like coding style fix) may bury a
> original change of the code, and thus git blame is of less
> help. And to address this situation, I have to do like this:
>
> git blame -s REF^ <file-in-question> > temp
>
> to dig into the history recursively by hand, to find out
> the original change.
>
> Here, REF is commit-id that git blame reports.
>
> git log -L is a good alternative option, but sometimes it seems
> too cubersome, as I care only one line of code.
>
> Is there any current solution or suggestion?
>
I use "git gui blame" for this all the time at $dayjob. If there aren't
too many of these code clean ups then the eclipse git integration is
also handy for this but it will suffer from the same issues as git blame.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is there any efficient way to track history of a piece of code?
2014-05-08 7:32 ` Jianyu Zhan
@ 2014-05-08 18:34 ` Junio C Hamano
2014-05-09 6:56 ` David Lang
1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2014-05-08 18:34 UTC (permalink / raw)
To: Jianyu Zhan; +Cc: Jeff King, git
Jianyu Zhan <nasa4836@gmail.com> writes:
> On Thu, May 8, 2014 at 3:00 PM, Jeff King <peff@peff.net> wrote:
>> Try "tig blame"[1]; from the blame view, the "," command will restart
>> the blame at REF^ automatically. If you don't mind a more graphical
>> interface, I think "git gui blame" can also reblame from the parent from
>> the right-click context menu.
>
> Thanks! It helps!
>
> Hmm, but you know, we are cli people so we met git ;-)
>
> My by-hand recursive digging history works for me and I've consider automate
> this but failed since the pattern match to find the correct line of
> code in each recursion
> is a big problem.
Yes, by definition, there is no corresponding line in a version
behind the version shown in the blame output, so there needs some
heuristics, such as "assume the same line range", "find the
beginning and the end of the function definition that contains that
line", etc.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Is there any efficient way to track history of a piece of code?
2014-05-08 7:32 ` Jianyu Zhan
2014-05-08 18:34 ` Junio C Hamano
@ 2014-05-09 6:56 ` David Lang
1 sibling, 0 replies; 7+ messages in thread
From: David Lang @ 2014-05-09 6:56 UTC (permalink / raw)
To: Jianyu Zhan; +Cc: Jeff King, git
On Thu, 8 May 2014, Jianyu Zhan wrote:
> That being said, storing abstract syntax tree, instead of raw object in git.
> But that goes too far...
well, there are the clean/smudge filters, you can have it run everything through
a prettyprinter as it's checked in.
with a little effort, you could do something along the lines of git filterbranch
that could create a clone of a repo with all commits cleaned up.
David Lang
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-05-09 6:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-08 6:54 Is there any efficient way to track history of a piece of code? Jianyu Zhan
2014-05-08 7:00 ` Jeff King
2014-05-08 7:32 ` Jianyu Zhan
2014-05-08 18:34 ` Junio C Hamano
2014-05-09 6:56 ` David Lang
2014-05-08 7:06 ` David Kastrup
2014-05-08 7:35 ` Chris Packham
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).