{"thread":{"id":"49653","subject":"[PATCH 0/2] Demonstrate and fix a rebase --autostash bug with dirty submodules","startedAt":"2018-10-23T19:57:17Z","lastAt":"2018-11-07T13:50:10Z","messageCount":6,"participants":["Johannes Schindelin via GitGitGadget","Ævar Arnfjörð Bjarmason","Jeff King","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"361319","messageId":"pull.56.git.gitgitgadget@gmail.com","threadId":"49653","inReplyTo":null,"subject":"[PATCH 0/2] Demonstrate and fix a rebase --autostash bug with dirty submodules","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-10-23T19:57:14Z","receivedAt":"2018-10-23T19:57:17Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"This bug report came in via Git for Windows (already with version 2.19.0,\nbut I misread the reporter's enthusiasm to take matters into his own hands).\n\nThe culprit is, in a nutshell, that the built-in rebase tries to run git\nstash only when the worktree is dirty, but it includes submodules in that.\nHowever, git stash cannot do anything about submodules, and if the only\nchanges are in submodules, then it won't even give us back an OID, and the\nbuilt-in rebase acts surprised.\n\nThe solution is easy: simply exclude the submodules from the question\nwhether the worktree is dirty.\n\nWhat is surprisingly not simple is to get the regression test right. For\nthat reason, and because I firmly believe that it is easier to verify a fix\nfor a regression when the regression test is introduced separately (i.e.\nmaking it simple to verify that there is a regression), I really want to\nkeep the first patch separate from the second one.\n\nSince this bug concerns the built-in rebase, I based the patches on top of \nnext.\n\nJohannes Schindelin (2):\n  rebase --autostash: demonstrate a problem with dirty submodules\n  rebase --autostash: fix issue with dirty submodules\n\n builtin/rebase.c            |  2 +-\n t/t3420-rebase-autostash.sh | 10 ++++++++++\n 2 files changed, 11 insertions(+), 1 deletion(-)\n\n\nbase-commit: 209f214ca4ae4e301fc32e59ab26f937082f3ea3\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-56%2Fdscho%2Ffix-built-in-rebase-autostash-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-56/dscho/fix-built-in-rebase-autostash-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/56\n-- \ngitgitgadget\n"},{"id":"361320","messageId":"6d9ff59733e632f69ff414baaaa084dfd461b7e1.1540324633.git.gitgitgadget@gmail.com","threadId":"49653","inReplyTo":"pull.56.git.gitgitgadget@gmail.com","subject":"[PATCH 1/2] rebase --autostash: demonstrate a problem with dirty submodules","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-10-23T19:57:16Z","receivedAt":"2018-10-23T19:57:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nIt has been reported that dirty submodules cause problems with the\nbuilt-in rebase when it is asked to autostash. The symptom is:\n\n\tfatal: Unexpected stash response: ''\n\nThis patch adds a regression test that demonstrates that bug.\n\nOriginal report: https://github.com/git-for-windows/git/issues/1820\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n t/t3420-rebase-autostash.sh | 10 ++++++++++\n 1 file changed, 10 insertions(+)\n\ndiff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh\nindex 0c4eefec7..7eb9f9041 100755\n--- a/t/t3420-rebase-autostash.sh\n+++ b/t/t3420-rebase-autostash.sh\n@@ -351,4 +351,14 @@ test_expect_success 'autostash is saved on editor failure with conflict' '\n \ttest_cmp expected file0\n '\n \n+test_expect_failure 'autostash with dirty submodules' '\n+\ttest_when_finished \"git reset --hard && git checkout master\" &&\n+\tgit checkout -b with-submodule &&\n+\tgit submodule add ./ sub &&\n+\ttest_tick &&\n+\tgit commit -m add-submodule &&\n+\techo changed >sub/file0 &&\n+\tgit rebase -i --autostash HEAD\n+'\n+\n test_done\n-- \ngitgitgadget\n\n"},{"id":"361321","messageId":"ee4b715284c95698fd1b68dc4b1a2d38056df56b.1540324633.git.gitgitgadget@gmail.com","threadId":"49653","inReplyTo":"pull.56.git.gitgitgadget@gmail.com","subject":"[PATCH 2/2] rebase --autostash: fix issue with dirty submodules","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-10-23T19:57:17Z","receivedAt":"2018-10-23T19:57:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nSince we cannot stash dirty submodules, there is no use in requiring\nthem to be clean (or stash them when they are not).\n\nThis brings the built-in rebase in line with the previous, scripted\nversion, which also did not care about dirty submodules (but it was\nadmittedly not very easy to figure that out).\n\nThis fixes https://github.com/git-for-windows/git/issues/1820\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/rebase.c            | 2 +-\n t/t3420-rebase-autostash.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 09f55bfb9..1dd24301f 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -1349,7 +1349,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)\n \t\t\tupdate_index_if_able(&the_index, &lock_file);\n \t\trollback_lock_file(&lock_file);\n \n-\t\tif (has_unstaged_changes(0) || has_uncommitted_changes(0)) {\n+\t\tif (has_unstaged_changes(1) || has_uncommitted_changes(1)) {\n \t\t\tconst char *autostash =\n \t\t\t\tstate_dir_path(\"autostash\", &options);\n \t\t\tstruct child_process stash = CHILD_PROCESS_INIT;\ndiff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh\nindex 7eb9f9041..f355c6825 100755\n--- a/t/t3420-rebase-autostash.sh\n+++ b/t/t3420-rebase-autostash.sh\n@@ -351,7 +351,7 @@ test_expect_success 'autostash is saved on editor failure with conflict' '\n \ttest_cmp expected file0\n '\n \n-test_expect_failure 'autostash with dirty submodules' '\n+test_expect_success 'autostash with dirty submodules' '\n \ttest_when_finished \"git reset --hard && git checkout master\" &&\n \tgit checkout -b with-submodule &&\n \tgit submodule add ./ sub &&\n-- \ngitgitgadget\n"},{"id":"362572","messageId":"878t2671dc.fsf@evledraar.gmail.com","threadId":"49653","inReplyTo":"pull.56.git.gitgitgadget@gmail.com","subject":"Regression in rebase-in-C with rebase.autoStash=true","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2018-11-06T13:59:43Z","receivedAt":"2018-11-06T13:59:49Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Oct 23 2018, Johannes Schindelin via GitGitGadget wrote:\n\n> Johannes Schindelin (2):\n>   rebase --autostash: demonstrate a problem with dirty submodules\n>   rebase --autostash: fix issue with dirty submodules\n>\n>  builtin/rebase.c            |  2 +-\n>  t/t3420-rebase-autostash.sh | 10 ++++++++++\n>  2 files changed, 11 insertions(+), 1 deletion(-)\n\nThere's another bug with rebase.autoStash in master (and next/pu) but\nnot v2.19.0. I tried to bisect bit it just comes down to 5541bd5b8f\n(\"rebase: default to using the builtin rebase\", 2018-08-08).\n\nCredit to a co-worker of mine who wishes to remain anonymous for\ndiscovering this. I narrowed down his test-case to (any repo will do):\n    \n    (\n        rm -rf /tmp/todo &&\n        git clone --single-branch --no-tags --branch=todo https://github.com/git/git.git /tmp/todo &&\n        cd /tmp/todo &&\n        rm Make &&\n        git rev-parse --abbrev-ref HEAD &&\n        git -c rebase.autoStash=true -c pull.rebase=true pull &&\n        if test $(git rev-parse --abbrev-ref HEAD) != 'todo'\n        then\n            echo 'On detached head!' &&\n            git status &&\n            exit 1\n        else\n            echo 'We are still on our todo branch!'\n        fi\n    )\n"},{"id":"362602","messageId":"20181106193235.GA8902@sigill.intra.peff.net","threadId":"49653","inReplyTo":"878t2671dc.fsf@evledraar.gmail.com","subject":"Re: Regression in rebase-in-C with rebase.autoStash=true","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2018-11-06T19:32:36Z","receivedAt":"2018-11-06T19:32:39Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Nov 06, 2018 at 02:59:43PM +0100, Ævar Arnfjörð Bjarmason wrote:\n\n> \n> On Tue, Oct 23 2018, Johannes Schindelin via GitGitGadget wrote:\n> \n> > Johannes Schindelin (2):\n> >   rebase --autostash: demonstrate a problem with dirty submodules\n> >   rebase --autostash: fix issue with dirty submodules\n> >\n> >  builtin/rebase.c            |  2 +-\n> >  t/t3420-rebase-autostash.sh | 10 ++++++++++\n> >  2 files changed, 11 insertions(+), 1 deletion(-)\n> \n> There's another bug with rebase.autoStash in master (and next/pu) but\n> not v2.19.0. I tried to bisect bit it just comes down to 5541bd5b8f\n> (\"rebase: default to using the builtin rebase\", 2018-08-08).\n\nThat's just flipping the config default. If you add \"-c\nrebase.usebuiltin=true\" to your invocation here:\n\n>         git -c rebase.autoStash=true -c pull.rebase=true pull &&\n\nyou can bisect further. However, the results weren't super useful, as I\nhad to skip a bunch of commits (ones that did die(\"TODO\") or just\ncomplained that the working tree wasn't clean; if you treat the latter\nas \"bad\", then it just bisects to e0333e5c63 (builtin rebase: require a\nclean worktree, 2018-09-04).\n\n-Peff\n"},{"id":"362658","messageId":"nycvar.QRO.7.76.6.1811071436290.39@tvgsbejvaqbjf.bet","threadId":"49653","inReplyTo":"878t2671dc.fsf@evledraar.gmail.com","subject":"Re: Regression in rebase-in-C with rebase.autoStash=true","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-11-07T13:50:00Z","receivedAt":"2018-11-07T13:50:10Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Ævar,\n\nOn Tue, 6 Nov 2018, Ævar Arnfjörð Bjarmason wrote:\n\n> \n> On Tue, Oct 23 2018, Johannes Schindelin via GitGitGadget wrote:\n> \n> > Johannes Schindelin (2):\n> >   rebase --autostash: demonstrate a problem with dirty submodules\n> >   rebase --autostash: fix issue with dirty submodules\n> >\n> >  builtin/rebase.c            |  2 +-\n> >  t/t3420-rebase-autostash.sh | 10 ++++++++++\n> >  2 files changed, 11 insertions(+), 1 deletion(-)\n> \n> There's another bug with rebase.autoStash in master (and next/pu) but\n> not v2.19.0. I tried to bisect bit it just comes down to 5541bd5b8f\n> (\"rebase: default to using the builtin rebase\", 2018-08-08).\n> \n> Credit to a co-worker of mine who wishes to remain anonymous for\n> discovering this. I narrowed down his test-case to (any repo will do):\n>     \n>     (\n>         rm -rf /tmp/todo &&\n>         git clone --single-branch --no-tags --branch=todo https://github.com/git/git.git /tmp/todo &&\n>         cd /tmp/todo &&\n>         rm Make &&\n>         git rev-parse --abbrev-ref HEAD &&\n>         git -c rebase.autoStash=true -c pull.rebase=true pull &&\n>         if test $(git rev-parse --abbrev-ref HEAD) != 'todo'\n>         then\n>             echo 'On detached head!' &&\n>             git status &&\n>             exit 1\n>         else\n>             echo 'We are still on our todo branch!'\n>         fi\n>     )\n\nI found the culprit. Patch forthcoming,\nDscho"}]}