Merge branch 'bc/hash-independent-tests-part-4'
Update to the tests to help SHA-256 transition continues. * bc/hash-independent-tests-part-4: t2203: avoid hard-coded object ID values t1710: make hash independent t1007: remove SHA1 prerequisites t0090: make test pass with SHA-256 t0027: make hash size independent t6030: make test work with SHA-256 t5000: make hash independent t1450: make hash size independent t1410: make hash size independent t: add helper to convert object IDs to paths
This commit is contained in:
commit
a7b27d9e6d
@ -15,8 +15,10 @@ compare_ws_file () {
|
|||||||
pfx=$1
|
pfx=$1
|
||||||
exp=$2.expect
|
exp=$2.expect
|
||||||
act=$pfx.actual.$3
|
act=$pfx.actual.$3
|
||||||
tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" >"$exp" &&
|
tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" |
|
||||||
tr '\015\000abcdef0123456789' QN00000000000000000 <"$3" >"$act" &&
|
sed -e "s/0000*/$ZERO_OID/" >"$exp" &&
|
||||||
|
tr '\015\000abcdef0123456789' QN00000000000000000 <"$3" |
|
||||||
|
sed -e "s/0000*/$ZERO_OID/" >"$act" &&
|
||||||
test_cmp "$exp" "$act" &&
|
test_cmp "$exp" "$act" &&
|
||||||
rm "$exp" "$act"
|
rm "$exp" "$act"
|
||||||
}
|
}
|
||||||
|
@ -162,8 +162,8 @@ test_expect_success PERL 'commit --interactive gives cache-tree on partial commi
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success PERL 'commit -p with shrinking cache-tree' '
|
test_expect_success PERL 'commit -p with shrinking cache-tree' '
|
||||||
mkdir -p deep/subdir &&
|
mkdir -p deep/very-long-subdir &&
|
||||||
echo content >deep/subdir/file &&
|
echo content >deep/very-long-subdir/file &&
|
||||||
git add deep &&
|
git add deep &&
|
||||||
git commit -m add &&
|
git commit -m add &&
|
||||||
git rm -r deep &&
|
git rm -r deep &&
|
||||||
|
@ -9,22 +9,19 @@ echo_without_newline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_blob_does_not_exist() {
|
test_blob_does_not_exist() {
|
||||||
test_expect_success SHA1 'blob does not exist in database' "
|
test_expect_success 'blob does not exist in database' "
|
||||||
test_must_fail git cat-file blob $1
|
test_must_fail git cat-file blob $1
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_blob_exists() {
|
test_blob_exists() {
|
||||||
test_expect_success SHA1 'blob exists in database' "
|
test_expect_success 'blob exists in database' "
|
||||||
git cat-file blob $1
|
git cat-file blob $1
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
hello_content="Hello World"
|
hello_content="Hello World"
|
||||||
hello_sha1=5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689
|
|
||||||
|
|
||||||
example_content="This is an example"
|
example_content="This is an example"
|
||||||
example_sha1=ddd3f836d3e3fbb7ae289aa9ae83536f76956399
|
|
||||||
|
|
||||||
setup_repo() {
|
setup_repo() {
|
||||||
echo_without_newline "$hello_content" > hello
|
echo_without_newline "$hello_content" > hello
|
||||||
@ -44,7 +41,16 @@ pop_repo() {
|
|||||||
rm -rf $test_repo
|
rm -rf $test_repo
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_repo
|
test_expect_success 'setup' '
|
||||||
|
setup_repo &&
|
||||||
|
test_oid_cache <<-EOF
|
||||||
|
hello sha1:5e1c309dae7f45e0f39b1bf3ac3cd9db12e7d689
|
||||||
|
hello sha256:1e3b6c04d2eeb2b3e45c8a330445404c0b7cc7b257e2b097167d26f5230090c4
|
||||||
|
|
||||||
|
example sha1:ddd3f836d3e3fbb7ae289aa9ae83536f76956399
|
||||||
|
example sha256:b44fe1fe65589848253737db859bd490453510719d7424daab03daf0767b85ae
|
||||||
|
EOF
|
||||||
|
'
|
||||||
|
|
||||||
# Argument checking
|
# Argument checking
|
||||||
|
|
||||||
@ -73,23 +79,23 @@ test_expect_success "Can't use --path with --no-filters" '
|
|||||||
|
|
||||||
push_repo
|
push_repo
|
||||||
|
|
||||||
test_expect_success SHA1 'hash a file' '
|
test_expect_success 'hash a file' '
|
||||||
test $hello_sha1 = $(git hash-object hello)
|
test "$(test_oid hello)" = $(git hash-object hello)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_blob_does_not_exist $hello_sha1
|
test_blob_does_not_exist "$(test_oid hello)"
|
||||||
|
|
||||||
test_expect_success SHA1 'hash from stdin' '
|
test_expect_success 'hash from stdin' '
|
||||||
test $example_sha1 = $(git hash-object --stdin < example)
|
test "$(test_oid example)" = $(git hash-object --stdin < example)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_blob_does_not_exist $example_sha1
|
test_blob_does_not_exist "$(test_oid example)"
|
||||||
|
|
||||||
test_expect_success SHA1 'hash a file and write to database' '
|
test_expect_success 'hash a file and write to database' '
|
||||||
test $hello_sha1 = $(git hash-object -w hello)
|
test "$(test_oid hello)" = $(git hash-object -w hello)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_blob_exists $hello_sha1
|
test_blob_exists "$(test_oid hello)"
|
||||||
|
|
||||||
test_expect_success 'git hash-object --stdin file1 <file0 first operates on file0, then file1' '
|
test_expect_success 'git hash-object --stdin file1 <file0 first operates on file0, then file1' '
|
||||||
echo foo > file1 &&
|
echo foo > file1 &&
|
||||||
@ -161,11 +167,11 @@ pop_repo
|
|||||||
for args in "-w --stdin" "--stdin -w"; do
|
for args in "-w --stdin" "--stdin -w"; do
|
||||||
push_repo
|
push_repo
|
||||||
|
|
||||||
test_expect_success SHA1 "hash from stdin and write to database ($args)" '
|
test_expect_success "hash from stdin and write to database ($args)" '
|
||||||
test $example_sha1 = $(git hash-object $args < example)
|
test "$(test_oid example)" = $(git hash-object $args < example)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_blob_exists $example_sha1
|
test_blob_exists "$(test_oid example)"
|
||||||
|
|
||||||
pop_repo
|
pop_repo
|
||||||
done
|
done
|
||||||
@ -173,22 +179,22 @@ done
|
|||||||
filenames="hello
|
filenames="hello
|
||||||
example"
|
example"
|
||||||
|
|
||||||
sha1s="$hello_sha1
|
oids="$(test_oid hello)
|
||||||
$example_sha1"
|
$(test_oid example)"
|
||||||
|
|
||||||
test_expect_success SHA1 "hash two files with names on stdin" '
|
test_expect_success "hash two files with names on stdin" '
|
||||||
test "$sha1s" = "$(echo_without_newline "$filenames" | git hash-object --stdin-paths)"
|
test "$oids" = "$(echo_without_newline "$filenames" | git hash-object --stdin-paths)"
|
||||||
'
|
'
|
||||||
|
|
||||||
for args in "-w --stdin-paths" "--stdin-paths -w"; do
|
for args in "-w --stdin-paths" "--stdin-paths -w"; do
|
||||||
push_repo
|
push_repo
|
||||||
|
|
||||||
test_expect_success SHA1 "hash two files with names on stdin and write to database ($args)" '
|
test_expect_success "hash two files with names on stdin and write to database ($args)" '
|
||||||
test "$sha1s" = "$(echo_without_newline "$filenames" | git hash-object $args)"
|
test "$oids" = "$(echo_without_newline "$filenames" | git hash-object $args)"
|
||||||
'
|
'
|
||||||
|
|
||||||
test_blob_exists $hello_sha1
|
test_blob_exists "$(test_oid hello)"
|
||||||
test_blob_exists $example_sha1
|
test_blob_exists "$(test_oid example)"
|
||||||
|
|
||||||
pop_repo
|
pop_repo
|
||||||
done
|
done
|
||||||
|
@ -30,14 +30,13 @@ check_fsck () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
corrupt () {
|
corrupt () {
|
||||||
aa=${1%??????????????????????????????????????} zz=${1#??}
|
mv .git/objects/$(test_oid_to_path $1) .git/$1
|
||||||
mv .git/objects/$aa/$zz .git/$aa$zz
|
|
||||||
}
|
}
|
||||||
|
|
||||||
recover () {
|
recover () {
|
||||||
aa=${1%??????????????????????????????????????} zz=${1#??}
|
aa=$(echo $1 | cut -c 1-2)
|
||||||
mkdir -p .git/objects/$aa
|
mkdir -p .git/objects/$aa
|
||||||
mv .git/$aa$zz .git/objects/$aa/$zz
|
mv .git/$1 .git/objects/$(test_oid_to_path $1)
|
||||||
}
|
}
|
||||||
|
|
||||||
check_dont_have () {
|
check_dont_have () {
|
||||||
@ -55,6 +54,7 @@ check_dont_have () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
|
test_oid_init &&
|
||||||
mkdir -p A/B &&
|
mkdir -p A/B &&
|
||||||
echo rat >C &&
|
echo rat >C &&
|
||||||
echo ox >A/D &&
|
echo ox >A/D &&
|
||||||
@ -313,12 +313,12 @@ test_expect_success 'stale dirs do not cause d/f conflicts (reflogs off)' '
|
|||||||
# Each line is 114 characters, so we need 75 to still have a few before the
|
# Each line is 114 characters, so we need 75 to still have a few before the
|
||||||
# last 8K. The 89-character padding on the final entry lines up our
|
# last 8K. The 89-character padding on the final entry lines up our
|
||||||
# newline exactly.
|
# newline exactly.
|
||||||
test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' '
|
test_expect_success SHA1 'parsing reverse reflogs at BUFSIZ boundaries' '
|
||||||
git checkout -b reflogskip &&
|
git checkout -b reflogskip &&
|
||||||
z38=00000000000000000000000000000000000000 &&
|
zf=$(test_oid zero_2) &&
|
||||||
ident="abc <xyz> 0000000001 +0000" &&
|
ident="abc <xyz> 0000000001 +0000" &&
|
||||||
for i in $(test_seq 1 75); do
|
for i in $(test_seq 1 75); do
|
||||||
printf "$z38%02d $z38%02d %s\t" $i $(($i+1)) "$ident" &&
|
printf "$zf%02d $zf%02d %s\t" $i $(($i+1)) "$ident" &&
|
||||||
if test $i = 75; then
|
if test $i = 75; then
|
||||||
for j in $(test_seq 1 89); do
|
for j in $(test_seq 1 89); do
|
||||||
printf X
|
printf X
|
||||||
@ -329,7 +329,7 @@ test_expect_success 'parsing reverse reflogs at BUFSIZ boundaries' '
|
|||||||
printf "\n"
|
printf "\n"
|
||||||
done >.git/logs/refs/heads/reflogskip &&
|
done >.git/logs/refs/heads/reflogskip &&
|
||||||
git rev-parse reflogskip@{73} >actual &&
|
git rev-parse reflogskip@{73} >actual &&
|
||||||
echo ${z38}03 >expect &&
|
echo ${zf}03 >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ test_description='git fsck random collection of tests
|
|||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
|
test_oid_init &&
|
||||||
git config gc.auto 0 &&
|
git config gc.auto 0 &&
|
||||||
git config i18n.commitencoding ISO-8859-1 &&
|
git config i18n.commitencoding ISO-8859-1 &&
|
||||||
test_commit A fileA one &&
|
test_commit A fileA one &&
|
||||||
@ -54,8 +55,8 @@ test_expect_success 'setup: helpers for corruption tests' '
|
|||||||
|
|
||||||
test_expect_success 'object with bad sha1' '
|
test_expect_success 'object with bad sha1' '
|
||||||
sha=$(echo blob | git hash-object -w --stdin) &&
|
sha=$(echo blob | git hash-object -w --stdin) &&
|
||||||
old=$(echo $sha | sed "s+^..+&/+") &&
|
old=$(test_oid_to_path "$sha") &&
|
||||||
new=$(dirname $old)/ffffffffffffffffffffffffffffffffffffff &&
|
new=$(dirname $old)/$(test_oid ff_2) &&
|
||||||
sha="$(dirname $new)$(basename $new)" &&
|
sha="$(dirname $new)$(basename $new)" &&
|
||||||
mv .git/objects/$old .git/objects/$new &&
|
mv .git/objects/$old .git/objects/$new &&
|
||||||
test_when_finished "remove_object $sha" &&
|
test_when_finished "remove_object $sha" &&
|
||||||
@ -84,7 +85,7 @@ test_expect_success 'branch pointing to non-commit' '
|
|||||||
test_expect_success 'HEAD link pointing at a funny object' '
|
test_expect_success 'HEAD link pointing at a funny object' '
|
||||||
test_when_finished "mv .git/SAVED_HEAD .git/HEAD" &&
|
test_when_finished "mv .git/SAVED_HEAD .git/HEAD" &&
|
||||||
mv .git/HEAD .git/SAVED_HEAD &&
|
mv .git/HEAD .git/SAVED_HEAD &&
|
||||||
echo 0000000000000000000000000000000000000000 >.git/HEAD &&
|
echo $ZERO_OID >.git/HEAD &&
|
||||||
# avoid corrupt/broken HEAD from interfering with repo discovery
|
# avoid corrupt/broken HEAD from interfering with repo discovery
|
||||||
test_must_fail env GIT_DIR=.git git fsck 2>out &&
|
test_must_fail env GIT_DIR=.git git fsck 2>out &&
|
||||||
cat out &&
|
cat out &&
|
||||||
@ -244,10 +245,16 @@ test_expect_success 'tree object with duplicate entries' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'unparseable tree object' '
|
test_expect_success 'unparseable tree object' '
|
||||||
|
test_oid_cache <<-\EOF &&
|
||||||
|
junk sha1:twenty-bytes-of-junk
|
||||||
|
junk sha256:twenty-bytes-of-junk-twelve-more
|
||||||
|
EOF
|
||||||
|
|
||||||
test_when_finished "git update-ref -d refs/heads/wrong" &&
|
test_when_finished "git update-ref -d refs/heads/wrong" &&
|
||||||
test_when_finished "remove_object \$tree_sha1" &&
|
test_when_finished "remove_object \$tree_sha1" &&
|
||||||
test_when_finished "remove_object \$commit_sha1" &&
|
test_when_finished "remove_object \$commit_sha1" &&
|
||||||
tree_sha1=$(printf "100644 \0twenty-bytes-of-junk" | git hash-object -t tree --stdin -w --literally) &&
|
junk=$(test_oid junk) &&
|
||||||
|
tree_sha1=$(printf "100644 \0$junk" | git hash-object -t tree --stdin -w --literally) &&
|
||||||
commit_sha1=$(git commit-tree $tree_sha1) &&
|
commit_sha1=$(git commit-tree $tree_sha1) &&
|
||||||
git update-ref refs/heads/wrong $commit_sha1 &&
|
git update-ref refs/heads/wrong $commit_sha1 &&
|
||||||
test_must_fail git fsck 2>out &&
|
test_must_fail git fsck 2>out &&
|
||||||
@ -275,8 +282,9 @@ test_expect_success 'tree entry with type mismatch' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'tag pointing to nonexistent' '
|
test_expect_success 'tag pointing to nonexistent' '
|
||||||
cat >invalid-tag <<-\EOF &&
|
badoid=$(test_oid deadbeef) &&
|
||||||
object ffffffffffffffffffffffffffffffffffffffff
|
cat >invalid-tag <<-EOF &&
|
||||||
|
object $badoid
|
||||||
type commit
|
type commit
|
||||||
tag invalid
|
tag invalid
|
||||||
tagger T A Gger <tagger@example.com> 1234567890 -0000
|
tagger T A Gger <tagger@example.com> 1234567890 -0000
|
||||||
@ -386,8 +394,8 @@ test_expect_success 'rev-list --verify-objects' '
|
|||||||
|
|
||||||
test_expect_success 'rev-list --verify-objects with bad sha1' '
|
test_expect_success 'rev-list --verify-objects with bad sha1' '
|
||||||
sha=$(echo blob | git hash-object -w --stdin) &&
|
sha=$(echo blob | git hash-object -w --stdin) &&
|
||||||
old=$(echo $sha | sed "s+^..+&/+") &&
|
old=$(test_oid_to_path $sha) &&
|
||||||
new=$(dirname $old)/ffffffffffffffffffffffffffffffffffffff &&
|
new=$(dirname $old)/$(test_oid ff_2) &&
|
||||||
sha="$(dirname $new)$(basename $new)" &&
|
sha="$(dirname $new)$(basename $new)" &&
|
||||||
mv .git/objects/$old .git/objects/$new &&
|
mv .git/objects/$old .git/objects/$new &&
|
||||||
test_when_finished "remove_object $sha" &&
|
test_when_finished "remove_object $sha" &&
|
||||||
@ -402,7 +410,7 @@ test_expect_success 'rev-list --verify-objects with bad sha1' '
|
|||||||
|
|
||||||
test_might_fail git rev-list --verify-objects refs/heads/bogus >/dev/null 2>out &&
|
test_might_fail git rev-list --verify-objects refs/heads/bogus >/dev/null 2>out &&
|
||||||
cat out &&
|
cat out &&
|
||||||
test_i18ngrep -q "error: hash mismatch 63ffffffffffffffffffffffffffffffffffffff" out
|
test_i18ngrep -q "error: hash mismatch $(dirname $new)$(test_oid ff_2)" out
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'force fsck to ignore double author' '
|
test_expect_success 'force fsck to ignore double author' '
|
||||||
@ -417,13 +425,12 @@ test_expect_success 'force fsck to ignore double author' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
_bz='\0'
|
_bz='\0'
|
||||||
_bz5="$_bz$_bz$_bz$_bz$_bz"
|
_bzoid=$(printf $ZERO_OID | sed -e 's/00/\\0/g')
|
||||||
_bz20="$_bz5$_bz5$_bz5$_bz5"
|
|
||||||
|
|
||||||
test_expect_success 'fsck notices blob entry pointing to null sha1' '
|
test_expect_success 'fsck notices blob entry pointing to null sha1' '
|
||||||
(git init null-blob &&
|
(git init null-blob &&
|
||||||
cd null-blob &&
|
cd null-blob &&
|
||||||
sha=$(printf "100644 file$_bz$_bz20" |
|
sha=$(printf "100644 file$_bz$_bzoid" |
|
||||||
git hash-object -w --stdin -t tree) &&
|
git hash-object -w --stdin -t tree) &&
|
||||||
git fsck 2>out &&
|
git fsck 2>out &&
|
||||||
cat out &&
|
cat out &&
|
||||||
@ -434,7 +441,7 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' '
|
|||||||
test_expect_success 'fsck notices submodule entry pointing to null sha1' '
|
test_expect_success 'fsck notices submodule entry pointing to null sha1' '
|
||||||
(git init null-commit &&
|
(git init null-commit &&
|
||||||
cd null-commit &&
|
cd null-commit &&
|
||||||
sha=$(printf "160000 submodule$_bz$_bz20" |
|
sha=$(printf "160000 submodule$_bz$_bzoid" |
|
||||||
git hash-object -w --stdin -t tree) &&
|
git hash-object -w --stdin -t tree) &&
|
||||||
git fsck 2>out &&
|
git fsck 2>out &&
|
||||||
cat out &&
|
cat out &&
|
||||||
@ -586,7 +593,7 @@ test_expect_success 'fsck --connectivity-only' '
|
|||||||
# its type. That lets us see that --connectivity-only is
|
# its type. That lets us see that --connectivity-only is
|
||||||
# not actually looking at the contents, but leaves it
|
# not actually looking at the contents, but leaves it
|
||||||
# free to examine the type if it chooses.
|
# free to examine the type if it chooses.
|
||||||
empty=.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 &&
|
empty=.git/objects/$(test_oid_to_path $EMPTY_BLOB) &&
|
||||||
blob=$(echo unrelated | git hash-object -w --stdin) &&
|
blob=$(echo unrelated | git hash-object -w --stdin) &&
|
||||||
mv -f $(sha1_file $blob) $empty &&
|
mv -f $(sha1_file $blob) $empty &&
|
||||||
|
|
||||||
@ -631,10 +638,12 @@ test_expect_success 'fsck --name-objects' '
|
|||||||
|
|
||||||
test_expect_success 'alternate objects are correctly blamed' '
|
test_expect_success 'alternate objects are correctly blamed' '
|
||||||
test_when_finished "rm -rf alt.git .git/objects/info/alternates" &&
|
test_when_finished "rm -rf alt.git .git/objects/info/alternates" &&
|
||||||
|
name=$(test_oid numeric) &&
|
||||||
|
path=$(test_oid_to_path "$name") &&
|
||||||
git init --bare alt.git &&
|
git init --bare alt.git &&
|
||||||
echo "../../alt.git/objects" >.git/objects/info/alternates &&
|
echo "../../alt.git/objects" >.git/objects/info/alternates &&
|
||||||
mkdir alt.git/objects/12 &&
|
mkdir alt.git/objects/$(dirname $path) &&
|
||||||
>alt.git/objects/12/34567890123456789012345678901234567890 &&
|
>alt.git/objects/$(dirname $path)/$(basename $path) &&
|
||||||
test_must_fail git fsck >out 2>&1 &&
|
test_must_fail git fsck >out 2>&1 &&
|
||||||
test_i18ngrep alt.git out
|
test_i18ngrep alt.git out
|
||||||
'
|
'
|
||||||
|
@ -20,6 +20,22 @@ create_non_racy_file () {
|
|||||||
test-tool chmtime =-5 "$1"
|
test-tool chmtime =-5 "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_expect_success 'setup' '
|
||||||
|
test_oid_cache <<-EOF
|
||||||
|
own_v3 sha1:8299b0bcd1ac364e5f1d7768efb62fa2da79a339
|
||||||
|
own_v3 sha256:38a6d2925e3eceec33ad7b34cbff4e0086caa0daf28f31e51f5bd94b4a7af86b
|
||||||
|
|
||||||
|
base_v3 sha1:39d890139ee5356c7ef572216cebcd27aa41f9df
|
||||||
|
base_v3 sha256:c9baeadf905112bf6c17aefbd7d02267afd70ded613c30cafed2d40cb506e1ed
|
||||||
|
|
||||||
|
own_v4 sha1:432ef4b63f32193984f339431fd50ca796493569
|
||||||
|
own_v4 sha256:6738ac6319c25b694afa7bcc313deb182d1a59b68bf7a47b4296de83478c0420
|
||||||
|
|
||||||
|
base_v4 sha1:508851a7f0dfa8691e9f69c7f055865389012491
|
||||||
|
base_v4 sha256:3177d4adfdd4b6904f7e921d91d715a471c0dde7cf6a4bba574927f02b699508
|
||||||
|
EOF
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'enable split index' '
|
test_expect_success 'enable split index' '
|
||||||
git config splitIndex.maxPercentChange 100 &&
|
git config splitIndex.maxPercentChange 100 &&
|
||||||
git update-index --split-index &&
|
git update-index --split-index &&
|
||||||
@ -29,11 +45,11 @@ test_expect_success 'enable split index' '
|
|||||||
# NEEDSWORK: Stop hard-coding checksums.
|
# NEEDSWORK: Stop hard-coding checksums.
|
||||||
if test "$indexversion" = "4"
|
if test "$indexversion" = "4"
|
||||||
then
|
then
|
||||||
own=432ef4b63f32193984f339431fd50ca796493569
|
own=$(test_oid own_v4)
|
||||||
base=508851a7f0dfa8691e9f69c7f055865389012491
|
base=$(test_oid base_v4)
|
||||||
else
|
else
|
||||||
own=8299b0bcd1ac364e5f1d7768efb62fa2da79a339
|
own=$(test_oid own_v3)
|
||||||
base=39d890139ee5356c7ef572216cebcd27aa41f9df
|
base=$(test_oid base_v3)
|
||||||
fi &&
|
fi &&
|
||||||
|
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
@ -99,17 +115,18 @@ test_expect_success 'enable split index again, "one" now belongs to base index"'
|
|||||||
|
|
||||||
test_expect_success 'modify original file, base index untouched' '
|
test_expect_success 'modify original file, base index untouched' '
|
||||||
echo modified | create_non_racy_file one &&
|
echo modified | create_non_racy_file one &&
|
||||||
|
file1_blob=$(git hash-object one) &&
|
||||||
git update-index one &&
|
git update-index one &&
|
||||||
git ls-files --stage >ls-files.actual &&
|
git ls-files --stage >ls-files.actual &&
|
||||||
cat >ls-files.expect <<-EOF &&
|
cat >ls-files.expect <<-EOF &&
|
||||||
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
|
100644 $file1_blob 0 one
|
||||||
EOF
|
EOF
|
||||||
test_cmp ls-files.expect ls-files.actual &&
|
test_cmp ls-files.expect ls-files.actual &&
|
||||||
|
|
||||||
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
||||||
q_to_tab >expect <<-EOF &&
|
q_to_tab >expect <<-EOF &&
|
||||||
$BASE
|
$BASE
|
||||||
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
|
100644 $file1_blob 0Q
|
||||||
replacements: 0
|
replacements: 0
|
||||||
deletions:
|
deletions:
|
||||||
EOF
|
EOF
|
||||||
@ -121,7 +138,7 @@ test_expect_success 'add another file, which stays index' '
|
|||||||
git update-index --add two &&
|
git update-index --add two &&
|
||||||
git ls-files --stage >ls-files.actual &&
|
git ls-files --stage >ls-files.actual &&
|
||||||
cat >ls-files.expect <<-EOF &&
|
cat >ls-files.expect <<-EOF &&
|
||||||
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
|
100644 $file1_blob 0 one
|
||||||
100644 $EMPTY_BLOB 0 two
|
100644 $EMPTY_BLOB 0 two
|
||||||
EOF
|
EOF
|
||||||
test_cmp ls-files.expect ls-files.actual &&
|
test_cmp ls-files.expect ls-files.actual &&
|
||||||
@ -129,7 +146,7 @@ test_expect_success 'add another file, which stays index' '
|
|||||||
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
||||||
q_to_tab >expect <<-EOF &&
|
q_to_tab >expect <<-EOF &&
|
||||||
$BASE
|
$BASE
|
||||||
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
|
100644 $file1_blob 0Q
|
||||||
100644 $EMPTY_BLOB 0 two
|
100644 $EMPTY_BLOB 0 two
|
||||||
replacements: 0
|
replacements: 0
|
||||||
deletions:
|
deletions:
|
||||||
@ -141,14 +158,14 @@ test_expect_success 'remove file not in base index' '
|
|||||||
git update-index --force-remove two &&
|
git update-index --force-remove two &&
|
||||||
git ls-files --stage >ls-files.actual &&
|
git ls-files --stage >ls-files.actual &&
|
||||||
cat >ls-files.expect <<-EOF &&
|
cat >ls-files.expect <<-EOF &&
|
||||||
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0 one
|
100644 $file1_blob 0 one
|
||||||
EOF
|
EOF
|
||||||
test_cmp ls-files.expect ls-files.actual &&
|
test_cmp ls-files.expect ls-files.actual &&
|
||||||
|
|
||||||
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
||||||
q_to_tab >expect <<-EOF &&
|
q_to_tab >expect <<-EOF &&
|
||||||
$BASE
|
$BASE
|
||||||
100644 2e0996000b7e9019eabcad29391bf0f5c7702f0b 0Q
|
100644 $file1_blob 0Q
|
||||||
replacements: 0
|
replacements: 0
|
||||||
deletions:
|
deletions:
|
||||||
EOF
|
EOF
|
||||||
@ -237,9 +254,9 @@ test_expect_success 'set core.splitIndex config variable to true' '
|
|||||||
git update-index --add three &&
|
git update-index --add three &&
|
||||||
git ls-files --stage >ls-files.actual &&
|
git ls-files --stage >ls-files.actual &&
|
||||||
cat >ls-files.expect <<-EOF &&
|
cat >ls-files.expect <<-EOF &&
|
||||||
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
|
100644 $EMPTY_BLOB 0 one
|
||||||
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 three
|
100644 $EMPTY_BLOB 0 three
|
||||||
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
|
100644 $EMPTY_BLOB 0 two
|
||||||
EOF
|
EOF
|
||||||
test_cmp ls-files.expect ls-files.actual &&
|
test_cmp ls-files.expect ls-files.actual &&
|
||||||
BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
|
BASE=$(test-tool dump-split-index .git/index | grep "^base") &&
|
||||||
@ -257,8 +274,8 @@ test_expect_success 'set core.splitIndex config variable to false' '
|
|||||||
git update-index --force-remove three &&
|
git update-index --force-remove three &&
|
||||||
git ls-files --stage >ls-files.actual &&
|
git ls-files --stage >ls-files.actual &&
|
||||||
cat >ls-files.expect <<-EOF &&
|
cat >ls-files.expect <<-EOF &&
|
||||||
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 one
|
100644 $EMPTY_BLOB 0 one
|
||||||
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 two
|
100644 $EMPTY_BLOB 0 two
|
||||||
EOF
|
EOF
|
||||||
test_cmp ls-files.expect ls-files.actual &&
|
test_cmp ls-files.expect ls-files.actual &&
|
||||||
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
||||||
@ -285,7 +302,7 @@ test_expect_success 'set core.splitIndex config variable back to true' '
|
|||||||
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
$BASE
|
$BASE
|
||||||
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 four
|
100644 $EMPTY_BLOB 0 four
|
||||||
replacements:
|
replacements:
|
||||||
deletions:
|
deletions:
|
||||||
EOF
|
EOF
|
||||||
@ -309,7 +326,7 @@ test_expect_success 'check behavior with splitIndex.maxPercentChange unset' '
|
|||||||
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
test-tool dump-split-index .git/index | sed "/^own/d" >actual &&
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
$BASE
|
$BASE
|
||||||
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 six
|
100644 $EMPTY_BLOB 0 six
|
||||||
replacements:
|
replacements:
|
||||||
deletions:
|
deletions:
|
||||||
EOF
|
EOF
|
||||||
|
@ -247,12 +247,14 @@ test_expect_success 'diff-files/diff-cached shows ita as new/not-new files' '
|
|||||||
test_expect_success '"diff HEAD" includes ita as new files' '
|
test_expect_success '"diff HEAD" includes ita as new files' '
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
echo new >new-ita &&
|
echo new >new-ita &&
|
||||||
|
oid=$(git hash-object new-ita) &&
|
||||||
|
oid=$(git rev-parse --short $oid) &&
|
||||||
git add -N new-ita &&
|
git add -N new-ita &&
|
||||||
git diff HEAD >actual &&
|
git diff HEAD >actual &&
|
||||||
cat >expected <<-\EOF &&
|
cat >expected <<-EOF &&
|
||||||
diff --git a/new-ita b/new-ita
|
diff --git a/new-ita b/new-ita
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..3e75765
|
index 0000000..$oid
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/new-ita
|
+++ b/new-ita
|
||||||
@@ -0,0 +1 @@
|
@@ -0,0 +1 @@
|
||||||
|
@ -94,6 +94,13 @@ check_tar() {
|
|||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_expect_success 'setup' '
|
||||||
|
test_oid_cache <<-EOF
|
||||||
|
obj sha1:19f9c8273ec45a8938e6999cb59b3ff66739902a
|
||||||
|
obj sha256:3c666f798798601571f5cec0adb57ce4aba8546875e7693177e0535f34d2c49b
|
||||||
|
EOF
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'populate workdir' \
|
'populate workdir' \
|
||||||
'mkdir a &&
|
'mkdir a &&
|
||||||
@ -369,11 +376,10 @@ test_lazy_prereq TAR_HUGE '
|
|||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success LONG_IS_64BIT 'set up repository with huge blob' '
|
test_expect_success LONG_IS_64BIT 'set up repository with huge blob' '
|
||||||
obj_d=19 &&
|
obj=$(test_oid obj) &&
|
||||||
obj_f=f9c8273ec45a8938e6999cb59b3ff66739902a &&
|
path=$(test_oid_to_path $obj) &&
|
||||||
obj=${obj_d}${obj_f} &&
|
mkdir -p .git/objects/$(dirname $path) &&
|
||||||
mkdir -p .git/objects/$obj_d &&
|
cp "$TEST_DIRECTORY"/t5000/huge-object .git/objects/$path &&
|
||||||
cp "$TEST_DIRECTORY"/t5000/$obj .git/objects/$obj_d/$obj_f &&
|
|
||||||
rm -f .git/index &&
|
rm -f .git/index &&
|
||||||
git update-index --add --cacheinfo 100644,$obj,huge &&
|
git update-index --add --cacheinfo 100644,$obj,huge &&
|
||||||
git commit -m huge
|
git commit -m huge
|
||||||
|
@ -615,6 +615,7 @@ test_expect_success 'broken branch creation' '
|
|||||||
git add missing/MISSING &&
|
git add missing/MISSING &&
|
||||||
git commit -m "6(broken): Added file that will be deleted" &&
|
git commit -m "6(broken): Added file that will be deleted" &&
|
||||||
git tag BROKEN_HASH6 &&
|
git tag BROKEN_HASH6 &&
|
||||||
|
deleted=$(git rev-parse --verify HEAD:missing) &&
|
||||||
add_line_into_file "7(broken): second line on a broken branch" hello2 &&
|
add_line_into_file "7(broken): second line on a broken branch" hello2 &&
|
||||||
git tag BROKEN_HASH7 &&
|
git tag BROKEN_HASH7 &&
|
||||||
add_line_into_file "8(broken): third line on a broken branch" hello2 &&
|
add_line_into_file "8(broken): third line on a broken branch" hello2 &&
|
||||||
@ -622,12 +623,12 @@ test_expect_success 'broken branch creation' '
|
|||||||
git rm missing/MISSING &&
|
git rm missing/MISSING &&
|
||||||
git commit -m "9(broken): Remove missing file" &&
|
git commit -m "9(broken): Remove missing file" &&
|
||||||
git tag BROKEN_HASH9 &&
|
git tag BROKEN_HASH9 &&
|
||||||
rm .git/objects/39/f7e61a724187ab767d2e08442d9b6b9dab587d
|
rm .git/objects/$(test_oid_to_path $deleted)
|
||||||
'
|
'
|
||||||
|
|
||||||
echo "" > expected.ok
|
echo "" > expected.ok
|
||||||
cat > expected.missing-tree.default <<EOF
|
cat > expected.missing-tree.default <<EOF
|
||||||
fatal: unable to read tree 39f7e61a724187ab767d2e08442d9b6b9dab587d
|
fatal: unable to read tree $deleted
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'bisect fails if tree is broken on start commit' '
|
test_expect_success 'bisect fails if tree is broken on start commit' '
|
||||||
@ -713,12 +714,12 @@ test_expect_success 'bisect: demonstrate identification of damage boundary' "
|
|||||||
"
|
"
|
||||||
|
|
||||||
cat > expected.bisect-log <<EOF
|
cat > expected.bisect-log <<EOF
|
||||||
# bad: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
|
# bad: [$HASH4] Add <4: Ciao for now> into <hello>.
|
||||||
# good: [7b7f204a749c3125d5224ed61ea2ae1187ad046f] Add <2: A new day for git> into <hello>.
|
# good: [$HASH2] Add <2: A new day for git> into <hello>.
|
||||||
git bisect start '32a594a3fdac2d57cf6d02987e30eec68511498c' '7b7f204a749c3125d5224ed61ea2ae1187ad046f'
|
git bisect start '$HASH4' '$HASH2'
|
||||||
# good: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
|
# good: [$HASH3] Add <3: Another new day for git> into <hello>.
|
||||||
git bisect good 3de952f2416b6084f557ec417709eac740c6818c
|
git bisect good $HASH3
|
||||||
# first bad commit: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
|
# first bad commit: [$HASH4] Add <4: Ciao for now> into <hello>.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'bisect log: successful result' '
|
test_expect_success 'bisect log: successful result' '
|
||||||
@ -731,14 +732,14 @@ test_expect_success 'bisect log: successful result' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
cat > expected.bisect-skip-log <<EOF
|
cat > expected.bisect-skip-log <<EOF
|
||||||
# bad: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
|
# bad: [$HASH4] Add <4: Ciao for now> into <hello>.
|
||||||
# good: [7b7f204a749c3125d5224ed61ea2ae1187ad046f] Add <2: A new day for git> into <hello>.
|
# good: [$HASH2] Add <2: A new day for git> into <hello>.
|
||||||
git bisect start '32a594a3fdac2d57cf6d02987e30eec68511498c' '7b7f204a749c3125d5224ed61ea2ae1187ad046f'
|
git bisect start '$HASH4' '$HASH2'
|
||||||
# skip: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
|
# skip: [$HASH3] Add <3: Another new day for git> into <hello>.
|
||||||
git bisect skip 3de952f2416b6084f557ec417709eac740c6818c
|
git bisect skip $HASH3
|
||||||
# only skipped commits left to test
|
# only skipped commits left to test
|
||||||
# possible first bad commit: [32a594a3fdac2d57cf6d02987e30eec68511498c] Add <4: Ciao for now> into <hello>.
|
# possible first bad commit: [$HASH4] Add <4: Ciao for now> into <hello>.
|
||||||
# possible first bad commit: [3de952f2416b6084f557ec417709eac740c6818c] Add <3: Another new day for git> into <hello>.
|
# possible first bad commit: [$HASH3] Add <3: Another new day for git> into <hello>.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_expect_success 'bisect log: only skip commits left' '
|
test_expect_success 'bisect log: only skip commits left' '
|
||||||
|
@ -1430,6 +1430,12 @@ test_oid () {
|
|||||||
eval "printf '%s' \"\${$var}\""
|
eval "printf '%s' \"\${$var}\""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Insert a slash into an object ID so it can be used to reference a location
|
||||||
|
# under ".git/objects". For example, "deadbeef..." becomes "de/adbeef..".
|
||||||
|
test_oid_to_path () {
|
||||||
|
echo "${1%${1#??}}/${1#??}"
|
||||||
|
}
|
||||||
|
|
||||||
# Choose a port number based on the test script's number and store it in
|
# Choose a port number based on the test script's number and store it in
|
||||||
# the given variable name, unless that variable already contains a number.
|
# the given variable name, unless that variable already contains a number.
|
||||||
test_set_port () {
|
test_set_port () {
|
||||||
|
Loading…
Reference in New Issue
Block a user