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

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

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 20, 2016, 11:06 UTC
Message-ID
<1453287968-26000-1-git-send-email-pclouds@gmail.com>

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(-)
-- 
2.7.0.125.g9eec362
Next: Nguyễn Thái Ngọc Duy
Message 1 of 20 in “Diff rename, manual correction, round 2”
  1. 0/7 Diff rename, manual correction, round 2Nguyễn Thái Ngọc Duy, Jan 20, 2016
  2. 1/7 diff-no-index: do not take a redundant prefix argumentNguyễn Thái Ngọc Duy, Jan 20, 2016
  3. 2/7 diff.c: take "prefix" argument in diff_opt_parse()Nguyễn Thái Ngọc Duy, Jan 20, 2016
  4. Junio C HamanoJan 20, 2016
  5. Jeff KingJan 20, 2016
  6. Junio C HamanoJan 20, 2016
  7. Duy NguyenJan 21, 2016
  8. Junio C HamanoJan 21, 2016
  9. 3/7 diff: add --rename-fileNguyễn Thái Ngọc Duy, Jan 20, 2016
  10. Junio C HamanoJan 20, 2016
  11. Junio C HamanoJan 20, 2016
  12. 4/7 log: add --rename-notes to correct renames per commitNguyễn Thái Ngọc Duy, Jan 20, 2016
  13. Junio C HamanoJan 20, 2016
  14. Duy NguyenJan 22, 2016
  15. 5/7 merge: add --rename-fileNguyễn Thái Ngọc Duy, Jan 20, 2016
  16. 6/7 diffcore-rename: allow to say "rename this blob to that blob"Nguyễn Thái Ngọc Duy, Jan 20, 2016
  17. 7/7 merge: add --rename-notesNguyễn Thái Ngọc Duy, Jan 20, 2016
  18. Junio C HamanoJan 21, 2016
  19. Duy NguyenJan 22, 2016
  20. Junio C HamanoJan 22, 2016

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.