mbox series

[0/2] Demonstrate and fix a rebase --autostash bug with dirty submodules

Message ID pull.56.git.gitgitgadget@gmail.com (mailing list archive)
Headers show
Series Demonstrate and fix a rebase --autostash bug with dirty submodules | expand

Message

Bruce Perry via GitGitGadget Oct. 23, 2018, 7:57 p.m. UTC
This bug report came in via Git for Windows (already with version 2.19.0,
but I misread the reporter's enthusiasm to take matters into his own hands).

The culprit is, in a nutshell, that the built-in rebase tries to run git
stash only when the worktree is dirty, but it includes submodules in that.
However, git stash cannot do anything about submodules, and if the only
changes are in submodules, then it won't even give us back an OID, and the
built-in rebase acts surprised.

The solution is easy: simply exclude the submodules from the question
whether the worktree is dirty.

What is surprisingly not simple is to get the regression test right. For
that reason, and because I firmly believe that it is easier to verify a fix
for a regression when the regression test is introduced separately (i.e.
making it simple to verify that there is a regression), I really want to
keep the first patch separate from the second one.

Since this bug concerns the built-in rebase, I based the patches on top of 
next.

Johannes Schindelin (2):
  rebase --autostash: demonstrate a problem with dirty submodules
  rebase --autostash: fix issue with dirty submodules

 builtin/rebase.c            |  2 +-
 t/t3420-rebase-autostash.sh | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)


base-commit: 209f214ca4ae4e301fc32e59ab26f937082f3ea3
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-56%2Fdscho%2Ffix-built-in-rebase-autostash-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-56/dscho/fix-built-in-rebase-autostash-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/56

Comments

Ævar Arnfjörð Bjarmason Nov. 6, 2018, 1:59 p.m. UTC | #1
On Tue, Oct 23 2018, Johannes Schindelin via GitGitGadget wrote:

> Johannes Schindelin (2):
>   rebase --autostash: demonstrate a problem with dirty submodules
>   rebase --autostash: fix issue with dirty submodules
>
>  builtin/rebase.c            |  2 +-
>  t/t3420-rebase-autostash.sh | 10 ++++++++++
>  2 files changed, 11 insertions(+), 1 deletion(-)

There's another bug with rebase.autoStash in master (and next/pu) but
not v2.19.0. I tried to bisect bit it just comes down to 5541bd5b8f
("rebase: default to using the builtin rebase", 2018-08-08).

Credit to a co-worker of mine who wishes to remain anonymous for
discovering this. I narrowed down his test-case to (any repo will do):
    
    (
        rm -rf /tmp/todo &&
        git clone --single-branch --no-tags --branch=todo https://github.com/git/git.git /tmp/todo &&
        cd /tmp/todo &&
        rm Make &&
        git rev-parse --abbrev-ref HEAD &&
        git -c rebase.autoStash=true -c pull.rebase=true pull &&
        if test $(git rev-parse --abbrev-ref HEAD) != 'todo'
        then
            echo 'On detached head!' &&
            git status &&
            exit 1
        else
            echo 'We are still on our todo branch!'
        fi
    )
Jeff King Nov. 6, 2018, 7:32 p.m. UTC | #2
On Tue, Nov 06, 2018 at 02:59:43PM +0100, Ævar Arnfjörð Bjarmason wrote:

> 
> On Tue, Oct 23 2018, Johannes Schindelin via GitGitGadget wrote:
> 
> > Johannes Schindelin (2):
> >   rebase --autostash: demonstrate a problem with dirty submodules
> >   rebase --autostash: fix issue with dirty submodules
> >
> >  builtin/rebase.c            |  2 +-
> >  t/t3420-rebase-autostash.sh | 10 ++++++++++
> >  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> There's another bug with rebase.autoStash in master (and next/pu) but
> not v2.19.0. I tried to bisect bit it just comes down to 5541bd5b8f
> ("rebase: default to using the builtin rebase", 2018-08-08).

That's just flipping the config default. If you add "-c
rebase.usebuiltin=true" to your invocation here:

>         git -c rebase.autoStash=true -c pull.rebase=true pull &&

you can bisect further. However, the results weren't super useful, as I
had to skip a bunch of commits (ones that did die("TODO") or just
complained that the working tree wasn't clean; if you treat the latter
as "bad", then it just bisects to e0333e5c63 (builtin rebase: require a
clean worktree, 2018-09-04).

-Peff
Johannes Schindelin Nov. 7, 2018, 1:50 p.m. UTC | #3
Hi Ævar,

On Tue, 6 Nov 2018, Ævar Arnfjörð Bjarmason wrote:

> 
> On Tue, Oct 23 2018, Johannes Schindelin via GitGitGadget wrote:
> 
> > Johannes Schindelin (2):
> >   rebase --autostash: demonstrate a problem with dirty submodules
> >   rebase --autostash: fix issue with dirty submodules
> >
> >  builtin/rebase.c            |  2 +-
> >  t/t3420-rebase-autostash.sh | 10 ++++++++++
> >  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> There's another bug with rebase.autoStash in master (and next/pu) but
> not v2.19.0. I tried to bisect bit it just comes down to 5541bd5b8f
> ("rebase: default to using the builtin rebase", 2018-08-08).
> 
> Credit to a co-worker of mine who wishes to remain anonymous for
> discovering this. I narrowed down his test-case to (any repo will do):
>     
>     (
>         rm -rf /tmp/todo &&
>         git clone --single-branch --no-tags --branch=todo https://github.com/git/git.git /tmp/todo &&
>         cd /tmp/todo &&
>         rm Make &&
>         git rev-parse --abbrev-ref HEAD &&
>         git -c rebase.autoStash=true -c pull.rebase=true pull &&
>         if test $(git rev-parse --abbrev-ref HEAD) != 'todo'
>         then
>             echo 'On detached head!' &&
>             git status &&
>             exit 1
>         else
>             echo 'We are still on our todo branch!'
>         fi
>     )

I found the culprit. Patch forthcoming,
Dscho