git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heiko Voigt <hvoigt@hvoigt.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>, git@vger.kernel.org
Subject: [PATCH v3] add configuration variable for --autosquash option of interactive rebase
Date: Tue, 13 Jul 2010 13:24:40 +0200	[thread overview]
Message-ID: <20100713112316.GA758@book.hvoigt.net> (raw)
In-Reply-To: <7vk4p1fdlg.fsf@alter.siamese.dyndns.org>

If you use this feature regularly you can now enable it by default. In
case the user wants to override this config on the commandline
--no-autosquash can be used to force disabling.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
On Sun, Jul 11, 2010 at 10:55:55PM -0700, Junio C Hamano wrote:
> Heiko Voigt <hvoigt@hvoigt.net> writes:
> 
> > If you use this feature regularly you can now enable it by default.
> 
> And if you use this often _but_ you sometimes need to countermand from the
> command line, do you provide a way to do so (I didn't bother to check).

No I did not see the exact use case because you could simply not prefix
you commits with 'fixup!' or 'squash!' and if your project regularly
uses those on commits you probably would like to configure different
prefixes.

On the other hand I think it is a good convention to always provide a
--no-... option for things you can enable in the config and it does not
hurt to do so. So here is a new patch implementing this. I also fixed
some places with missing && in the testcases I implemented.

cheers Heiko

 Documentation/git-rebase.txt |    8 ++++++++
 git-rebase--interactive.sh   |    4 ++++
 t/t3415-rebase-autosquash.sh |   40 ++++++++++++++++++++++++++++++++--------
 3 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index be23ad2..d357ab1 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -199,6 +199,9 @@ rebase.stat::
 	Whether to show a diffstat of what changed upstream since the last
 	rebase. False by default.
 
+rebase.autosquash::
+	If set to true enable '--autosquash' option by default.
+
 OPTIONS
 -------
 <newbase>::
@@ -335,6 +338,11 @@ idea unless you know what you are doing (see BUGS below).
 +
 This option is only valid when the '--interactive' option is used.
 
+--no-autosquash::
+	If the '--autosquash' option is enabled by default using the
+	configuration variable `rebase.autosquash` this option can be
+	used to override and disable this setting.
+
 --no-ff::
 	With --interactive, cherry-pick all rebased commits instead of
 	fast-forwarding over the unchanged ones.  This ensures that the
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 6b86abc..7b35f80 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -111,6 +111,7 @@ VERBOSE=
 OK_TO_SKIP_PRE_REBASE=
 REBASE_ROOT=
 AUTOSQUASH=
+test "$(git config --bool rebase.autosquash)" = "true" && AUTOSQUASH=t
 NEVER_FF=
 
 GIT_CHERRY_PICK_HELP="  After resolving the conflicts,
@@ -795,6 +796,9 @@ first and then run 'git rebase --continue' again."
 	--autosquash)
 		AUTOSQUASH=t
 		;;
+	--no-autosquash)
+		AUTOSQUASH=
+		;;
 	--onto)
 		shift
 		ONTO=$(parse_onto "$1") ||
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index b63f4e2..37cb89a 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -21,38 +21,62 @@ test_expect_success setup '
 	git tag base
 '
 
-test_expect_success 'auto fixup' '
+test_auto_fixup() {
 	git reset --hard base &&
 	echo 1 >file1 &&
 	git add -u &&
 	test_tick &&
 	git commit -m "fixup! first"
 
-	git tag final-fixup &&
+	git tag $1 &&
 	test_tick &&
-	git rebase --autosquash -i HEAD^^^ &&
+	git rebase $2 -i HEAD^^^ &&
 	git log --oneline >actual &&
 	test 3 = $(wc -l <actual) &&
-	git diff --exit-code final-fixup &&
+	git diff --exit-code $1 &&
 	test 1 = "$(git cat-file blob HEAD^:file1)" &&
 	test 1 = $(git cat-file commit HEAD^ | grep first | wc -l)
+}
+
+test_expect_success 'auto fixup (option)' '
+	test_auto_fixup final-fixup-option --autosquash
+'
+
+test_expect_success 'auto fixup (config)' '
+	git config rebase.autosquash true &&
+	test_auto_fixup final-fixup-config-true &&
+	test_must_fail test_auto_fixup fixup-config-true-no --no-autosquash &&
+	git config rebase.autosquash false &&
+	test_must_fail test_auto_fixup final-fixup-config-false
 '
 
-test_expect_success 'auto squash' '
+test_auto_squash() {
 	git reset --hard base &&
 	echo 1 >file1 &&
 	git add -u &&
 	test_tick &&
 	git commit -m "squash! first"
 
-	git tag final-squash &&
+	git tag $1 &&
 	test_tick &&
-	git rebase --autosquash -i HEAD^^^ &&
+	git rebase $2 -i HEAD^^^ &&
 	git log --oneline >actual &&
 	test 3 = $(wc -l <actual) &&
-	git diff --exit-code final-squash &&
+	git diff --exit-code $1 &&
 	test 1 = "$(git cat-file blob HEAD^:file1)" &&
 	test 2 = $(git cat-file commit HEAD^ | grep first | wc -l)
+}
+
+test_expect_success 'auto squash (option)' '
+	test_auto_squash final-squash --autosquash
+'
+
+test_expect_success 'auto squash (config)' '
+	git config rebase.autosquash true &&
+	test_auto_squash final-squash-config-true &&
+	test_must_fail test_auto_squash squash-config-true-no --no-autosquash &&
+	git config rebase.autosquash false &&
+	test_must_fail test_auto_squash final-squash-config-false
 '
 
 test_expect_success 'misspelled auto squash' '
-- 
1.7.2.rc2.1.gf1735.dirty

  reply	other threads:[~2010-07-13 11:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09 12:47 [PATCH] add configuration variable for --autosquash option of interactive rebase Heiko Voigt
2010-07-09 18:01 ` Andreas Schwab
2010-07-10  9:15   ` [PATCH v2] " Heiko Voigt
2010-07-12  5:55     ` Junio C Hamano
2010-07-13 11:24       ` Heiko Voigt [this message]
2010-07-13 12:34         ` [PATCH v3] " Santi Béjar
2010-07-13 16:08           ` Junio C Hamano
2010-07-14 11:50             ` Heiko Voigt
2010-07-14  5:15         ` Stephen Boyd
2010-07-14 11:54           ` Heiko Voigt
2010-07-14 11:59           ` [PATCH v4] " Heiko Voigt

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=20100713112316.GA758@book.hvoigt.net \
    --to=hvoigt@hvoigt.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=schwab@linux-m68k.org \
    /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).