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

[RFC PATCH 4/5] Add tests for rebase --continue --autostage

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Jul 26, 2017, 10:27 UTC
Message-ID
<20170726102720.15274-5-phillip.wood@talktalk.net>
In-Reply-To
<20170726102720.15274-1-phillip.wood@talktalk.net>
From: Phillip Wood <phillip.wood@dunelm.org.uk>

Make sure that --autostage stages any changes and fails if there are merge markers in the file to be staged.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 t/t3418-rebase-continue.sh | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh
index 4428b9086e8bcb383df801834d0de323f316f4fa..4e71e5d5c2f26866cd5d32bfea445f899398d6c9 100755
--- a/t/t3418-rebase-continue.sh
+++ b/t/t3418-rebase-continue.sh
@@ -14,7 +14,6 @@ test_expect_success 'setup' '
 
 	git checkout -b topic HEAD^ &&
 	test_commit "commit-new-file-F2-on-topic-branch" F2 22 &&
-
 	git checkout master
 '
 
@@ -40,6 +39,40 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
 	git rebase --continue
 '
 
+reset () {
+	rm -fr .git/rebase-* &&
+	git reset --hard commit-new-file-F2-on-topic-branch &&
+	git checkout master
+}
+
+test_autostage () {
+	action=$1
+
+	test_expect_success "rebase $action --continue --autostage stages changes" '
+		reset &&
+		test_must_fail git rebase $action --onto master master topic &&
+		echo "Resolved" >F2 &&
+		git rebase --continue --autostage
+'
+
+	test_expect_success "rebase $action --continue --autostage fails when there are merge markers (1)" '
+		reset &&
+		test_must_fail git rebase $action --onto master master topic &&
+		test_must_fail git rebase --continue --autostage
+'
+
+	test_expect_success "rebase $action --continue --autostage  fails when there are merge markers (2)" '
+		reset &&
+		test_must_fail git rebase $action --onto master master topic &&
+		git reset -- F2 &&
+		test_must_fail git rebase --continue --autostage
+	'
+}
+
+test_autostage
+test_autostage -i
+test_autostage -m
+
 test_expect_success 'non-interactive rebase --continue with rerere enabled' '
 	test_config rerere.enabled true &&
 	test_when_finished "test_might_fail git rebase --abort" &&
-- 
2.13.3
Previous: Phillip WoodNext: Phillip Wood
Message 4 of 19 in “Add option to autostage changes when continuing a rebase”
  1. 0/5 Add option to autostage changes when continuing a rebasePhillip Wood, Jul 26, 2017
  2. 1/5 rebase --continue: add --autostage to stage unstaged changesPhillip Wood, Jul 26, 2017
  3. 3/5 Unify rebase amend message when HEAD has changedPhillip Wood, Jul 26, 2017
  4. 4/5 Add tests for rebase --continue --autostagePhillip Wood, Jul 26, 2017
  5. 5/5 Add rebase.continue.autostage config settingPhillip Wood, Jul 26, 2017
  6. 2/5 rebase -i: improve --continue --autostagePhillip Wood, Jul 26, 2017
  7. Junio C HamanoJul 26, 2017
  8. Junio C HamanoJul 26, 2017
  9. Junio C HamanoJul 26, 2017
  10. Phillip WoodJul 27, 2017
  11. Phillip WoodJul 27, 2017
  12. Junio C HamanoJul 27, 2017
  13. Phillip WoodAug 21, 2017
  14. Junio C HamanoAug 21, 2017
  15. Phillip WoodAug 22, 2017
  16. Junio C HamanoAug 22, 2017
  17. Phillip WoodAug 24, 2017
  18. Junio C HamanoAug 24, 2017
  19. Phillip WoodAug 25, 2017

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.