* looking for example of following code across files
@ 2008-02-16 4:41 Rhodes, Kate
2008-02-16 9:16 ` Jakub Narebski
0 siblings, 1 reply; 4+ messages in thread
From: Rhodes, Kate @ 2008-02-16 4:41 UTC (permalink / raw)
To: git
I seem to remember that when Linus was giving the tech-talk to the
folks at Google he mentioned Git being able to follow a block of code
as it was moved from file to file, but I'm having a hard time finding
an actual example of how that plays out. I'd love to be able to
demonstrate this to people but I'm not quite sure of the steps I'd
need to do to accomplish this.
I've gotten as far as using git ls-tree to track down the sha1 of the
blob I want to follow, which I'm assuming is the key to making this
happen but I'm not sure where to go from there. :(
Can someone please point me to an example showing how to go about this?
-Kate=masukomi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: looking for example of following code across files
2008-02-16 4:41 looking for example of following code across files Rhodes, Kate
@ 2008-02-16 9:16 ` Jakub Narebski
2008-02-16 17:10 ` Rhodes, Kate
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Narebski @ 2008-02-16 9:16 UTC (permalink / raw)
To: Rhodes, Kate; +Cc: git
"Rhodes, Kate" <masukomi@gmail.com> writes:
> I seem to remember that when Linus was giving the tech-talk to the
> folks at Google he mentioned Git being able to follow a block of code
> as it was moved from file to file, but I'm having a hard time finding
> an actual example of how that plays out. I'd love to be able to
> demonstrate this to people but I'm not quite sure of the steps I'd
> need to do to accomplish this.
>
> I've gotten as far as using git ls-tree to track down the sha1 of the
> blob I want to follow, which I'm assuming is the key to making this
> happen but I'm not sure where to go from there. :(
>
> Can someone please point me to an example showing how to go about this?
For example in git.git repository, try "git gui blame revision.c".
The 9th fragment, the 'path_name' function, was moved there from the
file "rev-list.c".
This is the commit that added the code:
commit e646de0d14bac20ef6e156c1742b9e62fb0b9020
Author: Junio C Hamano <junkio@cox.net> czw lut 23 07:10:24 2006
Committer: Junio C Hamano <junkio@cox.net> pi? lut 24 08:44:42 2006
Original File: rev-list.c
rev-list --objects: use full pathname to help hashing.
This helps to group the same files from different revs together,
while spreading files with the same basename in different
directories, to help pack-object.
Signed-off-by: Junio C Hamano <junkio@cox.net>
This is the commit that moved the code
commit ae563542bf10fa8c33abd2a354e4b28aca4264d7
Author: Linus Torvalds <torvalds@osdl.org> nie lut 26 01:19:46 2006
Committer: Junio C Hamano <junkio@cox.net> pon lut 27 00:33:27 2006
First cut at libifying revlist generation
This really just splits things up partially, and creates the
interface to set things up by parsing the command line.
No real code changes so far, although the parsing of filenames is a bit
stricter. In particular, if there is a "--", then we do not accept any
filenames before it, and if there isn't any "--", then we check that _all_
paths listed are valid, not just the first one.
The new argument parsing automatically also gives us "--default" and
"--not" handling as in git-rev-parse.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
You can check the commits using gitweb; unfortunately blame in gitweb
is usually disabled, and it dies not have fancy "git gui blame"
showing of code movements.
P.S. Sorry, I've just noticed that the dates are in my locale...
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: looking for example of following code across files
2008-02-16 9:16 ` Jakub Narebski
@ 2008-02-16 17:10 ` Rhodes, Kate
2008-02-16 17:54 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Rhodes, Kate @ 2008-02-16 17:10 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
On Feb 16, 2008, at 4:16 AM, Jakub Narebski wrote:
> "Rhodes, Kate" <masukomi@gmail.com> writes:
>
>> I seem to remember that when Linus was giving the tech-talk to the
>> folks at Google he mentioned Git being able to follow a block of code
>> as it was moved from file to file, but I'm having a hard time finding
>> an actual example of how that plays out.
[snip]
>>
>> Can someone please point me to an example showing how to go about
>> this?
>
> For example in git.git repository, try "git gui blame revision.c".
> The 9th fragment, the 'path_name' function, was moved there from the
> file "rev-list.c".
>
> This is the commit that added the code:
>
> commit e646de0d14bac20ef6e156c1742b9e62fb0b9020
[snip]
>
> This is the commit that moved the code
>
> commit ae563542bf10fa8c33abd2a354e4b28aca4264d7
[snip]
>
> You can check the commits using gitweb; unfortunately blame in gitweb
> is usually disabled, and it dies not have fancy "git gui blame"
> showing of code movements.
>
> P.S. Sorry, I've just noticed that the dates are in my locale...
Thank you Jakub. I really appreciate it.
In order to find the original commit of each block is the system
looking up the commit for each block via it's SHA1, then following its
parent commits until it finds another commit that affected the same
block or runs out of commits?
I'm thinking that while this would be possible to do manually it would
way too many lookups to be practical. Or, is there a simpler way to do
it on the command line?
I'm just trying to get my head around how the pieces of git fit
together.
-Kate=masukomi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: looking for example of following code across files
2008-02-16 17:10 ` Rhodes, Kate
@ 2008-02-16 17:54 ` Jeff King
0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2008-02-16 17:54 UTC (permalink / raw)
To: Rhodes, Kate; +Cc: Jakub Narebski, git
On Sat, Feb 16, 2008 at 12:10:11PM -0500, Rhodes, Kate wrote:
> In order to find the original commit of each block is the system looking
> up the commit for each block via it's SHA1, then following its parent
> commits until it finds another commit that affected the same block or runs
> out of commits?
Not exactly. You don't have a sha1 for each block, you have a sha1 for
the whole file. So you walk the parent tree looking for the first time a
particular chunk showed up. The basic idea is sketched out here:
http://article.gmane.org/gmane.comp.version-control.git/28826
> I'm thinking that while this would be possible to do manually it would
> way too many lookups to be practical. Or, is there a simpler way to do it
> on the command line?
You could do it manually, but it would be horribly slow. An overly
simplified version of the algorithm is:
1. Assume I'm interesed in a line that says "int foo() {"
2. Check whether my parent has that line
2a. If yes, then pass blame to parent, starting at '1'.
2b. If no, then I introduced the line. Accept blame.
[When you talk about content movement, it gets a little trickier. See
Junio's original explanation for more details.]
So you would end up pass blame for some lines through many commits that
didn't touch those lines. I don't think you would want to do that by
hand.
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-02-16 17:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-16 4:41 looking for example of following code across files Rhodes, Kate
2008-02-16 9:16 ` Jakub Narebski
2008-02-16 17:10 ` Rhodes, Kate
2008-02-16 17:54 ` Jeff King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox