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

Handling renames.

From
David Woodhouse <dwmw2@infradead.org>
Date
Apr 14, 2005, 17:54 UTC
Message-ID
<1113501260.27227.26.camel@hades.cambridge.redhat.com>

I've been looking at tracking file revisions. One proposed solution was to have a separate revision history for individual files, with a new kind of 'filecommit' object which parallels the existing 'commit', referencing a blob instead of a tree. Then trees would reference such objects instead of referencing blobs directly.

I think that introduces a lot of redundancy though, because 99% of the time, the revision history of the individual file is entirely reproducible from the revision history of the tree. It's only when files are renamed that we fall over -- and I think we can handle renames fairly well if we just log them in the commit object.

My 'gitfilelog.sh' script is already capable of tracking a given file back through multiple tree commits, listing those commits where the file in question was actually changed. It uses my patched version of diff- tree which supports 'diff-tree <TREE_A> <TREE_B> <filename>' in order to do this.

By storing rename information in the commit object, the script (or a reimplementation of a similar algorithm) could know when to change the filename it's looking for, as it goes back through the tree. That ought to be perfectly sufficient.

So a commit involving a rename would look something like this...
	tree 82ba574c85e9a2e4652419c88244e9dd1bfa8baa
	parent bb95843a5a0f397270819462812735ee29796fb4
	rename foo.c bar.c
	author David Woodhouse <dwmw2@hades.cambridge.redhat.com> 1113499881 +0100
	committer David Woodhouse <dwmw2@hades.cambridge.redhat.com> 1113499881 +0100
	Rename foo.c to bar.c and s/foo_/bar_/g

Opinions? Dissent? We'd probably need to escape the filenames in some way -- handwave over that for now.

-- 
dwmw2
Next: Linus Torvalds
Message 1 of 20 in “Handling renames.”
  1. David WoodhouseApr 14, 2005
  2. Linus TorvaldsApr 14, 2005
  3. David WoodhouseApr 14, 2005
  4. Ingo MolnarApr 14, 2005
  5. Linus TorvaldsApr 14, 2005
  6. Ingo MolnarApr 14, 2005
  7. David WoodhouseApr 14, 2005
  8. David MansfieldApr 14, 2005
  9. H. Peter AnvinApr 14, 2005
  10. Linus TorvaldsApr 14, 2005
  11. H. Peter AnvinApr 14, 2005
  12. Zach WelchApr 14, 2005
  13. Andrew Timberlake-NewellApr 14, 2005
  14. Naming the SCM (was Re: Handling renames.)Steven Cole, Apr 14, 2005
  15. Petr BaudisApr 14, 2005
  16. H. Peter AnvinApr 14, 2005
  17. Petr BaudisApr 14, 2005
  18. Peter WilliamsApr 14, 2005
  19. Daniel BarkalowApr 14, 2005
  20. David WoodhouseApr 14, 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.