t5520: improve test style

Improve the test style by removing leading and trailing empty lines
within test cases. Also, reformat multi-line subshells to conform to the
existing style.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Denton Liu 2019-11-12 15:07:48 -08:00 committed by Junio C Hamano
parent 2c9e125b27
commit e8d1eaf9b4

View File

@ -538,7 +538,6 @@ test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-m
' '
test_expect_success '--rebase with rebased upstream' ' test_expect_success '--rebase with rebased upstream' '
git remote add -f me . && git remote add -f me . &&
git checkout copy && git checkout copy &&
git tag copy-orig && git tag copy-orig &&
@ -552,7 +551,6 @@ test_expect_success '--rebase with rebased upstream' '
git pull --rebase me copy && git pull --rebase me copy &&
test "conflicting modification" = "$(cat file)" && test "conflicting modification" = "$(cat file)" &&
test file = "$(cat file2)" test file = "$(cat file2)"
' '
test_expect_success '--rebase -f with rebased upstream' ' test_expect_success '--rebase -f with rebased upstream' '
@ -564,14 +562,12 @@ test_expect_success '--rebase -f with rebased upstream' '
' '
test_expect_success '--rebase with rebased default upstream' ' test_expect_success '--rebase with rebased default upstream' '
git update-ref refs/remotes/me/copy copy-orig && git update-ref refs/remotes/me/copy copy-orig &&
git checkout --track -b to-rebase2 me/copy && git checkout --track -b to-rebase2 me/copy &&
git reset --hard to-rebase-orig && git reset --hard to-rebase-orig &&
git pull --rebase && git pull --rebase &&
test "conflicting modification" = "$(cat file)" && test "conflicting modification" = "$(cat file)" &&
test file = "$(cat file2)" test file = "$(cat file2)"
' '
test_expect_success 'rebased upstream + fetch + pull --rebase' ' test_expect_success 'rebased upstream + fetch + pull --rebase' '
@ -588,7 +584,6 @@ test_expect_success 'rebased upstream + fetch + pull --rebase' '
' '
test_expect_success 'pull --rebase dies early with dirty working directory' ' test_expect_success 'pull --rebase dies early with dirty working directory' '
git checkout to-rebase && git checkout to-rebase &&
git update-ref refs/remotes/me/copy copy^ && git update-ref refs/remotes/me/copy copy^ &&
COPY="$(git rev-parse --verify me/copy)" && COPY="$(git rev-parse --verify me/copy)" &&
@ -603,16 +598,16 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
git checkout HEAD -- file && git checkout HEAD -- file &&
git pull && git pull &&
test "$COPY" != "$(git rev-parse --verify me/copy)" test "$COPY" != "$(git rev-parse --verify me/copy)"
' '
test_expect_success 'pull --rebase works on branch yet to be born' ' test_expect_success 'pull --rebase works on branch yet to be born' '
git rev-parse master >expect && git rev-parse master >expect &&
mkdir empty_repo && mkdir empty_repo &&
(cd empty_repo && (
git init && cd empty_repo &&
git pull --rebase .. master && git init &&
git rev-parse HEAD >../actual git pull --rebase .. master &&
git rev-parse HEAD >../actual
) && ) &&
test_cmp expect actual test_cmp expect actual
' '
@ -646,58 +641,65 @@ test_expect_success 'pull --rebase fails on corrupt HEAD' '
test_expect_success 'setup for detecting upstreamed changes' ' test_expect_success 'setup for detecting upstreamed changes' '
mkdir src && mkdir src &&
(cd src && (
git init && cd src &&
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff && git init &&
git add stuff && printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
git commit -m "Initial revision" git add stuff &&
git commit -m "Initial revision"
) && ) &&
git clone src dst && git clone src dst &&
(cd src && (
modify s/5/43/ stuff && cd src &&
git commit -a -m "5->43" && modify s/5/43/ stuff &&
modify s/6/42/ stuff && git commit -a -m "5->43" &&
git commit -a -m "Make it bigger" modify s/6/42/ stuff &&
git commit -a -m "Make it bigger"
) && ) &&
(cd dst && (
modify s/5/43/ stuff && cd dst &&
git commit -a -m "Independent discovery of 5->43" modify s/5/43/ stuff &&
git commit -a -m "Independent discovery of 5->43"
) )
' '
test_expect_success 'git pull --rebase detects upstreamed changes' ' test_expect_success 'git pull --rebase detects upstreamed changes' '
(cd dst && (
git pull --rebase && cd dst &&
test -z "$(git ls-files -u)" git pull --rebase &&
test -z "$(git ls-files -u)"
) )
' '
test_expect_success 'setup for avoiding reapplying old patches' ' test_expect_success 'setup for avoiding reapplying old patches' '
(cd dst && (
test_might_fail git rebase --abort && cd dst &&
git reset --hard origin/master test_might_fail git rebase --abort &&
git reset --hard origin/master
) && ) &&
git clone --bare src src-replace.git && git clone --bare src src-replace.git &&
rm -rf src && rm -rf src &&
mv src-replace.git src && mv src-replace.git src &&
(cd dst && (
modify s/2/22/ stuff && cd dst &&
git commit -a -m "Change 2" && modify s/2/22/ stuff &&
modify s/3/33/ stuff && git commit -a -m "Change 2" &&
git commit -a -m "Change 3" && modify s/3/33/ stuff &&
modify s/4/44/ stuff && git commit -a -m "Change 3" &&
git commit -a -m "Change 4" && modify s/4/44/ stuff &&
git push && git commit -a -m "Change 4" &&
git push &&
modify s/44/55/ stuff && modify s/44/55/ stuff &&
git commit --amend -a -m "Modified Change 4" git commit --amend -a -m "Modified Change 4"
) )
' '
test_expect_success 'git pull --rebase does not reapply old patches' ' test_expect_success 'git pull --rebase does not reapply old patches' '
(cd dst && (
test_must_fail git pull --rebase && cd dst &&
test 1 = $(find .git/rebase-apply -name "000*" | wc -l) test_must_fail git pull --rebase &&
test 1 = $(find .git/rebase-apply -name "000*" | wc -l)
) )
' '