threads / discuss / 59768

[not even design notes yet] teaching rerere to remember removal?

Subject: [not even design notes yet] teaching rerere to remember removal?

## tl;dr

2 messages between May 18, 2023 and May 19, 2023.

replies: 1people: 2as markdown or json

Junio C Hamano· May 18, 2023, 22:18 UTC · lore

This is more like just an early scratches on paper that might some day turn into a design.

A side branch can remove path P, while the mainline, since the side branch forked from it, can modify P. When such a side branch is merged to the mainilne, we would see a 'one side modified, the other side removed' merge conflict. The change made on the mainline may be of small significance (e.g. code restructuring), while the removal done on the side branch may be of bigger significance (e.g. the command implemented by the file P is no longer necessary).

For safety, the rerere mechanism does not unconditionally remember such a removal and replay. When you resolve such a conflict in favor of removal of P after looking at it, the decision to remove it may be reasonable, but if you let the mainline further tweak P without knowing other party working on the side branch is planning to remove it, at some point you may want to reconsider the decision to discard the changes made to P on the mainline. The discarded changes may not be important enough to make you want to resurrect the change and side-port to another path, but at least you would want to have a chance to double check and decide that the new work the mainline did to P is still discardable.

So I am wondering what should be used as the record of "if the other branch made this change, we have seen this conflict already, and we know it is safe to resolve it to remove the path". As such a conflict will leave either stages 1 & 2 (we modified, while they removed), or 1 & 3 (we removed, while they kept working on it), e.g.

    $ git ls-files -u
    100644 d1d63feaa9e299ace44d228176cd2b4335193569 1	t/helper/test-fast-rebase.c
    100644 cac20a72b3fcb52c5ccb66cbbb1679ecb8f39f97 2	t/helper/test-fast-rebase.c
one idea is to take a textual diff of these two stages:
    $ git diff :{1,2}:t/helper/test-fast-rebase.c
    diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
    index d1d63feaa9..cac20a72b3 100644
    --- a/t/helper/test-fast-rebase.c
    +++ b/t/helper/test-fast-rebase.c
    @@ -12,15 +12,16 @@
     #define USE_THE_INDEX_VARIABLE
     #include "test-tool.h"
    -#include "cache.h"
     #include "cache-tree.h"
     #include "commit.h"
     #include "environment.h"
     #include "gettext.h"
    +#include "hash.h"
     #include "hex.h"
     #include "lockfile.h"
     #include "merge-ort.h"
     #include "object-name.h"
    +#include "read-cache-ll.h"
     #include "refs.h"
     #include "revision.h"
     #include "sequencer.h"

and record that when we that one side made this change to a path while the other side removed the path, we know it is safe to resolve such a conflict to remove the path.

The "rerere conflict ID" (the directory name under .git/rerere/ that each rerere database entry uses) is most likely the SHA-1 hash of the above patch text, with pathname and line numbers redacted.

Oswald Buddenhagen· May 19, 2023, 07:51 UTC · re: Junio C Hamano · lore

Re: [not even design notes yet] teaching rerere to remember removal?

On Thu, May 18, 2023 at 03:18:02PM -0700, Junio C Hamano wrote:
>So I am wondering what should be used as the record of "if the other
>branch made this change, we have seen this conflict already, and we
>know it is safe to resolve it to remove the path".
>

i suppose i may be missing the obvious, but why not just treat the removal as a full diff (like a traditional patch would do) and remember the resolution accordingly like any other conflict?

the key to making this useful is presenting followup conflicts in a sensible way that highlights where they actually are, but that would be useful regardless - i often run into this while rebasing, where finding that one line that i added to a bigger section that was (re-)moved requires so much attention that i instead look at the original patch rather than the conflict to see what it was. (note that i'm using diff3 markers.)

regards, ossi

← back to recent threads