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

git-rebase-todo gets popped prematurely

From
Phil Hord <hordp@cisco.com>
Date
Apr 2, 2014, 22:37 UTC
Message-ID
<533C913C.20106@cisco.com>

During a 'git rebase --continue', I got an error about having left a file in place which the next commit intended to add as new. Stupid me.

So I rm'ed the file and tried again. This time, git rebase --continue succeeded. But it accidentally left out the next commit in my rebase-todo.

I looked in the code and it seems that when the "pick" returns an error, rebase--interactive stops and lets the user clean up. But it assumes the index already tracks a conflicted merge, and so it removes the commit from the todo list. In this case, however, the conflicted merge was avoided by detecting it in advance. The result is that the "would be overwritten" conflict evicts the entire commit from the rebase action.

I think the code needs to detect the difference between "merge failed; conflicted index" and "merge failed; no change". I think I can do this with 'git-status -s -uno', maybe. But I haven't tried it yet and it feels like I'm missing a case or two also.

I tried to bisect this to some specific change, but it fails the same way as far back as 1.6.5.

Test script follows in case anyone has a better idea how to approach this and wants to understand it better.

    #!/bin/sh
    set -x
    git --version
    rm -rf baz
    git init baz && cd baz
    echo initial>initial && git add initial && git commit -minitial
    echo foo>foo && git add foo && git commit -mfoo
    echo bar>bar && git add bar && git commit -mbar
    git log --oneline
    GIT_EDITOR='sed -i -e s/^pick/edit/ -e /^#/d' git rebase -i HEAD^^
    touch bar
    git rebase --continue
    rm bar
    git rebase --continue
    git log --oneline

And the tail of the output (note the missing "bar" commit even though "Successfully rebased"):

    + git log --oneline
    fcc9b6e bar
    8121f15 foo
    a521fa1 initial
    + GIT_EDITOR='sed -i -e s/^pick/edit/ -e /^#/d'
    + git rebase -i 'HEAD^^'
    Stopped at 8121f1593ea5c66dc7e9af7719100c1fcf4ab721... foo
    You can amend the commit now, with
        git commit --amend
    Once you are satisfied with your changes, run
        git rebase --continue
    + touch bar
    + git rebase --continue
    error: The following untracked working tree files would be
    overwritten by merge:
        bar
    Please move or remove them before you can merge.
    Aborting
    Could not apply fcc9b6ef2941e870f88362edbe0f1078cebb20e5... bar
    + rm bar
    + git rebase --continue
    Successfully rebased and updated refs/heads/master.
    + git log --oneline
    8121f15 foo
    a521fa1 initial
Next: Fabian Ruch
Message 1 of 13 in “git-rebase-todo gets popped prematurely”
  1. Phil HordApr 2, 2014
  2. 1/3 sequencer: Signal failed ff as an aborted, not a conflicted mergeFabian Ruch, May 26, 2014
  3. Junio C HamanoMay 27, 2014
  4. Fabian RuchJun 9, 2014
  5. Junio C HamanoJun 10, 2014
  6. Phil HordJun 10, 2014
  7. Junio C HamanoJun 10, 2014
  8. 2/3 rebase -i: Reschedule tasks that failed before the index was touchedFabian Ruch, May 26, 2014
  9. Michael HaggertyMay 27, 2014
  10. Phil HordMay 27, 2014
  11. 3/3 tests: Add 'rebase -i commits that overwrite untracked files'Fabian Ruch, May 26, 2014
  12. Michael HaggertyMay 27, 2014
  13. Junio C HamanoMay 27, 2014

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.