Skip to content

Commit

Permalink
test: use $_z40 from test-lib
Browse files Browse the repository at this point in the history
There is no need to duplicate the definition of $_z40 and $_x40 that
test-lib.sh supplies the test scripts.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Apr 24, 2011
1 parent 87b5054 commit 3749fde
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion t/t1400-update-ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
test_description='Test git update-ref and basic ref logging'
. ./test-lib.sh

Z=0000000000000000000000000000000000000000
Z=$_z40

test_expect_success setup '
Expand Down
7 changes: 3 additions & 4 deletions t/t1501-worktree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ test_expect_success 'setup' '
EMPTY_TREE=$(git write-tree) &&
EMPTY_BLOB=$(git hash-object -t blob --stdin </dev/null) &&
CHANGED_BLOB=$(echo changed | git hash-object -t blob --stdin) &&
ZEROES=0000000000000000000000000000000000000000 &&
EMPTY_BLOB7=$(echo $EMPTY_BLOB | sed "s/\(.......\).*/\1/") &&
CHANGED_BLOB7=$(echo $CHANGED_BLOB | sed "s/\(.......\).*/\1/") &&
Expand Down Expand Up @@ -239,10 +238,10 @@ test_expect_success '_gently() groks relative GIT_DIR & GIT_WORK_TREE' '

test_expect_success 'diff-index respects work tree under .git dir' '
cat >diff-index-cached.expected <<-EOF &&
:000000 100644 $ZEROES $EMPTY_BLOB A sub/dir/tracked
:000000 100644 $_z40 $EMPTY_BLOB A sub/dir/tracked
EOF
cat >diff-index.expected <<-EOF &&
:000000 100644 $ZEROES $ZEROES A sub/dir/tracked
:000000 100644 $_z40 $_z40 A sub/dir/tracked
EOF
(
Expand All @@ -258,7 +257,7 @@ test_expect_success 'diff-index respects work tree under .git dir' '

test_expect_success 'diff-files respects work tree under .git dir' '
cat >diff-files.expected <<-EOF &&
:100644 100644 $EMPTY_BLOB $ZEROES M sub/dir/tracked
:100644 100644 $EMPTY_BLOB $_z40 M sub/dir/tracked
EOF
(
Expand Down
2 changes: 1 addition & 1 deletion t/t2011-checkout-invalid-head.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_expect_success 'checkout should not start branch from a tree' '
'

test_expect_success 'checkout master from invalid HEAD' '
echo 0000000000000000000000000000000000000000 >.git/HEAD &&
echo $_z40 >.git/HEAD &&
git checkout master --
'

Expand Down
2 changes: 0 additions & 2 deletions t/t2201-add-update-typechange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ test_description='more git add -u'

. ./test-lib.sh

_z40=0000000000000000000000000000000000000000

test_expect_success setup '
>xyzzy &&
_empty=$(git hash-object --stdin <xyzzy) &&
Expand Down
4 changes: 2 additions & 2 deletions t/t3200-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test_expect_success \
'git branch a/b/c && test -f .git/refs/heads/a/b/c'

cat >expect <<EOF
0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
EOF
test_expect_success \
'git branch -l d/e/f should create a branch and a log' \
Expand Down Expand Up @@ -214,7 +214,7 @@ test_expect_success \

# Keep this test last, as it changes the current branch
cat >expect <<EOF
0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
EOF
test_expect_success \
'git checkout -b g/h/i -l should create a branch and a log' \
Expand Down
3 changes: 1 addition & 2 deletions t/t3600-rm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,10 @@ test_expect_success 'refresh index before checking if it is up-to-date' '

test_expect_success 'choking "git rm" should not let it die with cruft' '
git reset -q --hard &&
H=0000000000000000000000000000000000000000 &&
i=0 &&
while test $i -lt 12000
do
echo "100644 $H 0 some-file-$i"
echo "100644 $_z40 0 some-file-$i"
i=$(( $i + 1 ))
done | git update-index --index-info &&
git rm -n "some-file-*" | :;
Expand Down
5 changes: 1 addition & 4 deletions t/t4002-diff-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,12 @@ cat >.test-recursive-AB <<\EOF
:100644 100644 3fdbe17fd013303a2e981e1ca1c6cd6e72789087 7e09d6a3a14bd630913e8c75693cea32157b606d M Z/NM
EOF

x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
x40="$x40$x40$x40$x40$x40$x40$x40$x40"
z40='0000000000000000000000000000000000000000'
cmp_diff_files_output () {
# diff-files never reports additions. Also it does not fill in the
# object ID for the changed files because it wants you to look at the
# filesystem.
sed <"$2" >.test-tmp \
-e '/^:000000 /d;s/'$x40'\( [MCRNDU][0-9]*\) /'$z40'\1 /' &&
-e '/^:000000 /d;s/'$_x40'\( [MCRNDU][0-9]*\) /'$_z40'\1 /' &&
test_cmp "$1" .test-tmp
}

Expand Down
2 changes: 0 additions & 2 deletions t/t4020-diff-external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ test_description='external diff interface test'

. ./test-lib.sh

_z40=0000000000000000000000000000000000000000

test_expect_success setup '
test_tick &&
Expand Down
1 change: 0 additions & 1 deletion t/t4027-diff-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ test_description='difference in submodules'
. ./test-lib.sh
. "$TEST_DIRECTORY"/diff-lib.sh

_z40=0000000000000000000000000000000000000000
test_expect_success setup '
test_tick &&
test_create_repo sub &&
Expand Down
4 changes: 2 additions & 2 deletions t/t7011-skip-worktree-reading.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ H sub/2
EOF

NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
ZERO_SHA0=0000000000000000000000000000000000000000

setup_absent() {
test -f 1 && rm 1
git update-index --remove 1 &&
Expand Down Expand Up @@ -120,7 +120,7 @@ test_expect_success 'grep with skip-worktree file' '
test "$(git grep --no-ext-grep test)" = "1:test"
'

echo ":000000 100644 $ZERO_SHA0 $NULL_SHA1 A 1" > expected
echo ":000000 100644 $_z40 $NULL_SHA1 A 1" > expected
test_expect_success 'diff-index does not examine skip-worktree absent entries' '
setup_absent &&
git diff-index HEAD -- 1 > result &&
Expand Down
2 changes: 1 addition & 1 deletion t/t7012-skip-worktree-writing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test_expect_success 'read-tree removes worktree, dirty case' '
'

NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
ZERO_SHA0=0000000000000000000000000000000000000000

setup_absent() {
test -f 1 && rm 1
git update-index --remove 1 &&
Expand Down
3 changes: 3 additions & 0 deletions t/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ esac
_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"

# Zero SHA-1
_z40=0000000000000000000000000000000000000000

# Each test should start with something like this, after copyright notices:
#
# test_description='Description of this test...
Expand Down

0 comments on commit 3749fde

Please sign in to comment.