Skip to content

Diff rename, manual correction, round 2

Nguyễn Thái Ngọc Duy git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7diff-no-index: do not take a redundant prefix argumentbuiltin/diff.c diff-no-index.c diff.h+4 -40 replies
2/7diff.c: take "prefix" argument in diff_opt_parse()builtin/am.c diff-no-index.c diff.c +2 more+7 -55 replies
3/7diff: add --rename-fileDocumentation/diff-options.txt diff.c diff.h +2 more+113 -22 replies
4/7log: add --rename-notes to correct renames per commitDocumentation/pretty-options.txt log-tree.c revision.c +2 more+72 -02 replies
5/7merge: add --rename-filebuiltin/merge.c merge-recursive.c merge-recursive.h+11 -00 replies
6/7diffcore-rename: allow to say "rename this blob to that blob"diffcore-rename.c t/t4001-diff-rename.sh+65 -00 replies
7/7merge: add --rename-notesbuiltin/merge.c+114 -03 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/7] Diff rename, manual correction, round 2

Git is amazing. It can detect file renames without you telling it. But even the best fails sometimes. And when it fails, we have no way to correct it. Not so amazing..

Round 1 was three years ago. The idea back then [1] was to let the user say "rename this path to this path". Jeff quickly pointed out it didn't help merge. And it should help merge to reduce merge conflicts. For merge to take advantage of rename correction, the user needs to spell out "rename this blob to this blob" instead. Then I went away doing something and dropped it.

Round 2. I still want to keep "rename path to path", at least on the user interface level. For git-merge, I do exactly what Jeff wrote back then, traversing the whole notes tree to collect rename hints. But now I cache the result, so while traversing is expensive, we don't have to pay often.

The first two patches are preparation. Patch 3 adds --rename-file where you can tell Git to "rename this path to that path" by writing a file with lines like this

this path => that path

I will need to support quoting, but that can come later. Patch 5 is similar.

Patch 4 adds --rename-notes, where you can now store the above file in a notes tree. The note will be used when its associate commit A is diff'ed against A^.

Patch 6 introduces a new syntax to that file, "blob SHA-1 => SHA-1". This is the basis for patch 7, where we traverse the whole notes tree, convert all non-blob lines into blob ones. Then we simply tell git-merge to use that as a rename instruction file.

Expect round 3 in 2019 (hopefully not)

[1] http://thread.gmane.org/gmane.comp.version-control.git/202654

Nguyễn Thái Ngọc Duy (7):
diff-no-index: do not take a redundant prefix argument diff.c: take "prefix" argument in diff_opt_parse()
diff: add --rename-file
log: add --rename-notes to correct renames per commit
merge: add --rename-file
diffcore-rename: allow to say "rename this blob to that blob"
merge: add --rename-notes

 Documentation/diff-options.txt   |   7 +++
 Documentation/pretty-options.txt |   5 ++
 builtin/am.c                     |   2 +-
 builtin/diff.c                   |   2 +-
 builtin/merge.c                  | 123 +++++++++++++++++++++++++++++++++++++++
 diff-no-index.c                  |   7 ++-
 diff.c                           |  13 ++++-
 diff.h                           |   5 +-
 diffcore-rename.c                | 104 ++++++++++++++++++++++++++++++++-
 log-tree.c                       |  32 ++++++++++
 merge-recursive.c                |   1 +
 merge-recursive.h                |   1 +
 revision.c                       |  12 +++-
 revision.h                       |   1 +
 t/t4001-diff-rename.sh           |  82 ++++++++++++++++++++++++++
 15 files changed, 386 insertions(+), 11 deletions(-)
Signature · 1 line
2.7.0.125.g9eec362