git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
* [PATCH 0/2] Demonstrate and fix a rebase --autostash bug with dirty submodules
@ 2018-10-23 19:57 Johannes Schindelin via GitGitGadget
  2018-10-23 19:57 ` [PATCH 1/2] rebase --autostash: demonstrate a problem " Johannes Schindelin via GitGitGadget
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-10-23 19:57 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

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
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] rebase --autostash: demonstrate a problem with dirty submodules
  2018-10-23 19:57 [PATCH 0/2] Demonstrate and fix a rebase --autostash bug with dirty submodules Johannes Schindelin via GitGitGadget
@ 2018-10-23 19:57 ` " Johannes Schindelin via GitGitGadget
  2018-10-23 19:57 ` [PATCH 2/2] rebase --autostash: fix issue " Johannes Schindelin via GitGitGadget
  2018-11-06 13:59 ` Regression in rebase-in-C with rebase.autoStash=true Ævar Arnfjörð Bjarmason
  2 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-10-23 19:57 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

It has been reported that dirty submodules cause problems with the
built-in rebase when it is asked to autostash. The symptom is:

	fatal: Unexpected stash response: ''

This patch adds a regression test that demonstrates that bug.

Original report: https://github.com/git-for-windows/git/issues/1820

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 t/t3420-rebase-autostash.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 0c4eefec7..7eb9f9041 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -351,4 +351,14 @@ test_expect_success 'autostash is saved on editor failure with conflict' '
 	test_cmp expected file0
 '
 
+test_expect_failure 'autostash with dirty submodules' '
+	test_when_finished "git reset --hard && git checkout master" &&
+	git checkout -b with-submodule &&
+	git submodule add ./ sub &&
+	test_tick &&
+	git commit -m add-submodule &&
+	echo changed >sub/file0 &&
+	git rebase -i --autostash HEAD
+'
+
 test_done
-- 
gitgitgadget


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] rebase --autostash: fix issue with dirty submodules
  2018-10-23 19:57 [PATCH 0/2] Demonstrate and fix a rebase --autostash bug with dirty submodules Johannes Schindelin via GitGitGadget
  2018-10-23 19:57 ` [PATCH 1/2] rebase --autostash: demonstrate a problem " Johannes Schindelin via GitGitGadget
@ 2018-10-23 19:57 ` " Johannes Schindelin via GitGitGadget
  2018-11-06 13:59 ` Regression in rebase-in-C with rebase.autoStash=true Ævar Arnfjörð Bjarmason
  2 siblings, 0 replies; 6+ messages in thread
From: Johannes Schindelin via GitGitGadget @ 2018-10-23 19:57 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Johannes Schindelin

From: Johannes Schindelin <johannes.schindelin@gmx.de>

Since we cannot stash dirty submodules, there is no use in requiring
them to be clean (or stash them when they are not).

This brings the built-in rebase in line with the previous, scripted
version, which also did not care about dirty submodules (but it was
admittedly not very easy to figure that out).

This fixes https://github.com/git-for-windows/git/issues/1820

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 builtin/rebase.c            | 2 +-
 t/t3420-rebase-autostash.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/rebase.c b/builtin/rebase.c
index 09f55bfb9..1dd24301f 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -1349,7 +1349,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			update_index_if_able(&the_index, &lock_file);
 		rollback_lock_file(&lock_file);
 
-		if (has_unstaged_changes(0) || has_uncommitted_changes(0)) {
+		if (has_unstaged_changes(1) || has_uncommitted_changes(1)) {
 			const char *autostash =
 				state_dir_path("autostash", &options);
 			struct child_process stash = CHILD_PROCESS_INIT;
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 7eb9f9041..f355c6825 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -351,7 +351,7 @@ test_expect_success 'autostash is saved on editor failure with conflict' '
 	test_cmp expected file0
 '
 
-test_expect_failure 'autostash with dirty submodules' '
+test_expect_success 'autostash with dirty submodules' '
 	test_when_finished "git reset --hard && git checkout master" &&
 	git checkout -b with-submodule &&
 	git submodule add ./ sub &&
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Regression in rebase-in-C with rebase.autoStash=true
  2018-10-23 19:57 [PATCH 0/2] Demonstrate and fix a rebase --autostash bug with dirty submodules Johannes Schindelin via GitGitGadget
  2018-10-23 19:57 ` [PATCH 1/2] rebase --autostash: demonstrate a problem " Johannes Schindelin via GitGitGadget
  2018-10-23 19:57 ` [PATCH 2/2] rebase --autostash: fix issue " Johannes Schindelin via GitGitGadget
@ 2018-11-06 13:59 ` Ævar Arnfjörð Bjarmason
  2018-11-06 19:32   ` Jeff King
  2018-11-07 13:50   ` Johannes Schindelin
  2 siblings, 2 replies; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-11-06 13:59 UTC (permalink / raw)
  To: Johannes Schindelin via GitGitGadget; +Cc: git, Junio C Hamano, Pratik Karki


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
    )

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Regression in rebase-in-C with rebase.autoStash=true
  2018-11-06 13:59 ` Regression in rebase-in-C with rebase.autoStash=true Ævar Arnfjörð Bjarmason
@ 2018-11-06 19:32   ` Jeff King
  2018-11-07 13:50   ` Johannes Schindelin
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff King @ 2018-11-06 19:32 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Johannes Schindelin via GitGitGadget, git, Junio C Hamano, Pratik Karki

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Regression in rebase-in-C with rebase.autoStash=true
  2018-11-06 13:59 ` Regression in rebase-in-C with rebase.autoStash=true Ævar Arnfjörð Bjarmason
  2018-11-06 19:32   ` Jeff King
@ 2018-11-07 13:50   ` Johannes Schindelin
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2018-11-07 13:50 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Johannes Schindelin via GitGitGadget, git, Junio C Hamano, Pratik Karki

[-- Attachment #1: Type: text/plain, Size: 1408 bytes --]

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23 19:57 [PATCH 0/2] Demonstrate and fix a rebase --autostash bug with dirty submodules Johannes Schindelin via GitGitGadget
2018-10-23 19:57 ` [PATCH 1/2] rebase --autostash: demonstrate a problem " Johannes Schindelin via GitGitGadget
2018-10-23 19:57 ` [PATCH 2/2] rebase --autostash: fix issue " Johannes Schindelin via GitGitGadget
2018-11-06 13:59 ` Regression in rebase-in-C with rebase.autoStash=true Ævar Arnfjörð Bjarmason
2018-11-06 19:32   ` Jeff King
2018-11-07 13:50   ` Johannes Schindelin

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox