Skip to content

Commit

Permalink
Merge branch 'yd/use-test-config-unconfig'
Browse files Browse the repository at this point in the history
Bulk-update of the test suite.

* yd/use-test-config-unconfig:
  t5520: use test_config to set/unset git config variables (leftover bits)
  t7600: use test_config to set/unset git config variables
  t7502: remove clear_config
  t7502: use test_config to set/unset git config variables
  t9500: use test_config to set/unset git config variables
  t7508: use test_config to set/unset git config variables
  t7500: use test_config to set/unset git config variables
  t5541: use test_config to set/unset git config variables
  t5520: use test_config to set/unset git config variables
  t4202: use test_config/test_unconfig to set/unset git config variables
  t4034: use test_config/test_unconfig to set/unset git config variables
  t4304: use test_config to set/unset git config variables
  t3400: use test_config to set/unset git config variables
  • Loading branch information
Junio C Hamano committed Mar 28, 2013
2 parents 74bd526 + 790f282 commit 631bc94
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 142 deletions.
3 changes: 1 addition & 2 deletions t/t3400-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ test_expect_success 'rebase a single mode change' '
'

test_expect_success 'rebase is not broken by diff.renames' '
git config diff.renames copies &&
test_when_finished "git config --unset diff.renames" &&
test_config diff.renames copies &&
git checkout filemove &&
GIT_TRACE=1 git rebase force-3way
'
Expand Down
3 changes: 1 addition & 2 deletions t/t3404-rebase-interactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,7 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' '
test_expect_success 'rebase -i respects core.commentchar' '
git reset --hard &&
git checkout E^0 &&
git config core.commentchar "\\" &&
test_when_finished "git config --unset core.commentchar" &&
test_config core.commentchar "\\" &&
write_script remove-all-but-first.sh <<-\EOF &&
sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" &&
mv "$1.tmp" "$1"
Expand Down
7 changes: 3 additions & 4 deletions t/t4034-diff-words.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ test_expect_success '.gitattributes override config' '
'
test_expect_success 'setup: remove diff driver regex' '
test_might_fail git config --unset diff.testdriver.wordRegex
test_unconfig diff.testdriver.wordRegex
'
test_expect_success 'use configured regex' '
Expand Down Expand Up @@ -335,8 +335,7 @@ test_expect_success 'word-diff with diff.sbe' '
c
EOF
test_when_finished "git config --unset diff.suppress-blank-empty" &&
git config diff.suppress-blank-empty true &&
test_config diff.suppress-blank-empty true &&
word_diff --word-diff=plain
'
Expand Down Expand Up @@ -368,7 +367,7 @@ test_expect_success 'setup history with two files' '
test_expect_success 'wordRegex for the first file does not apply to the second' '
echo "*.tex diff=tex" >.gitattributes &&
git config diff.tex.wordRegex "[a-z]+|." &&
test_config diff.tex.wordRegex "[a-z]+|." &&
cat >expect <<-\EOF &&
diff --git a/a.tex b/a.tex
--- a/a.tex
Expand Down
28 changes: 8 additions & 20 deletions t/t4202-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ test_expect_success 'log --graph with merge' '
'

test_expect_success 'log.decorate configuration' '
test_might_fail git config --unset-all log.decorate &&
git log --oneline >expect.none &&
git log --oneline --decorate >expect.short &&
git log --oneline --decorate=full >expect.full &&
Expand All @@ -429,61 +427,55 @@ test_expect_success 'log.decorate configuration' '
git log --oneline >actual &&
test_cmp expect.short actual &&
git config --unset-all log.decorate &&
git config log.decorate true &&
test_config log.decorate true &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
git log --oneline --decorate=no >actual &&
test_cmp expect.none actual &&
git config --unset-all log.decorate &&
git config log.decorate no &&
test_config log.decorate no &&
git log --oneline >actual &&
test_cmp expect.none actual &&
git log --oneline --decorate >actual &&
test_cmp expect.short actual &&
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
git config --unset-all log.decorate &&
git config log.decorate 1 &&
test_config log.decorate 1 &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
git log --oneline --decorate=no >actual &&
test_cmp expect.none actual &&
git config --unset-all log.decorate &&
git config log.decorate short &&
test_config log.decorate short &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --no-decorate >actual &&
test_cmp expect.none actual &&
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
git config --unset-all log.decorate &&
git config log.decorate full &&
test_config log.decorate full &&
git log --oneline >actual &&
test_cmp expect.full actual &&
git log --oneline --no-decorate >actual &&
test_cmp expect.none actual &&
git log --oneline --decorate >actual &&
test_cmp expect.short actual
git config --unset-all log.decorate &&
test_unconfig log.decorate &&
git log --pretty=raw >expect.raw &&
git config log.decorate full &&
test_config log.decorate full &&
git log --pretty=raw >actual &&
test_cmp expect.raw actual
'

test_expect_success 'reflog is expected format' '
test_might_fail git config --remove-section log &&
git log -g --abbrev-commit --pretty=oneline >expect &&
git reflog >actual &&
test_cmp expect actual
Expand All @@ -496,10 +488,6 @@ test_expect_success 'whatchanged is expected format' '
'

test_expect_success 'log.abbrevCommit configuration' '
test_when_finished "git config --unset log.abbrevCommit" &&
test_might_fail git config --unset log.abbrevCommit &&
git log --abbrev-commit >expect.log.abbrev &&
git log --no-abbrev-commit >expect.log.full &&
git log --pretty=raw >expect.log.raw &&
Expand All @@ -508,7 +496,7 @@ test_expect_success 'log.abbrevCommit configuration' '
git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
git config log.abbrevCommit true &&
test_config log.abbrevCommit true &&
git log >actual &&
test_cmp expect.log.abbrev actual &&
Expand Down
18 changes: 7 additions & 11 deletions t/t5520-pull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,24 @@ test_expect_success '--rebase' '
'
test_expect_success 'pull.rebase' '
git reset --hard before-rebase &&
git config --bool pull.rebase true &&
test_when_finished "git config --unset pull.rebase" &&
test_config pull.rebase true &&
git pull . copy &&
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
test new = $(git show HEAD:file2)
'

