Add rename detection
We should use rename detection at least when diffing and merging.
The footnote on https://blog.palantir.com/optimizing-gits-merge-machinery-2-d81391b97878 has some information about how Git does it.
A few logistical questions:
- Is rename tracking explicit metadata (like in mercurial) or implicit (like git)? Do we know yet?
- Are there baby steps towards getting this working, like for example updating
jj diffto notice renames but nothing else? - Do we anticipate big gotchas with how rename tracking interacts with other features, like how the semantics are shared to git and other backends or breaking how conflicts work in renamed files?
I ran into an especially ugly rename+edit case recently and got intensely interested in improving this. =) I'd wanted to use jj split to separate revisions for the pure rename from the subsequent edits and that did not go well...
Is rename tracking explicit metadata (like in mercurial) or implicit (like git)?
This question is confusing because Git doesn't deal with files (it has blobs), but it does have a mv command.
Bazaar(Breezy) also has a mv command, and it deals with renames better than Git.
We don't know yet if we're going to do rename tracking or rename detection. I'm leaning towards tracking, mostly because it seems like it would scale better. One interesting case that rename detection handles well when commit A adds file foo, commit B modifies it, and then you amend A with a rename from foo to bar (https://bz.mercurial-scm.org/show_bug.cgi?id=5457).
Also, if we want to track renames and also track content moves at the sub-file level (like git blame -C), then we would either have to track moved content at the sub-file level, or we'd have to somehow augment the file-level tracking information. It might be enough to track that "some content was moved out of file foo and into file bar" and then detect at query time exactly which content it was.
We should also keep in mind that diffing will hopefully get smarter in the future. In particular, I hope we'll start doing language-/AST-aware diffing and merging at some point. So we probably don't want to do any sub-file-level tracking of moved content, because we'll probably be able to detect exactly what moved in the future. Relevant message from Linus Torvalds: https://gist.github.com/borekb/3a548596ffd27ad6d948854751756a08
Is rename tracking explicit metadata (like in mercurial) or implicit (like git)?
This question is confusing because Git doesn't deal with files (it has blobs), but it does have a
mvcommand. Bazaar(Breezy) also has amvcommand, and it deals with renames better than Git.
Right, I think that's exactly what David is saying - that Git doesn't track renames. Mercurial does track renames.