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

Re: What's the recommendation for forgetting all rerere's records?

From
Sean Allred <allred.sean@gmail.com>
Date
Jan 3, 2024, 08:30 UTC
Message-ID
<m0frzeu89w.fsf@epic96565.epic.com>
In-Reply-To
<35f24a01d15ce28932bb6be098d6a164a49cc542008f75673cd6221a9b24b578@mu.id>

(Doesn't look like this actually got picked up by lore when I originally sent it at Fri, 22 Dec 2023 12:19:50 -0600. This is a re-send; apologies if you get this message twice.)

==
There might be a bug here.
Junio C Hamano <gitster@pobox.com> writes:
     # Now the fun command you seem to have missed.  You MUST give
     # "git checkout --merge" a pathspec.  I do not encourage it but
     # using "." to say "unresolve everything under the sun" should
     # also work.
     $ git checkout --merge builtin/mv.c
     Recreated 1 merge conflict
Yep, I definitely missed this! Very handy, thank you :-)
     # You should then be able to correct the resolution with your
     # editor.
     $ edit builtin/mv.c
     # If this is one-time fix (you are happy with the original
     # resolution and wanted to deviate from it only once this time),
     # there is nothing else need to be done.  If you want to record
     # this as a new resolution, you'd get rid of the old one and
     # record this one.
     $ git rerere forget builtin/mv.c
     $ git rerere

It's taken some time to investigate on our end, but it appears that the issue we're seeing is particular to git-rebase.

Consider a run using git-merge, which works perfectly as you describe:
    # Let's set up our conflict; most output here elided for brevity.
    $ git init
    $ echo aaa >file
    $ git add file
    $ git commit -ambase
    $ git branch feature
    $ echo bbb >file
    $ git commit -amremote
    $ git switch feature
    $ echo ccc >file
    $ git commit -amlocal
    $ git --no-pager log --oneline --graph --all
    * 6b33f42 (HEAD -> feature) local
    | * 7e189f6 (main) remote
    |/
    * c5901f5 base
    # Now for the fun part!
    $ git config rerere.enabled true
    $ git merge main
    Auto-merging file
    CONFLICT (content): Merge conflict in file
    Recorded preimage for 'file'
    Automatic merge failed; fix conflicts and then commit the result.
    $ echo 'bad merge' >file
    $ git commit -ammerge
    Recorded resolution for 'file'.
    [feature 75d45f0] merge
    # Ack! That merge was bad. Let's try that again.
    $ git reset --hard @^
    HEAD is now at 6b33f42 local
    $ git merge main
    Auto-merging file
    CONFLICT (content): Merge conflict in file
    Resolved 'file' using previous resolution.
    Automatic merge failed; fix conflicts and then commit the result.
    # Your method to correct this single bad merge works flawlessly:
    $ git checkout --merge file
    Recreated 1 merge conflict
    $ git rerere forget file
    Updated preimage for 'file'
    Forgot resolution for 'file'
    $ echo 'good merge' >file
    $ git commit -ammerge
    Recorded resolution for 'file'.
    [feature 1770541] merge
Let's compare this with git-rebase:
    # Same setup as before
    $ git init
    $ echo aaa >file
    $ git add file
    $ git commit -ambase
    $ git branch feature
    $ echo bbb >file
    $ git commit -amremote
    $ git switch feature
    $ echo ccc >file
    $ git commit -amlocal
    $ git --no-pager log --oneline --graph --all
    * b4d7aeb (HEAD -> feature) local
    | * 2a0978d (main) remote
    |/
    * 91140a6 base
    # Now for the fun part! Just like before, but we're going to use
    # git-rebase instead of git-merge.
    $ git config rerere.enabled true
    $ git rebase main
    Auto-merging file
    CONFLICT (content): Merge conflict in file
    error: could not apply b4d7aeb... local
    hint: Resolve all conflicts manually, mark them as resolved with
    hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
    hint: You can instead skip this commit: run "git rebase --skip".
    hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
    Recorded preimage for 'file'
    Could not apply b4d7aeb... local
    $ echo 'bad merge' >file
    $ git add file
    $ EDITOR=: git rebase --continue
    file: needs merge
    You must edit all merge conflicts and then
    mark them as resolved using git add
    $ git rebase --abort
    $ git rebase main
    Auto-merging file
    CONFLICT (content): Merge conflict in file
    error: could not apply b4d7aeb... local
    hint: Resolve all conflicts manually, mark them as resolved with
    hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
    hint: You can instead skip this commit: run "git rebase --skip".
    hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
    Recorded preimage for 'file'
    Could not apply b4d7aeb... local
    $ git checkout --merge .
    Recreated 1 merge conflict
    $ git rerere forget .
    error: no remembered resolution for 'file'
    $ echo 'good merge' >file
    $ EDITOR=: git rebase --continue
    file: needs merge
    You must edit all merge conflicts and then
    mark them as resolved using git add
Is this a bug?

-- Sean Allred

Previous: Junio C HamanoNext: Sean Allred
Message 5 of 7 in “What's the recommendation for forgetting all rerere's records?”
  1. Sean AllredDec 6, 2023
  2. Junio C HamanoDec 8, 2023
  3. Sean AllredDec 15, 2023
  4. Junio C HamanoDec 15, 2023
  5. Sean AllredJan 3, 2024
  6. Sean AllredJan 3, 2024
  7. Sean AllredFeb 10, 2024

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.