test_expect_success 'branch.to-rebase.rebase' '
git reset --hard before-rebase &&
git config --bool branch.to-rebase.rebase true &&
test_when_finished "git config --unset branch.to-rebase.rebase" &&
test_config branch.to-rebase.rebase true &&
git pull . copy &&
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
test new = $(git show HEAD:file2)
'

test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
git reset --hard before-rebase &&
git config --bool pull.rebase true &&
test_when_finished "git config --unset pull.rebase" &&
git config --bool branch.to-rebase.rebase false &&
test_when_finished "git config --unset branch.to-rebase.rebase" &&
test_config pull.rebase true &&
test_config branch.to-rebase.rebase false &&
git pull . copy &&
test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
test new = $(git show HEAD:file2)
Expand Down Expand Up @@ -171,9 +167,9 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
git update-ref refs/remotes/me/copy copy^ &&
COPY=$(git rev-parse --verify me/copy) &&
git rebase --onto $COPY copy &&
git config branch.to-rebase.remote me &&
git config branch.to-rebase.merge refs/heads/copy &&
git config branch.to-rebase.rebase true &&
test_config branch.to-rebase.remote me &&
test_config branch.to-rebase.merge refs/heads/copy &&
test_config branch.to-rebase.rebase true &&
echo dirty >> file &&
git add file &&
test_must_fail git pull &&
Expand Down
3 changes: 1 addition & 2 deletions t/t5541-http-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ test_expect_success 'push (chunked)' '
git checkout master &&
test_commit commit path3 &&
HEAD=$(git rev-parse --verify HEAD) &&
git config http.postbuffer 4 &&
test_when_finished "git config --unset http.postbuffer" &&
test_config http.postbuffer 4 &&
git push -v -v origin $BRANCH 2>err &&
grep "POST git-receive-pack (chunked)" err &&
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
Expand Down
6 changes: 2 additions & 4 deletions t/t7500-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ test_expect_success 'nonexistent template file should return error' '
'

test_expect_success 'nonexistent template file in config should return error' '
git config commit.template "$PWD"/notexist &&
test_when_finished "git config --unset commit.template" &&
test_config commit.template "$PWD"/notexist &&
(
GIT_EDITOR="echo hello >\"\$1\"" &&
export GIT_EDITOR &&
Expand Down Expand Up @@ -93,14 +92,13 @@ test_expect_success '-t option should be short for --template' '

test_expect_success 'config-specified template should commit' '
echo "new template" > "$TEMPLATE" &&
git config commit.template "$TEMPLATE" &&
test_config commit.template "$TEMPLATE" &&
echo "more content" >> foo &&
git add foo &&
(
test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
git commit
) &&
git config --unset commit.template &&
commit_msg_is "new templatecommit message"
'

Expand Down
40 changes: 9 additions & 31 deletions t/t7502-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ test_expect_success 'verbose' '

test_expect_success 'verbose respects diff config' '
git config color.diff always &&
test_config color.diff always &&
git status -v >actual &&
grep "\[1mdiff --git" actual &&
git config --unset color.diff
grep "\[1mdiff --git" actual
'

mesg_with_comment_and_newlines='
Expand Down Expand Up @@ -435,16 +434,6 @@ EOF

echo '## Custom template' >template

clear_config () {
(
git config --unset-all "$1"
case $? in
0|5) exit 0 ;;
*) exit 1 ;;
esac
)
}

try_commit () {
git reset --hard &&
echo >>negative &&
Expand All @@ -460,67 +449,57 @@ try_commit () {
try_commit_status_combo () {

test_expect_success 'commit' '
clear_config commit.status &&
try_commit "" &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit' '
clear_config commit.status &&
try_commit "" &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit --status' '
clear_config commit.status &&
try_commit --status &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit --no-status' '
clear_config commit.status &&
try_commit --no-status &&
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit with commit.status = yes' '
clear_config commit.status &&
git config commit.status yes &&
test_config commit.status yes &&
try_commit "" &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit with commit.status = no' '
clear_config commit.status &&
git config commit.status no &&
test_config commit.status no &&
try_commit "" &&
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit --status with commit.status = yes' '
clear_config commit.status &&
git config commit.status yes &&
test_config commit.status yes &&
try_commit --status &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit --no-status with commit.status = yes' '
clear_config commit.status &&
git config commit.status yes &&
test_config commit.status yes &&
try_commit --no-status &&
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit --status with commit.status = no' '
clear_config commit.status &&
git config commit.status no &&
test_config commit.status no &&
try_commit --status &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'

test_expect_success 'commit --no-status with commit.status = no' '
clear_config commit.status &&
git config commit.status no &&
test_config commit.status no &&
try_commit --no-status &&
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
Expand All @@ -534,8 +513,7 @@ use_template="-t template"
try_commit_status_combo

test_expect_success 'commit --status with custom comment character' '
test_when_finished "git config --unset core.commentchar" &&
git config core.commentchar ";" &&
test_config core.commentchar ";" &&
try_commit --status &&
test_i18ngrep "^; Changes to be committed:" .git/COMMIT_EDITMSG
'
Expand Down
Loading

0 comments on commit 631bc94

Please sign in to comment.