All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yann Droneaud <ydroneaud@opteya.com>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Cc: Yann Droneaud <ydroneaud@opteya.com>
Subject: [PATCH 13/15] t7600: use test_config to set/unset git config variables
Date: Sun, 24 Mar 2013 22:06:12 +0100	[thread overview]
Message-ID: <48e5b9a14fdebd7257d859eda05477dc2956d525.1364158574.git.ydroneaud@opteya.com> (raw)
In-Reply-To: <cover.1364158574.git.ydroneaud@opteya.com>
In-Reply-To: <cover.1364158574.git.ydroneaud@opteya.com>

Instead of using construct such as:
    test_when_finished "git config --unset <key>"
    git config <key> <value>
uses
    test_config <key> <value>
The latter takes care of removing <key> at the end of the test.

Tests are modified to assume default configuration at entry,
and to reset the modified configuration variables at the end.

Test 'merge log message' was relying on the presence of option `--no-ff`
in the configuration. With the option, git show -s --pretty=format:%b HEAD
produces an empty line and without the option, it produces an empty file.
The test is modified to check with and without `--no-ff` option.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
 t/t7600-merge.sh | 60 ++++++++++++++++++++++++--------------------------------
 1 file changed, 26 insertions(+), 34 deletions(-)

diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 5e19598..2f70433 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -56,7 +56,8 @@ create_merge_msgs () {
 		echo &&
 		git log --no-merges ^HEAD c2 c3
 	} >squash.1-5-9 &&
