[PATCH 0/3] Fix a couple of edge cases in autostash

DORMANTno replies

4 messages, 1 author, 2016-06-15 · open the first message on its own page

[PATCH 0/3] Fix a couple of edge cases in autostash

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:57:44

Hi,

I apologize for having missed these two trivial cases in the original
series.

Ramkumar Ramachandra (3):
  rebase: guard against missing files in read_basic_state()
  rebase: finish_rebase() in fast-forward rebase
  rebase: finish_rebase() in noop rebase

 git-rebase.sh               |  4 ++++
 t/t3420-rebase-autostash.sh | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)

-- 
1.8.3.1.381.gf08dd97.dirty

[PATCH 1/3] rebase: guard against missing files in read_basic_state()

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:57:44

Signed-off-by: Ramkumar Ramachandra <redacted>
---
 git-rebase.sh | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/git-rebase.sh b/git-rebase.sh
index d0c11a9..2122fe0 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -84,6 +84,8 @@ keep_empty=
 test "$(git config --bool rebase.autosquash)" = "true" && autosquash=t
 
 read_basic_state () {
+	test -f "$state_dir/head-name" &&
+	test -f "$state_dir/onto" &&
 	head_name=$(cat "$state_dir"/head-name) &&
 	onto=$(cat "$state_dir"/onto) &&
 	# We always write to orig-head, but interactive rebase used to write to
-- 
1.8.3.1.381.gf08dd97.dirty

[PATCH 2/3] rebase: finish_rebase() in fast-forward rebase

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:57:44

In the following case

  $ git rebase master
  Fast-forwarded autostash-fix to master.

The autostash is not applied automatically, because this codepath
forgets to call finish_rebase().  Fix this.  Also add a test to guard
against regressions.

Signed-off-by: Ramkumar Ramachandra <redacted>
---
 git-rebase.sh               |  1 +
 t/t3420-rebase-autostash.sh | 11 +++++++++++
 2 files changed, 12 insertions(+)
diff --git a/git-rebase.sh b/git-rebase.sh
index 2122fe0..154d4be 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -579,6 +579,7 @@ if test "$mb" = "$orig_head"
 then
 	say "$(eval_gettext "Fast-forwarded \$branch_name to \$onto_name.")"
 	move_to_original_branch
+	finish_rebase
 	exit 0
 fi
 
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 479cbb2..1bde007 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -141,6 +141,17 @@ testrebase() {
 	'
 }
 
+test_expect_success "rebase: fast-forward rebase" '
+	test_config rebase.autostash true &&
+	git reset --hard &&
+	git checkout -b behind-feature-branch feature-branch~1 &&
+	test_when_finished git branch -D behind-feature-branch &&
+	echo dirty >>file1 &&
+	git rebase feature-branch &&
+	grep dirty file1 &&
+	git checkout feature-branch
+'
+
 testrebase "" .git/rebase-apply
 testrebase " --merge" .git/rebase-merge
 testrebase " --interactive" .git/rebase-merge
-- 
1.8.3.1.381.gf08dd97.dirty

[PATCH 3/3] rebase: finish_rebase() in noop rebase

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:57:44

In the following case

  $ git rebase master
  Current branch autostash-fix is up to date.

the autostash is not applied automatically, because this codepath
forgets to call finish_rebase().  Fix this.  Also add a test to guard
against regressions.

Signed-off-by: Ramkumar Ramachandra <redacted>
---
 git-rebase.sh               |  1 +
 t/t3420-rebase-autostash.sh | 11 +++++++++++
 2 files changed, 12 insertions(+)
diff --git a/git-rebase.sh b/git-rebase.sh
index 154d4be..2d5c2bd 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -547,6 +547,7 @@ then
 		# Lazily switch to the target branch if needed...
 		test -z "$switch_to" || git checkout "$switch_to" --
 		say "$(eval_gettext "Current branch \$branch_name is up to date.")"
+		finish_rebase
 		exit 0
 	else
 		say "$(eval_gettext "Current branch \$branch_name is up to date, rebase forced.")"
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 1bde007..90eb264 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -152,6 +152,17 @@ test_expect_success "rebase: fast-forward rebase" '
 	git checkout feature-branch
 '
 
+test_expect_success "rebase: noop rebase" '
+	test_config rebase.autostash true &&
+	git reset --hard &&
+	git checkout -b same-feature-branch feature-branch &&
+	test_when_finished git branch -D same-feature-branch &&
+	echo dirty >>file1 &&
+	git rebase feature-branch &&
+	grep dirty file1 &&
+	git checkout feature-branch
+'
+
 testrebase "" .git/rebase-apply
 testrebase " --merge" .git/rebase-merge
 testrebase " --interactive" .git/rebase-merge
-- 
1.8.3.1.381.gf08dd97.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help