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

[PATCH 0/7] saving and replaying multiple variants with rerere

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 14, 2015, 23:57 UTC
Message-ID
<1442275050-30497-1-git-send-email-gitster@pobox.com>

This is a continuation of jc/rerere topic that is now in 'next'. The old topic is purely about refactoring and code cleaning and this series builds on top of it.

We record a previously seen conflict and its resolution in a subdirectory of $GIT_DIR/rr-cache, and the name of the subdirectory is computed by hashing the "shape" of the conflicted hunk. When a similar-looking conflict is encountered later in the working tree, "git rerere" tries to replay the recorded resolution by running a three-way merge to apply the change to go from the previous conflict to the previous resolution to the current conflicted state.

Depending on what appears in the context around the conflicted hunk, however, this three-way merge itself can conflict and fail to apply to a seemingly identical conflict. You _could_ argue that you could merge with reduced context lines to work around the problem, but that is a risky proposition.

As a safer approach, these patches allow us to keep more than one pairs of <preimage,postimage> (i.e. conflicted state and its resolution) in the same "shape". If two paths have identical looking conflict and one's resolution does not cleanly replay to the other's conflicted state, we now save the resolutions of these two paths as different "variants" so that they can be applied when we see these conflicts again.

I think the basic "record and replay" part is done with this round, but I haven't really reviewed the part that deals with garbage collection of old rerere database entries, which probably needs more work (and could use help, hints hints...).

Junio C Hamano (7):
  rerere: split conflict ID further
  rerere: scan $GIT_DIR/rr-cache/$ID when instantiating a rerere_id
  rerere: handle leftover rr-cache/$ID directory and postimage files
  rerere: delay the recording of preimage
  rerere: allow multiple variants to exist
  t4200: rerere a merge with two identical conflicts
  rerere: do use multiple variants
 rerere.c          | 270 +++++++++++++++++++++++++++++++++++++++++++++---------
 rerere.h          |   4 +-
 t/t4200-rerere.sh |  92 ++++++++++++++++++-
 3 files changed, 321 insertions(+), 45 deletions(-)
-- 
2.6.0-rc2-164-gdcd5d00
Next: Junio C Hamano
Message 1 of 32 in “saving and replaying multiple variants with rerere”
  1. 0/7 saving and replaying multiple variants with rerereJunio C Hamano, Sep 14, 2015
  2. 1/7 rerere: split conflict ID furtherJunio C Hamano, Sep 14, 2015
  3. 2/7 rerere: scan $GIT_DIR/rr-cache/$ID when instantiating a rerere_idJunio C Hamano, Sep 14, 2015
  4. 3/7 rerere: handle leftover rr-cache/$ID directory and postimage filesJunio C Hamano, Sep 14, 2015
  5. 4/7 rerere: delay the recording of preimageJunio C Hamano, Sep 14, 2015
  6. 5/7 rerere: allow multiple variants to existJunio C Hamano, Sep 14, 2015
  7. 6/7 t4200: rerere a merge with two identical conflictsJunio C Hamano, Sep 14, 2015
  8. 7/7 rerere: do use multiple variantsJunio C Hamano, Sep 14, 2015
  9. 00/11 saving and replaying multiple variants with rerereJunio C Hamano, Mar 28, 2016
  10. 01/11 rerere: split conflict ID furtherJunio C Hamano, Mar 28, 2016
  11. 02/11 rerere: scan $GIT_DIR/rr-cache/$ID when instantiating a rerere_idJunio C Hamano, Mar 28, 2016
  12. 03/11 rerere: handle leftover rr-cache/$ID directory and postimage filesJunio C Hamano, Mar 28, 2016
  13. 04/11 rerere: delay the recording of preimageJunio C Hamano, Mar 28, 2016
  14. 05/11 rerere: allow multiple variants to existJunio C Hamano, Mar 28, 2016
  15. 06/11 t4200: rerere a merge with two identical conflictsJunio C Hamano, Mar 28, 2016
  16. 07/11 rerere: do use multiple variantsJunio C Hamano, Mar 28, 2016
  17. 08/11 rerere: gc and clearJunio C Hamano, Mar 28, 2016
  18. 09/11 rerere: move code related to "forget" togetherJunio C Hamano, Mar 28, 2016
  19. 10/11 rerere: split code to call ll_merge() furtherJunio C Hamano, Mar 28, 2016
  20. 11/11 rerere: adjust 'forget' to multi-variant world orderJunio C Hamano, Mar 28, 2016
  21. 00/11 saving and replaying multiple variants with rerereJunio C Hamano, Apr 6, 2016
  22. 01/11 rerere: split conflict ID furtherJunio C Hamano, Apr 6, 2016
  23. 02/11 rerere: scan $GIT_DIR/rr-cache/$ID when instantiating a rerere_idJunio C Hamano, Apr 6, 2016
  24. 03/11 rerere: handle leftover rr-cache/$ID directory and postimage filesJunio C Hamano, Apr 6, 2016
  25. 04/11 rerere: delay the recording of preimageJunio C Hamano, Apr 6, 2016
  26. 05/11 rerere: allow multiple variants to existJunio C Hamano, Apr 6, 2016
  27. 06/11 t4200: rerere a merge with two identical conflictsJunio C Hamano, Apr 6, 2016
  28. 07/11 rerere: do use multiple variantsJunio C Hamano, Apr 6, 2016
  29. 08/11 rerere: gc and clearJunio C Hamano, Apr 6, 2016
  30. 09/11 rerere: move code related to "forget" togetherJunio C Hamano, Apr 6, 2016
  31. 10/11 rerere: split code to call ll_merge() furtherJunio C Hamano, Apr 6, 2016
  32. 11/11 rerere: adjust 'forget' to multi-variant world orderJunio C Hamano, Apr 6, 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.