From: Firmin Martin <firminmartin24@gmail.com>
To: Firmin Martin <firminmartin24@gmail.com>, git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH v2 2/2] t: use test_config whenever possible
Date: Sat, 15 May 2021 17:27:21 +0200 [thread overview]
Message-ID: <20210515152721.885728-3-firminmartin24@gmail.com> (raw)
In-Reply-To: <20210515152721.885728-1-firminmartin24@gmail.com>
Replace patterns of the form
1.
git config <config-option> <value> &&
...
git config --unset <config-option> &&
2.
test_when_finished "git config --unset <config-option>" &&
git config <config-option> <value> &&
...
to the concise
test_config <config-option> <value>
In t5526, two tests have been further simplified as the output file is
written before "git config --global --unset".
Signed-off-by: Firmin Martin <firminmartin24@gmail.com>
---
t/t3200-branch.sh | 9 +++------
t/t3900-i18n-commit.sh | 3 +--
t/t4027-diff-submodule.sh | 3 +--
t/t4041-diff-submodule-option.sh | 3 +--
t/t4205-log-pretty-formats.sh | 8 +++-----
t/t5505-remote.sh | 3 +--
t/t5526-fetch-submodules.sh | 16 ++++------------
t/t6006-rev-list-format.sh | 5 ++---
t/t7401-submodule-summary.sh | 3 +--
t/t7610-mergetool.sh | 2 +-
t/t7900-maintenance.sh | 9 +++------
11 files changed, 21 insertions(+), 43 deletions(-)
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index cc4b10236e..0b0119bbe2 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -365,11 +365,9 @@ EOF
'
test_expect_success 'git branch with column.*' '
- git config column.ui column &&
- git config column.branch "dense" &&
+ test_config column.ui column &&
+ test_config column.branch "dense" &&
COLUMNS=80 git branch >actual &&
- git config --unset column.branch &&
- git config --unset column.ui &&
cat >expect <<\EOF &&
a/b/c bam foo l * main n o/p r
abc bar j/k m/m mb o/o q topic
@@ -382,9 +380,8 @@ test_expect_success 'git branch --column -v should fail' '
'
test_expect_success 'git branch -v with column.ui ignored' '
- git config column.ui column &&
+ test_config column.ui column &&
COLUMNS=80 git branch -v | cut -c -8 | sed "s/ *$//" >actual &&
- git config --unset column.ui &&
cat >expect <<\EOF &&
a/b/c
abc
diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh
index bfab245eb3..c16c0f7fba 100755
--- a/t/t3900-i18n-commit.sh
+++ b/t/t3900-i18n-commit.sh
@@ -179,7 +179,7 @@ test_commit_autosquash_flags () {
H=$1
flag=$2
test_expect_success "commit --$flag with $H encoding" '
- git config i18n.commitencoding $H &&
+ test_config i18n.commitencoding $H &&
git checkout -b $H-$flag C0 &&
echo $H >>F &&
git commit -a -F "$TEST_DIRECTORY"/t3900/$H.txt &&
@@ -193,7 +193,6 @@ test_commit_autosquash_flags () {
E=$(git cat-file commit '$H-$flag' |
sed -ne "s/^encoding //p") &&
test "z$E" = "z$H" &&
- git config --unset-all i18n.commitencoding &&
git rebase --autosquash -i HEAD^^^ &&
git log --oneline >actual &&
test_line_count = 3 actual
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 94ef77e1df..a6eb2416ed 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -123,7 +123,7 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'
'
test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) [.gitmodules]' '
- git config diff.ignoreSubmodules dirty &&
+ test_config diff.ignoreSubmodules dirty &&
git diff HEAD >actual &&
test_must_be_empty actual &&
git config --add -f .gitmodules submodule.subname.ignore none &&
@@ -152,7 +152,6 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)
test_cmp expect.body actual.body &&
git config --remove-section submodule.subname &&
git config --remove-section -f .gitmodules submodule.subname &&
- git config --unset diff.ignoreSubmodules &&
rm .gitmodules
'
diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh
index 0c1502d4b0..782424c2d0 100755
--- a/t/t4041-diff-submodule-option.sh
+++ b/t/t4041-diff-submodule-option.sh
@@ -58,13 +58,12 @@ test_expect_success 'added submodule' '
'
test_expect_success 'added submodule, set diff.submodule' '
- git config diff.submodule log &&
+ test_config diff.submodule log &&
git add sm1 &&
git diff --cached >actual &&
cat >expected <<-EOF &&
Submodule sm1 0000000...$head1 (new submodule)
EOF
- git config --unset diff.submodule &&
test_cmp expected actual
'
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 8272d94ce6..fbe8ae5378 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -30,12 +30,11 @@ test_expect_success 'set up basic repos' '
>bar &&
git add foo &&
test_tick &&
- git config i18n.commitEncoding $test_encoding &&
+ test_config i18n.commitEncoding $test_encoding &&
commit_msg $test_encoding | git commit -F - &&
git add bar &&
test_tick &&
- git commit -m "add bar" &&
- git config --unset i18n.commitEncoding
+ git commit -m "add bar"
'
test_expect_success 'alias builtin format' '
@@ -60,10 +59,9 @@ test_expect_success 'alias user-defined format' '
'
test_expect_success 'alias user-defined tformat with %s (ISO8859-1 encoding)' '
- git config i18n.logOutputEncoding $test_encoding &&
+ test_config i18n.logOutputEncoding $test_encoding &&
git log --oneline >expected-s &&
git log --pretty="tformat:%h %s" >actual-s &&
- git config --unset i18n.logOutputEncoding &&
test_cmp expected-s actual-s
'
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index c7b392794b..bed8e6633a 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -836,8 +836,7 @@ test_expect_success 'rename a remote with name prefix of other remote' '
test_expect_success 'rename succeeds with existing remote.<target>.prune' '
git clone one four.four &&
- test_when_finished git config --global --unset remote.upstream.prune &&
- git config --global remote.upstream.prune true &&
+ test_config_global remote.upstream.prune true &&
git -C four.four remote rename origin upstream
'
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index ed11569d8d..ff18263171 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -418,7 +418,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config
git fetch --recurse-submodules
) &&
add_upstream_commit &&
- git config --global fetch.recurseSubmodules false &&
+ test_config_global fetch.recurseSubmodules false &&
head1=$(git rev-parse --short HEAD) &&
git add submodule &&
git commit -m "new submodule" &&
@@ -429,11 +429,7 @@ test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config
(
cd downstream &&
git config fetch.recurseSubmodules on-demand &&
- git fetch >../actual.out 2>../actual.err
- ) &&
- git config --global --unset fetch.recurseSubmodules &&
- (
- cd downstream &&
+ git fetch >../actual.out 2>../actual.err &&
git config --unset fetch.recurseSubmodules
) &&
test_must_be_empty actual.out &&
@@ -446,7 +442,7 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override
git fetch --recurse-submodules
) &&
add_upstream_commit &&
- git config fetch.recurseSubmodules false &&
+ test_config fetch.recurseSubmodules false &&
head1=$(git rev-parse --short HEAD) &&
git add submodule &&
git commit -m "new submodule" &&
@@ -457,11 +453,7 @@ test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' override
(
cd downstream &&
git config submodule.submodule.fetchRecurseSubmodules on-demand &&
- git fetch >../actual.out 2>../actual.err
- ) &&
- git config --unset fetch.recurseSubmodules &&
- (
- cd downstream &&
+ git fetch >../actual.out 2>../actual.err &&
git config --unset submodule.submodule.fetchRecurseSubmodules
) &&
test_must_be_empty actual.out &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 35a2f62392..9ba06ec5ae 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -37,7 +37,7 @@ truncate_count=20
test_expect_success 'setup' '
: >foo &&
git add foo &&
- git config i18n.commitEncoding $test_encoding &&
+ test_config i18n.commitEncoding $test_encoding &&
echo "$added_iso88591" | git commit -F - &&
head1=$(git rev-parse --verify HEAD) &&
head1_short=$(git rev-parse --verify --short $head1) &&
@@ -48,8 +48,7 @@ test_expect_success 'setup' '
head2=$(git rev-parse --verify HEAD) &&
head2_short=$(git rev-parse --verify --short $head2) &&
tree2=$(git rev-parse --verify HEAD:) &&
- tree2_short=$(git rev-parse --verify --short $tree2) &&
- git config --unset i18n.commitEncoding
+ tree2_short=$(git rev-parse --verify --short $tree2)
'
# usage: test_format name format_string [failure] <expected_output
diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh
index 9c3cc4cf40..4963f3290d 100755
--- a/t/t7401-submodule-summary.sh
+++ b/t/t7401-submodule-summary.sh
@@ -116,7 +116,7 @@ test_expect_success 'no ignore=all setting has any effect' "
git config -f .gitmodules submodule.sm1.path sm1 &&
git config -f .gitmodules submodule.sm1.ignore all &&
git config submodule.sm1.ignore all &&
- git config diff.ignoreSubmodules all &&
+ test_config diff.ignoreSubmodules all &&
git submodule summary >actual &&
cat >expected <<-EOF &&
* sm1 $head1...$head2 (1):
@@ -124,7 +124,6 @@ test_expect_success 'no ignore=all setting has any effect' "
EOF
test_cmp expected actual &&
- git config --unset diff.ignoreSubmodules &&
git config --remove-section submodule.sm1 &&
git config -f .gitmodules --remove-section submodule.sm1
"
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index 8cc64729ad..2ff00f6c46 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -803,7 +803,7 @@ test_expect_success 'diff.orderFile configuration is honored' '
test_expect_success 'mergetool -Oorder-file is honored' '
test_when_finished "git reset --hard" &&
git checkout -b test$test_count order-file-side2 &&
- test_config diff.orderFile order-file &&
+ git config diff.orderFile order-file &&
test_config mergetool.myecho.cmd "echo \"\$LOCAL\"" &&
test_config mergetool.myecho.trustExitCode true &&
echo b >order-file &&
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index b93ae014ee..7f12619feb 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -155,8 +155,7 @@ test_expect_success 'prefetch multiple remotes' '
git log --oneline --decorate --all >log &&
! grep "prefetch" log &&
- test_when_finished git config --unset remote.remote1.skipFetchAll &&
- git config remote.remote1.skipFetchAll true &&
+ test_config remote.remote1.skipFetchAll true &&
GIT_TRACE2_EVENT="$(pwd)/skip-remote1.txt" git maintenance run --task=prefetch 2>/dev/null &&
test_subcommand ! git fetch remote1 $fetchargs <skip-remote1.txt &&
test_subcommand git fetch remote2 $fetchargs <skip-remote1.txt
@@ -407,8 +406,7 @@ test_expect_success 'maintenance.strategy inheritance' '
git config --unset maintenance.$task.schedule || return 1
done &&
- test_when_finished git config --unset maintenance.strategy &&
- git config maintenance.strategy incremental &&
+ test_config maintenance.strategy incremental &&
GIT_TRACE2_EVENT="$(pwd)/incremental-hourly.txt" \
git maintenance run --schedule=hourly --quiet &&
@@ -465,8 +463,7 @@ test_expect_success 'maintenance.strategy inheritance' '
'
test_expect_success 'register and unregister' '
- test_when_finished git config --global --unset-all maintenance.repo &&
- git config --global --add maintenance.repo /existing1 &&
+ test_config_global maintenance.repo /existing1 &&
git config --global --add maintenance.repo /existing2 &&
git config --global --get-all maintenance.repo >before &&
--
2.31.1.443.g67a420f573
next prev parent reply other threads:[~2021-05-15 15:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 6:55 [PATCH 1/2] t/README: document test_config Firmin Martin
2021-05-14 6:55 ` [PATCH 2/2] t: use test_config whenever possible Firmin Martin
2021-05-15 20:15 ` Felipe Contreras
2021-05-15 20:21 ` Felipe Contreras
2021-05-15 22:00 ` Firmin Martin
2021-05-14 7:02 ` [PATCH 1/2] t/README: document test_config Eric Sunshine
2021-05-15 14:43 ` Firmin Martin
2021-05-15 15:27 ` [PATCH v2 0/2] document test_config & use it whenever possible Firmin Martin
2021-05-15 15:27 ` [PATCH v2 1/2] t/README: document test_config Firmin Martin
2021-05-16 5:03 ` Bagas Sanjaya
2021-05-17 7:44 ` Firmin Martin
2021-05-15 15:27 ` Firmin Martin [this message]
2021-05-16 5:02 ` [PATCH v2 2/2] t: use test_config whenever possible Junio C Hamano
2021-05-17 6:08 ` Firmin Martin
2021-05-17 6:55 ` Junio C Hamano
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=20210515152721.885728-3-firminmartin24@gmail.com \
--to=firminmartin24@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.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).