threads / discuss / 24913

Detection of relocations within a file

Subject: Detection of relocations within a file

## tl;dr

3 messages between Aug 30, 2010 and Aug 30, 2010.

replies: 2people: 3as markdown or json

Tim Mazid· Aug 30, 2010, 15:04 UTC · lore
Hi git-list,
I was just wondering if git can/does detect relocations of sections of code/text within a file.
For example, moving a function from the top of a file to the end.
If git does not currently do this, would it be a good/bad idea, and how hard would it be to implement?
Regards,
Tim.
 		 	   		  
Jonathan Nieder· Aug 30, 2010, 15:44 UTC · re: Tim Mazid · lore

Re: Detection of relocations within a file

Hi Tim,
Tim Mazid wrote:
> I was just wondering if git can/does detect relocations of sections of code/text within a file.
> 
> For example, moving a function from the top of a file to the end.
Depends what you are trying to do.
1. I am mystified by some piece of code, and I want to know where
it originated.  Code movements is uninteresting to me (so grepping
through a patch won't do it).  The command
 $ git log -S'const char git_more_info_string[] =
	"See 'git help COMMAND' for more information on a specific command.";' \
      -- git.c
tells the originating commit pretty quickly.
2. I am mystified not by some particular piece of code but by an
entire file.  The command
 $ git gui blame -- git.c
works okay.
3. The origins of some piece of code make enough sense, but the code
changes since then are a mystery to investigate.  The command
 $ git log -L '/int main(/,/}/' git.c
with git from the "next" branch can help.
4. I want a simple, easy-to-review patch representing a code movement.
No one I know of has worked on this, and if you have ideas for it,
that would be very neat.
Matthieu Moy· Aug 30, 2010, 16:24 UTC · re: Jonathan Nieder · lore

Re: Detection of relocations within a file

Jonathan Nieder <jrnieder@gmail.com> writes:
> 4. I want a simple, easy-to-review patch representing a code movement.
> No one I know of has worked on this, and if you have ideas for it,
> that would be very neat.
5. I have a history with a lot of code movement, someone branched from
me a while ago, modified various pieces of code which moved in the
meantime, and we want to merge.

Unfortunately, I don't think any VCS does a really good job here either.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

← back to recent threads