git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Handling renames.

From
Petr Baudis <pasky@suse.cz>
Date
Oct 22, 2005, 00:47 UTC
Message-ID
<20051022004743.GN30889@pasky.or.cz>
In-Reply-To
<20051022003733.GA8351@pasky.or.cz>
  (Having Apr 14 flashbacks? Good memory!)

Dear diary, on Sat, Oct 22, 2005 at 02:37:33AM CEST, I got a letter where Petr Baudis <pasky@suse.cz> told me that...

Show 7 quoted lines
> But my main concern is - will it be possible to do the rename detection
> here as well? Using --dense instead of explicit diff-tree calls in
> cg-log would be nice optimization, but I was about to add support for
> optional following of renames for cg-log <filename>. That's really
> pretty useful to have, every time I hit the Junio's big scripts rename
> I keep repeating that to myself. ;-) Now when core GIT got the comfort
> of per-file history, I only hope that it will start to annoy you as well.
  After all, this might be as good time to bring this up as any. Heavy
post-1.0 material follows:
  How to track renames? I believe the situation has changed in the last
half a year.  GIT really is a full-fledged SCM by now (at least its
major part code-wise), and I think it's hopefully becoming obvious that
we need to track renames. I actually decided to skip the whole
discussion why so, because we already _do_ concern ourselves with
renames - that's what the cool diff -M gadget does. And people start to
want to use it for all kind of history-digging stuff (not just for nice
diffs between trees).
  So the problem is whether we should make this explicit. diff -M is
only a heuristic and it can go wrong, while it was empirically found
out in other SCMs that people actually don't mind telling their SCM
about renames explicitly - no more than telling it about adds and
removals explicitly. So the user is willing to tell us what precisely
happened and it would be foolish to throw that away and insist on
guessing.  Besides, guessing (and even doing that everytime we go
through the history) is fundamentally slow, orders of magnitude more
than just a tree diff.
  If I convince you that it is worth tracking the renames explicitly,
"how" is already a minor question. One idea of mine was to add an "edge"
object describing the edge between two trees (that's optimized for
flexible use - some people use GIT for really weird things and perhaps
do not use commits at all; edge between two commits would be optimized
for flexibility in case we will later think of some other cool stuff to
track at the edge):
	trees c53f757133bb84a2d87e901c49207e9b7c48e1a6 6bc7aa4f652d0ef49108d9e30a7ea7fbf8e44639
	rename git-pull-script\0git-pull.sh\0
	copy somefile1\0somefile2\0
	rewrite anotherfile1\0anotherfile2\0
  (The "rewrite" line might be controversial. And you might want to
merge this with the delta objects during packing, or do something
similarly clever.)
  Then you could e.g. pass the edge object ID as the second ID on the
parent line:
	parent 99977bd5fdeabbd0608a70e9411c243007ec4ea2 edgeobjectid
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.
Previous: Petr BaudisNext: Linus Torvalds
Message 5 of 20 in “git-rev-list: add "--dense" flag”
  1. Linus TorvaldsOct 21, 2005
  2. Linus TorvaldsOct 21, 2005
  3. Linus TorvaldsOct 21, 2005
  4. Petr BaudisOct 22, 2005
  5. Handling renames.Petr Baudis, Oct 22, 2005
  6. Linus TorvaldsOct 22, 2005
  7. Petr BaudisOct 22, 2005
  8. Junio C HamanoOct 22, 2005
  9. Petr BaudisOct 22, 2005
  10. Linus TorvaldsOct 22, 2005
  11. Linus TorvaldsOct 22, 2005
  12. Petr BaudisOct 22, 2005
  13. Linus TorvaldsOct 22, 2005
  14. Junio C HamanoOct 22, 2005
  15. Linus TorvaldsOct 22, 2005
  16. Jonas FonsecaOct 25, 2005
  17. Linus TorvaldsOct 25, 2005
  18. Jonas FonsecaOct 25, 2005
  19. Linus TorvaldsOct 25, 2005
  20. Linus TorvaldsOct 25, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.