aboutsummaryrefslogtreecommitdiff
path: root/t/t6010-merge-base.sh
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-05-06 15:58:52 -0500
committerJunio C Hamano <gitster@pobox.com>2011-05-06 14:42:06 -0700
commit73151df0cf3b324fc5f8980774601794c4b88204 (patch)
tree6eca5f8a73a230d2492308e4fbed7225d293f7e1 /t/t6010-merge-base.sh
parentec014eac0e9e6f30cbbca616090fa2ecf74797e7 (diff)
downloadgit-73151df0cf3b324fc5f8980774601794c4b88204.tar.gz
git-73151df0cf3b324fc5f8980774601794c4b88204.tar.xz
tests: eliminate unnecessary setup test assertions
Most of git's tests write files and define shell functions and variables that will last throughout a test script at the top of the script, before all test assertions: . ./test-lib.sh VAR='some value' export VAR >empty fn () { do something } test_expect_success 'setup' ' ... nontrivial commands go here ... ' Two scripts use a different style with this kind of trivial code enclosed by a test assertion; fix them. The usual style is easier to read since there is less indentation to keep track of and no need to worry about nested quotes; and on the other hand, because the commands in question are trivial, it should not make the test suite any worse at catching future bugs in git. While at it, make some other small tweaks: - spell function definitions with a space before () for consistency with other scripts; - use the self-contained command "git mktree </dev/null" in preference to "git write-tree" which looks at the index when writing an empty tree. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t6010-merge-base.sh')
-rwxr-xr-xt/t6010-merge-base.sh50
1 files changed, 25 insertions, 25 deletions
diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh
index 082032edc..f80bba871 100755
--- a/t/t6010-merge-base.sh
+++ b/t/t6010-merge-base.sh
@@ -8,38 +8,38 @@ test_description='Merge base and parent list computation.
. ./test-lib.sh
-test_expect_success 'setup' '
- T=$(git write-tree) &&
+M=1130000000
+Z=+0000
- M=1130000000 &&
- Z=+0000 &&
+GIT_COMMITTER_EMAIL=git@comm.iter.xz
+GIT_COMMITTER_NAME='C O Mmiter'
+GIT_AUTHOR_NAME='A U Thor'
+GIT_AUTHOR_EMAIL=git@au.thor.xz
+export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
- GIT_COMMITTER_EMAIL=git@comm.iter.xz &&
- GIT_COMMITTER_NAME="C O Mmiter" &&
- GIT_AUTHOR_NAME="A U Thor" &&
- GIT_AUTHOR_EMAIL=git@au.thor.xz &&
- export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
+doit () {
+ OFFSET=$1 &&
+ NAME=$2 &&
+ shift 2 &&
- doit() {
- OFFSET=$1 &&
- NAME=$2 &&
- shift 2 &&
+ PARENTS= &&
+ for P
+ do
+ PARENTS="${PARENTS}-p $P "
+ done &&
- PARENTS= &&
- for P
- do
- PARENTS="${PARENTS}-p $P "
- done &&
+ GIT_COMMITTER_DATE="$(($M + $OFFSET)) $Z" &&
+ GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE &&
+ export GIT_COMMITTER_DATE GIT_AUTHOR_DATE &&
- GIT_COMMITTER_DATE="$(($M + $OFFSET)) $Z" &&
- GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE &&
- export GIT_COMMITTER_DATE GIT_AUTHOR_DATE &&
+ commit=$(echo $NAME | git commit-tree $T $PARENTS) &&
- commit=$(echo $NAME | git commit-tree $T $PARENTS) &&
+ echo $commit >.git/refs/tags/$NAME &&
+ echo $commit
+}
- echo $commit >.git/refs/tags/$NAME &&
- echo $commit
- }
+test_expect_success 'setup' '
+ T=$(git mktree </dev/null)
'
test_expect_success 'set up G and H' '