-	echo >msg.nolog &&
+	: >msg.nologff &&
+	echo >msg.nolognoff &&
 	{
 		echo "* tag 'c3':" &&
 		echo "  commit 3" &&
@@ -244,8 +245,7 @@ test_expect_success 'merges with --ff-only' '
 test_expect_success 'merges with merge.ff=only' '
 	git reset --hard c1 &&
 	test_tick &&
-	test_when_finished "git config --unset merge.ff" &&
-	git config merge.ff only &&
+	test_config merge.ff "only" &&
 	test_must_fail git merge c2 &&
 	test_must_fail git merge c3 &&
 	test_must_fail git merge c2 c3 &&
@@ -336,7 +336,7 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c1 with c2 (no-commit in config)' '
 	git reset --hard c1 &&
-	git config branch.master.mergeoptions "--no-commit" &&
+	test_config branch.master.mergeoptions "--no-commit" &&
 	git merge c2 &&
 	verify_merge file result.1-5 &&
 	verify_head $c1 &&
@@ -346,12 +346,11 @@ test_expect_success 'merge c1 with c2 (no-commit in config)' '
 test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c1 with c2 (log in config)' '
-	git config branch.master.mergeoptions "" &&
 	git reset --hard c1 &&
 	git merge --log c2 &&
 	git show -s --pretty=tformat:%s%n%b >expect &&
 
-	git config branch.master.mergeoptions --log &&
+	test_config branch.master.mergeoptions "--log" &&
 	git reset --hard c1 &&
 	git merge c2 &&
 	git show -s --pretty=tformat:%s%n%b >actual &&
@@ -360,17 +359,12 @@ test_expect_success 'merge c1 with c2 (log in config)' '
 '
 
 test_expect_success 'merge c1 with c2 (log in config gets overridden)' '
-	test_when_finished "git config --remove-section branch.master" &&
-	test_when_finished "git config --remove-section merge" &&
-	test_might_fail git config --remove-section branch.master &&
-	test_might_fail git config --remove-section merge &&
-
 	git reset --hard c1 &&
 	git merge c2 &&
 	git show -s --pretty=tformat:%s%n%b >expect &&
 
-	git config branch.master.mergeoptions "--no-log" &&
-	git config merge.log true &&
+	test_config branch.master.mergeoptions "--no-log" &&
+	test_config merge.log "true" &&
 	git reset --hard c1 &&
 	git merge c2 &&
 	git show -s --pretty=tformat:%s%n%b >actual &&
@@ -380,7 +374,7 @@ test_expect_success 'merge c1 with c2 (log in config gets overridden)' '
 
 test_expect_success 'merge c1 with c2 (squash in config)' '
 	git reset --hard c1 &&
-	git config branch.master.mergeoptions "--squash" &&
+	test_config branch.master.mergeoptions "--squash" &&
 	git merge c2 &&
 	verify_merge file result.1-5 &&
 	verify_head $c1 &&
@@ -392,7 +386,7 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'override config option -n with --summary' '
 	git reset --hard c1 &&
-	git config branch.master.mergeoptions "-n" &&
+	test_config branch.master.mergeoptions "-n" &&
 	test_tick &&
 	git merge --summary c2 >diffstat.txt &&
 	verify_merge file result.1-5 msg.1-5 &&
@@ -406,7 +400,7 @@ test_expect_success 'override config option -n with --summary' '
 
 test_expect_success 'override config option -n with --stat' '
 	git reset --hard c1 &&
-	git config branch.master.mergeoptions "-n" &&
+	test_config branch.master.mergeoptions "-n" &&
 	test_tick &&
 	git merge --stat c2 >diffstat.txt &&
 	verify_merge file result.1-5 msg.1-5 &&
@@ -422,7 +416,7 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'override config option --stat' '
 	git reset --hard c1 &&
-	git config branch.master.mergeoptions "--stat" &&
+	test_config branch.master.mergeoptions "--stat" &&
 	test_tick &&
 	git merge -n c2 >diffstat.txt &&
 	verify_merge file result.1-5 msg.1-5 &&
@@ -438,7 +432,7 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c1 with c2 (override --no-commit)' '
 	git reset --hard c1 &&
-	git config branch.master.mergeoptions "--no-commit" &&
+	test_config branch.master.mergeoptions "--no-commit" &&
 	test_tick &&
 	git merge --commit c2 &&
 	verify_merge file result.1-5 msg.1-5 &&
@@ -449,7 +443,7 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c1 with c2 (override --squash)' '
 	git reset --hard c1 &&
-	git config branch.master.mergeoptions "--squash" &&
+	test_config branch.master.mergeoptions "--squash" &&
 	test_tick &&
 	git merge --no-squash c2 &&
 	verify_merge file result.1-5 msg.1-5 &&
@@ -460,7 +454,6 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c0 with c1 (no-ff)' '
 	git reset --hard c0 &&
-	git config branch.master.mergeoptions "" &&
 	test_tick &&
 	git merge --no-ff c1 &&
 	verify_merge file result.1 &&
@@ -471,10 +464,9 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c0 with c1 (merge.ff=false)' '
 	git reset --hard c0 &&
-	git config merge.ff false &&
+	test_config merge.ff "false" &&
 	test_tick &&
 	git merge c1 &&
-	git config --remove-section merge &&
 	verify_merge file result.1 &&
 	verify_parents $c0 $c1
 '
@@ -482,22 +474,19 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'combine branch.master.mergeoptions with merge.ff' '
 	git reset --hard c0 &&
-	git config branch.master.mergeoptions --ff &&
-	git config merge.ff false &&
+	test_config branch.master.mergeoptions "--ff" &&
+	test_config merge.ff "false" &&
 	test_tick &&
 	git merge c1 &&
-	git config --remove-section "branch.master" &&
-	git config --remove-section "merge" &&
 	verify_merge file result.1 &&
 	verify_parents "$c0"
 '
 
 test_expect_success 'tolerate unknown values for merge.ff' '
 	git reset --hard c0 &&
-	git config merge.ff something-new &&
+	test_config merge.ff "something-new" &&
 	test_tick &&
 	git merge c1 2>message &&
-	git config --remove-section "merge" &&
 	verify_head "$c1" &&
 	test_cmp empty message
 '
@@ -515,7 +504,7 @@ test_expect_success 'combining --ff-only and --no-ff is refused' '
 
 test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
 	git reset --hard c0 &&
-	git config branch.master.mergeoptions "--no-ff" &&
+	test_config branch.master.mergeoptions "--no-ff" &&
 	git merge --ff c1 &&
 	verify_merge file result.1 &&
 	verify_head $c1
@@ -525,14 +514,20 @@ test_expect_success 'merge log message' '
 	git reset --hard c0 &&
 	git merge --no-log c2 &&
 	git show -s --pretty=format:%b HEAD >msg.act &&
-	test_cmp msg.nolog msg.act &&
+	test_cmp msg.nologff msg.act &&
+
+	git reset --hard c0 &&
+	test_config branch.master.mergeoptions "--no-ff" &&
+	git merge --no-log c2 &&
+	git show -s --pretty=format:%b HEAD >msg.act &&
+	test_cmp msg.nolognoff msg.act &&
 
 	git merge --log c3 &&
 	git show -s --pretty=format:%b HEAD >msg.act &&
 	test_cmp msg.log msg.act &&
 
 	git reset --hard HEAD^ &&
-	git config merge.log yes &&
+	test_config merge.log "yes" &&
 	git merge c3 &&
 	git show -s --pretty=format:%b HEAD >msg.act &&
 	test_cmp msg.log msg.act
@@ -542,7 +537,6 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c1 with c0, c2, c0, and c1' '
        git reset --hard c1 &&
-       git config branch.master.mergeoptions "" &&
        test_tick &&
        git merge c0 c2 c0 c1 &&
        verify_merge file result.1-5 &&
@@ -553,7 +547,6 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c1 with c0, c2, c0, and c1' '
        git reset --hard c1 &&
-       git config branch.master.mergeoptions "" &&
        test_tick &&
        git merge c0 c2 c0 c1 &&
        verify_merge file result.1-5 &&
@@ -564,7 +557,6 @@ test_debug 'git log --graph --decorate --oneline --all'
 
 test_expect_success 'merge c1 with c1 and c2' '
        git reset --hard c1 &&
-       git config branch.master.mergeoptions "" &&
        test_tick &&
        git merge c1 c2 &&
        verify_merge file result.1-5 &&
-- 
1.7.11.7

  parent reply	other threads:[~2013-03-24 21:27 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-19 14:55 git merge <tag> behavior Yann Droneaud
2013-03-19 16:19 ` Junio C Hamano
2013-03-19 17:54   ` Re* " Junio C Hamano
2013-04-01 19:57     ` [PATCH 0/3] Merging an annotated tag object Junio C Hamano
2013-04-01 19:57       ` [PATCH 1/3] merge: a random object may not necssarily be a commit Junio C Hamano
2013-04-01 22:51         ` Yann Droneaud
2013-04-02  5:30         ` Jeff King
2013-04-02 15:02           ` Junio C Hamano
2013-04-02 15:03             ` Jeff King
2013-04-01 19:57       ` [PATCH 2/3] t6200: use test_config/test_unconfig Junio C Hamano
2013-04-01 19:57       ` [PATCH 3/3] t6200: test message for merging of an annotated tag Junio C Hamano
2013-03-20 17:53   ` [PATCH] Documentation: merging a tag is a special case Yann Droneaud
2013-03-20 18:54     ` Jonathan Nieder
2013-03-20 19:07     ` Junio C Hamano
2013-03-21 19:50       ` Junio C Hamano
2013-03-21 19:56         ` Jonathan Nieder
2013-03-21 20:10           ` Junio C Hamano
2013-03-21 20:39             ` Jonathan Nieder
2013-03-21 21:47             ` Yann Droneaud
2013-03-21 21:57               ` [PATCH v2] " Yann Droneaud
2013-03-21 22:41                 ` Jonathan Nieder
2013-03-20 18:04   ` git merge <tag> behavior Yann Droneaud
2013-03-20 18:12     ` Yann Droneaud
2013-03-20 18:46       ` Junio C Hamano
2013-03-21 20:31 ` Max Nanasy
2013-03-22  9:16   ` Yann Droneaud
2013-03-22 10:09     ` [PATCH] t7600: test merge configuration override Yann Droneaud
2013-03-22 14:47       ` Junio C Hamano
2013-03-24 21:05       ` [PATCH 00/15] Use test_config Yann Droneaud
2013-03-24 21:06         ` [PATCH 01/15] t4018: remove test_config implementation Yann Droneaud
2013-03-24 21:06         ` [PATCH 02/15] t7810: " Yann Droneaud
2013-03-24 21:06         ` [PATCH 03/15] t7811: " Yann Droneaud
2013-03-24 21:06         ` [PATCH 04/15] t3400: use test_config to set/unset git config variables Yann Droneaud
2013-03-24 21:06         ` [PATCH 05/15] t4304: " Yann Droneaud
2013-03-24 21:06         ` [PATCH 06/15] t4034: use test_config/test_unconfig " Yann Droneaud
2013-03-24 21:06         ` [PATCH 07/15] t4202: " Yann Droneaud
2013-03-24 21:06         ` [PATCH 08/15] t5520: use test_config " Yann Droneaud
2013-03-24 21:06         ` [PATCH 09/15] t5541: " Yann Droneaud
2013-03-24 21:06         ` [PATCH 10/15] t7500: " Yann Droneaud
2013-03-24 21:06         ` [PATCH 11/15] t7502: " Yann Droneaud
2013-03-24 21:06         ` [PATCH 12/15] t7508: " Yann Droneaud
2013-03-24 21:06         ` Yann Droneaud [this message]
2013-03-24 21:06         ` [PATCH 14/15] t9500: " Yann Droneaud
2013-03-24 21:06         ` [PATCH 15/15] t7502: remove clear_config Yann Droneaud
2013-03-27 15:04           ` Junio C Hamano
2013-03-27 15:05         ` [PATCH 00/15] Use test_config Junio C Hamano
2013-03-27 16:19           ` Yann Droneaud
2013-03-22 15:23     ` git merge <tag> behavior Junio C Hamano
2013-03-22 10:57 ` [PATCH] t7600: merge tag shoud create a merge commit y
2013-03-22 14:48   ` Junio C Hamano
2013-03-22 14:56     ` Yann Droneaud
2013-03-22 15:05       ` Jeff King
2013-03-22 10:57 ` y

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=48e5b9a14fdebd7257d859eda05477dc2956d525.1364158574.git.ydroneaud@opteya.com \
    --to=ydroneaud@opteya.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.