зеркало из https://github.com/microsoft/git.git
test-lib.sh: introduce and use $EMPTY_TREE
This is a special SHA1. Let's keep it at one place, easier to replace later when the hash change comes, easier to recognize. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
05219a1276
Коммит
f9e7d9f8c3
|
@ -834,7 +834,7 @@ test_expect_success 'git write-tree should be able to write an empty tree' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'validate object ID of a known tree' '
|
test_expect_success 'validate object ID of a known tree' '
|
||||||
test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
test "$tree" = $EMPTY_TREE
|
||||||
'
|
'
|
||||||
|
|
||||||
# Various types of objects
|
# Various types of objects
|
||||||
|
|
|
@ -15,7 +15,7 @@ Also make sure that command line parser understands the normal
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
cat >expected <<EOF
|
cat >expected <<EOF
|
||||||
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
tree $EMPTY_TREE
|
||||||
author Author Name <author@email> 1117148400 +0000
|
author Author Name <author@email> 1117148400 +0000
|
||||||
committer Committer Name <committer@email> 1117150200 +0000
|
committer Committer Name <committer@email> 1117150200 +0000
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,6 @@ test_expect_success 'diff-tree pathspec' '
|
||||||
test_cmp expected current
|
test_cmp expected current
|
||||||
'
|
'
|
||||||
|
|
||||||
EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
||||||
|
|
||||||
test_expect_success 'diff-tree with wildcard shows dir also matches' '
|
test_expect_success 'diff-tree with wildcard shows dir also matches' '
|
||||||
git diff-tree --name-only $EMPTY_TREE $tree -- "f*" >result &&
|
git diff-tree --name-only $EMPTY_TREE $tree -- "f*" >result &&
|
||||||
echo file0 >expected &&
|
echo file0 >expected &&
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
test_description='test diff with a bogus tree containing the null sha1'
|
test_description='test diff with a bogus tree containing the null sha1'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
empty_tree=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
||||||
|
|
||||||
test_expect_success 'create bogus tree' '
|
test_expect_success 'create bogus tree' '
|
||||||
bogus_tree=$(
|
bogus_tree=$(
|
||||||
printf "100644 fooQQQQQQQQQQQQQQQQQQQQQ" |
|
printf "100644 fooQQQQQQQQQQQQQQQQQQQQQ" |
|
||||||
|
@ -22,13 +20,13 @@ test_expect_success 'create tree with matching file' '
|
||||||
|
|
||||||
test_expect_success 'raw diff shows null sha1 (addition)' '
|
test_expect_success 'raw diff shows null sha1 (addition)' '
|
||||||
echo ":000000 100644 $_z40 $_z40 A foo" >expect &&
|
echo ":000000 100644 $_z40 $_z40 A foo" >expect &&
|
||||||
git diff-tree $empty_tree $bogus_tree >actual &&
|
git diff-tree $EMPTY_TREE $bogus_tree >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'raw diff shows null sha1 (removal)' '
|
test_expect_success 'raw diff shows null sha1 (removal)' '
|
||||||
echo ":100644 000000 $_z40 $_z40 D foo" >expect &&
|
echo ":100644 000000 $_z40 $_z40 D foo" >expect &&
|
||||||
git diff-tree $bogus_tree $empty_tree >actual &&
|
git diff-tree $bogus_tree $EMPTY_TREE >actual &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -57,11 +55,11 @@ test_expect_success 'raw diff shows null sha1 (index)' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'patch fails due to bogus sha1 (addition)' '
|
test_expect_success 'patch fails due to bogus sha1 (addition)' '
|
||||||
test_must_fail git diff-tree -p $empty_tree $bogus_tree
|
test_must_fail git diff-tree -p $EMPTY_TREE $bogus_tree
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'patch fails due to bogus sha1 (removal)' '
|
test_expect_success 'patch fails due to bogus sha1 (removal)' '
|
||||||
test_must_fail git diff-tree -p $bogus_tree $empty_tree
|
test_must_fail git diff-tree -p $bogus_tree $EMPTY_TREE
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'patch fails due to bogus sha1 (modification)' '
|
test_expect_success 'patch fails due to bogus sha1 (modification)' '
|
||||||
|
|
|
@ -115,8 +115,8 @@ test_expect_success 'push with transfer.fsckobjects' '
|
||||||
test_cmp exp act
|
test_cmp exp act
|
||||||
'
|
'
|
||||||
|
|
||||||
cat >bogus-commit <<\EOF
|
cat >bogus-commit <<EOF
|
||||||
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
tree $EMPTY_TREE
|
||||||
author Bugs Bunny 1234567890 +0000
|
author Bugs Bunny 1234567890 +0000
|
||||||
committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
|
committer Bugs Bunny <bugs@bun.ni> 1234567890 +0000
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,8 @@ _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
|
||||||
# Zero SHA-1
|
# Zero SHA-1
|
||||||
_z40=0000000000000000000000000000000000000000
|
_z40=0000000000000000000000000000000000000000
|
||||||
|
|
||||||
|
EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||||
|
|
||||||
# Line feed
|
# Line feed
|
||||||
LF='
|
LF='
|
||||||
'
|
'
|
||||||
|
@ -170,7 +172,7 @@ LF='
|
||||||
# when case-folding filenames
|
# when case-folding filenames
|
||||||
u200c=$(printf '\342\200\214')
|
u200c=$(printf '\342\200\214')
|
||||||
|
|
||||||
export _x05 _x40 _z40 LF u200c
|
export _x05 _x40 _z40 LF u200c EMPTY_TREE
|
||||||
|
|
||||||
# Each test should start with something like this, after copyright notices:
|
# Each test should start with something like this, after copyright notices:
|
||||||
#
|
#
|
||||||
|
|
Загрузка…
Ссылка в новой задаче