mhagger / git-imerge

Incremental merge for git
GNU General Public License v2.0
2.7k stars 126 forks source link

Stuck in a merge, imerge crashes when attempting to continue #199

Open vmsh0 opened 1 year ago

vmsh0 commented 1 year ago

Hi,

git-imerge crashes when attempting to continue an incremental merge. The crash looks as follows:

contiki-sensinode on   (git)-[0e5ccf2f357f39c301939421a7017aff59fccb7c|merge]- [=✘»!+?] took 9s
➜ git imerge continue
Attempting automerge of 1-1145...failure.
Attempting automerge of 1-230...success.
error: Entry 'tools/cooja/java/org/contikios/cooja/util/CCITT_CRC.java' not uptodate. Cannot merge.
fatal: Could not reset index file to revision 'HEAD'.
Attempting automerge of 1-688...Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 661, in automerge
    call_silently(cmd)
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 230, in call_silently
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', '-c', 'rerere.enabled=false', 'merge', '61a5d234eb659234e1ef6db1026b88b0a8643c1e']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/git-imerge", line 33, in <module>
    sys.exit(load_entry_point('git-imerge==1.2.0', 'console_scripts', 'git-imerge')())
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 4357, in climain
    main(sys.argv[1:])
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 4338, in main
    cmd_continue(parser, options)
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 3847, in cmd_continue
    merge_state.auto_complete_frontier()
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 2823, in auto_complete_frontier
    frontier.auto_expand()
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 2114, in auto_expand
    merge_frontier = BlockwiseMergeFrontier.initiate_merge(block)
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 1866, in initiate_merge
    block, list(find_frontier_blocks(block)),
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 1367, in find_frontier_blocks
    i2 = find_first_false(
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 212, in find_first_false
    if f(mid):
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 1368, in <lambda>
    lambda i: block.is_mergeable(i1, i),
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 2321, in is_mergeable
    self.git.automerge(self[i1, 0].sha1, self[0, i2].sha1)
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 663, in automerge
    self.abort_merge()
  File "/usr/lib/python3.10/site-packages/gitimerge.py", line 910, in abort_merge
    check_call(['git', 'reset', '--merge'])
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['git', 'reset', '--merge']' returned non-zero exit status 128.

git status after the crash (very long, sorry for the external link): https://paste.sr.ht/blob/b466f3ca90050fbd8e2cf23cf7af716096c1ce46

Is it possible to recover from this situation? I've been working on this merge for a few days now, my current priority is not to lose the work I've done so far.

vmsh0 commented 1 year ago

In case it might be useful, this is the output of git reset --merge right after the crash:

contiki-sensinode on   (git)-[0e5ccf2f357f39c301939421a7017aff59fccb7c|merge]- [=✘»!+?]
➜ git reset --merge
error: Entry 'tools/cooja/java/org/contikios/cooja/util/CCITT_CRC.java' not uptodate. Cannot merge.
fatal: Could not reset index file to revision 'HEAD'.
vmsh0 commented 1 year ago

I suspect that the .gitattributes file that has a conflict for the current merge might have something to do with the issue:

<<<<<<< HEAD
.gitignore       export-ignore
.gitattributes   export-ignore
=======
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto whitespace=trailing-space

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
*.java text

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
>>>>>>> 61a5d234eb659234e1ef6db1026b88b0a8643c1e

However, even changing it and trying to continue the merge results in the crash happening again and the .gitattributes file being restored to the version above.