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

[PATCHV2 1/2] rebase -x: do not die without -i

From
Stefan Beller <sbeller@google.com>
Date
Mar 17, 2016, 21:44 UTC
Message-ID
<1458251060-311-2-git-send-email-sbeller@google.com>
In-Reply-To
<1458251060-311-1-git-send-email-sbeller@google.com>

In the later steps of preparing a patch series I do not want to edit the patches any more, but just make sure the test suite passes after each patch. Currently I would run

  EDITOR=true git rebase -i <anchor> -x "make test"
In an ideal world the command would be simpler and just be
  git rebase <anchor> -x "make test"

to run the test for each commit I am about to send out for review. This patch enables the short line. As things can still break, I'd want to be able to fix those failures directly at the commit, so it is not sufficient to just use:

        git rev-list old...new |
        while read rev
        do
                $command || break
        done
as it only tests and does not stop at a breakage to fix it up.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 Documentation/git-rebase.txt  |  6 +++---
 git-rebase.sh                 |  7 +------
 t/t3404-rebase-interactive.sh | 12 +++++-------
 3 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 6ed610a..0387b40 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -391,9 +391,6 @@ idea unless you know what you are doing (see BUGS below).
 	final history. <cmd> will be interpreted as one or more shell
 	commands.
 +
-This option can only be used with the `--interactive` option
-(see INTERACTIVE MODE below).
-+
 You may execute several commands by either using one instance of `--exec`
 with several commands:
 +
@@ -406,6 +403,9 @@ or by giving more than one `--exec`:
 If `--autosquash` is used, "exec" lines will not be appended for
 the intermediate commits, and will only appear at the end of each
 squash/fixup series.
++
+This uses the `--interactive` machinery internally, but it can be run
+without an explicit `--interactive`.
 
 --root::
 	Rebase all commits reachable from <branch>, instead of
diff --git a/git-rebase.sh b/git-rebase.sh
index cf60c43..0bf41ee 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -248,6 +248,7 @@ do
 		;;
 	--exec=*)
 		cmd="${cmd}exec ${1#--exec=}${LF}"
+		test -z "$interactive_rebase" && interactive_rebase=implied
 		;;
 	--interactive)
 		interactive_rebase=explicit
@@ -348,12 +349,6 @@ do
 done
 test $# -gt 2 && usage
 
-if test -n "$cmd" &&
-   test "$interactive_rebase" != explicit
-then
-	die "$(gettext "The --exec option must be used with the --interactive option")"
-fi
-
 if test -n "$action"
 then
 	test -z "$in_progress" && die "$(gettext "No rebase in progress?")"
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 544f9ad..c8cc03d 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -876,16 +876,14 @@ test_expect_success 'rebase -ix with --autosquash' '
 	test_cmp expected actual
 '
 
-
-test_expect_success 'rebase --exec without -i shows error message' '
+test_expect_success 'rebase --exec works without -i ' '
 	git reset --hard execute &&
-	set_fake_editor &&
-	test_must_fail git rebase --exec "git show HEAD" HEAD~2 2>actual &&
-	echo "The --exec option must be used with the --interactive option" >expected &&
-	test_i18ncmp expected actual
+	rm -rf exec_output &&
+	git rebase --exec "echo a line >>exec_output"  HEAD~2 2>actual &&
+	test_i18ngrep  "Successfully rebased and updated" actual &&
+	test_line_count = 2 exec_output
 '
 
-
 test_expect_success 'rebase -i --exec without <CMD>' '
 	git reset --hard execute &&
 	set_fake_editor &&
-- 
2.8.0.rc3.2.ga804a9e
Previous: Stefan BellerNext: Junio C Hamano
Message 2 of 10 in “[PATCHV2 0/2] Decouple rebase --exec from --interactive”
  1. Stefan BellerMar 17, 2016
  2. 1/2 rebase -x: do not die without -iStefan Beller, Mar 17, 2016
  3. Junio C HamanoMar 17, 2016
  4. 1/2 rebase: decouple --exec from --interactiveStefan Beller, Mar 18, 2016
  5. Junio C HamanoMar 18, 2016
  6. Junio C HamanoMar 18, 2016
  7. Stefan BellerMar 18, 2016
  8. Johannes SchindelinMar 18, 2016
  9. 2/2 t3404: cleanup double empty lines between testsStefan Beller, Mar 17, 2016
  10. Matthieu MoyMar 19, 2016

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.