git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com, Johannes.Schindelin@gmx.de
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [PATCHv3 1/2] rebase: decouple --exec from --interactive
Date: Fri, 18 Mar 2016 14:26:17 -0700	[thread overview]
Message-ID: <1458336377-28296-1-git-send-email-sbeller@google.com> (raw)
In-Reply-To: <xmqqd1qszs03.fsf@gitster.mtv.corp.google.com>

In the later steps of preparing a patch series I do not want to
edit or reorder the patches any more, but just make sure the
test suite passes after each patch and also to fix breakage
right there if some of the steps fail.  I could run

    EDITOR=true git rebase -i <anchor> -x "make test"

but it would be simpler if it can be spelled like so:

    git rebase <anchor> -x "make test"

Signed-off-by: Stefan Beller <sbeller@google.com>
---

  Thanks Junio, Johannes for review!
 
 * Reworded the commit message (took your suggestion)
 
 * Diff to v2 in t3404:
        test_expect_success 'rebase --exec works without -i ' '
                git reset --hard execute &&
                rm -rf exec_output &&
        -	git rebase --exec "echo a line >>exec_output"  HEAD~2 2>actual &&
        +	EDITOR="echo >invoked_editor" 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_line_count = 2 exec_output &&
        +	test_path_is_missing invoked_editor
        '
  * I just resend this patch instead of the whole series, so do not expect a
    [PATCHv3 2/2] nor cover letter 0/2
        

 Documentation/git-rebase.txt  |  6 +++---
 git-rebase.sh                 |  7 +------
 t/t3404-rebase-interactive.sh | 13 ++++++-------
 3 files changed, 10 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..21b1f95 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -876,16 +876,15 @@ 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 &&
+	EDITOR="echo >invoked_editor" 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_path_is_missing invoked_editor
 '
 
-
 test_expect_success 'rebase -i --exec without <CMD>' '
 	git reset --hard execute &&
 	set_fake_editor &&
-- 
2.8.0.rc3.10.gafa8710.dirty

  reply	other threads:[~2016-03-18 21:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 21:44 [PATCHV2 0/2] Decouple rebase --exec from --interactive Stefan Beller
2016-03-17 21:44 ` [PATCHV2 1/2] rebase -x: do not die without -i Stefan Beller
2016-03-17 21:58   ` Junio C Hamano
2016-03-18 21:26     ` Stefan Beller [this message]
2016-03-18 21:33       ` [PATCHv3 1/2] rebase: decouple --exec from --interactive Junio C Hamano
2016-03-18 21:44         ` Junio C Hamano
2016-03-18 21:46         ` Stefan Beller
2016-03-18  6:46   ` [PATCHV2 1/2] rebase -x: do not die without -i Johannes Schindelin
2016-03-17 21:44 ` [PATCHV2 2/2] t3404: cleanup double empty lines between tests Stefan Beller
2016-03-19 10:43 ` [PATCHV2 0/2] Decouple rebase --exec from --interactive Matthieu Moy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458336377-28296-1-git-send-email-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).