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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(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@xxxxxxxxx> 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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux