2007-01-18 19:26:24 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Shawn Pearce
|
|
|
|
#
|
|
|
|
|
2008-09-09 23:25:25 +02:00
|
|
|
test_description='test git fast-import utility'
|
2007-01-18 19:26:24 +01:00
|
|
|
. ./test-lib.sh
|
2008-08-08 11:26:28 +02:00
|
|
|
. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
|
2007-01-18 19:26:24 +01:00
|
|
|
|
2010-12-13 10:28:05 +01:00
|
|
|
# Print $1 bytes from stdin to stdout.
|
|
|
|
#
|
|
|
|
# This could be written as "head -c $1", but IRIX "head" does not
|
|
|
|
# support the -c option.
|
|
|
|
head_c () {
|
2013-10-29 02:23:03 +01:00
|
|
|
perl -e '
|
2010-12-13 10:28:05 +01:00
|
|
|
my $len = $ARGV[1];
|
|
|
|
while ($len > 0) {
|
|
|
|
my $s;
|
|
|
|
my $nread = sysread(STDIN, $s, $len);
|
|
|
|
die "cannot read: $!" unless defined($nread);
|
|
|
|
print $s;
|
|
|
|
$len -= $nread;
|
|
|
|
}
|
|
|
|
' - "$1"
|
|
|
|
}
|
|
|
|
|
2012-04-20 08:25:09 +02:00
|
|
|
verify_packs () {
|
|
|
|
for p in .git/objects/pack/*.pack
|
|
|
|
do
|
|
|
|
git verify-pack "$@" "$p" || return
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2007-01-18 20:49:05 +01:00
|
|
|
file2_data='file2
|
|
|
|
second line of EOF'
|
|
|
|
|
|
|
|
file3_data='EOF
|
|
|
|
in 3rd file
|
|
|
|
END'
|
|
|
|
|
|
|
|
file4_data=abcd
|
|
|
|
file4_len=4
|
|
|
|
|
2007-01-18 21:17:58 +01:00
|
|
|
file5_data='an inline file.
|
|
|
|
we should see it later.'
|
|
|
|
|
|
|
|
file6_data='#!/bin/sh
|
|
|
|
echo "$@"'
|
|
|
|
|
2010-11-28 20:45:01 +01:00
|
|
|
>empty
|
|
|
|
|
2007-01-18 19:26:24 +01:00
|
|
|
###
|
|
|
|
### series A
|
|
|
|
###
|
|
|
|
|
|
|
|
test_tick
|
2010-11-28 20:45:01 +01:00
|
|
|
|
|
|
|
test_expect_success 'empty stream succeeds' '
|
|
|
|
git fast-import </dev/null
|
|
|
|
'
|
|
|
|
|
2007-01-18 19:26:24 +01:00
|
|
|
cat >input <<INPUT_END
|
|
|
|
blob
|
|
|
|
mark :2
|
|
|
|
data <<EOF
|
2007-01-18 20:49:05 +01:00
|
|
|
$file2_data
|
2007-01-18 19:26:24 +01:00
|
|
|
EOF
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :3
|
|
|
|
data <<END
|
2007-01-18 20:49:05 +01:00
|
|
|
$file3_data
|
2007-01-18 19:26:24 +01:00
|
|
|
END
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :4
|
2007-01-18 20:49:05 +01:00
|
|
|
data $file4_len
|
|
|
|
$file4_data
|
2007-01-18 19:26:24 +01:00
|
|
|
commit refs/heads/master
|
|
|
|
mark :5
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
initial
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 :2 file2
|
|
|
|
M 644 :3 file3
|
|
|
|
M 755 :4 file4
|
|
|
|
|
2008-12-19 23:41:21 +01:00
|
|
|
tag series-A
|
|
|
|
from :5
|
|
|
|
data <<EOF
|
|
|
|
An annotated tag without a tagger
|
|
|
|
EOF
|
|
|
|
|
2011-08-22 14:10:18 +02:00
|
|
|
tag series-A-blob
|
|
|
|
from :3
|
|
|
|
data <<EOF
|
|
|
|
An annotated tag that annotates a blob.
|
|
|
|
EOF
|
|
|
|
|
2007-01-18 19:26:24 +01:00
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'A: create pack from stdin' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import --export-marks=marks.out <input &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git whatchanged master'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'A: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
initial
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'A: verify commit' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cat-file commit master | sed 1d >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
100644 blob file2
|
|
|
|
100644 blob file3
|
|
|
|
100755 blob file4
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'A: verify tree' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
2007-01-18 20:49:05 +01:00
|
|
|
echo "$file2_data" >expect
|
2007-01-18 19:26:24 +01:00
|
|
|
test_expect_success \
|
|
|
|
'A: verify file2' \
|
2008-05-24 07:28:56 +02:00
|
|
|
'git cat-file blob master:file2 >actual && test_cmp expect actual'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
2007-01-18 20:49:05 +01:00
|
|
|
echo "$file3_data" >expect
|
2007-01-18 19:26:24 +01:00
|
|
|
test_expect_success \
|
|
|
|
'A: verify file3' \
|
2008-05-24 07:28:56 +02:00
|
|
|
'git cat-file blob master:file3 >actual && test_cmp expect actual'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
2007-01-18 20:49:05 +01:00
|
|
|
printf "$file4_data" >expect
|
2007-01-18 19:26:24 +01:00
|
|
|
test_expect_success \
|
|
|
|
'A: verify file4' \
|
2008-05-24 07:28:56 +02:00
|
|
|
'git cat-file blob master:file4 >actual && test_cmp expect actual'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
2008-12-19 23:41:21 +01:00
|
|
|
cat >expect <<EOF
|
|
|
|
object $(git rev-parse refs/heads/master)
|
|
|
|
type commit
|
|
|
|
tag series-A
|
|
|
|
|
|
|
|
An annotated tag without a tagger
|
|
|
|
EOF
|
|
|
|
test_expect_success 'A: verify tag/series-A' '
|
|
|
|
git cat-file tag tags/series-A >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-08-22 14:10:18 +02:00
|
|
|
cat >expect <<EOF
|
|
|
|
object $(git rev-parse refs/heads/master:file3)
|
|
|
|
type blob
|
|
|
|
tag series-A-blob
|
|
|
|
|
|
|
|
An annotated tag that annotates a blob.
|
|
|
|
EOF
|
|
|
|
test_expect_success 'A: verify tag/series-A-blob' '
|
|
|
|
git cat-file tag tags/series-A-blob >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2007-01-18 19:26:24 +01:00
|
|
|
cat >expect <<EOF
|
2007-07-03 07:52:14 +02:00
|
|
|
:2 `git rev-parse --verify master:file2`
|
|
|
|
:3 `git rev-parse --verify master:file3`
|
|
|
|
:4 `git rev-parse --verify master:file4`
|
|
|
|
:5 `git rev-parse --verify master^0`
|
2007-01-18 19:26:24 +01:00
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'A: verify marks output' \
|
2008-05-24 07:28:56 +02:00
|
|
|
'test_cmp expect marks.out'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
2007-03-08 00:07:26 +01:00
|
|
|
test_expect_success \
|
|
|
|
'A: verify marks import' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import \
|
2007-03-08 00:07:26 +01:00
|
|
|
--import-marks=marks.out \
|
|
|
|
--export-marks=marks.new \
|
|
|
|
</dev/null &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect marks.new'
|
2007-03-08 00:07:26 +01:00
|
|
|
|
2011-08-22 14:10:18 +02:00
|
|
|
test_tick
|
2011-08-22 14:10:19 +02:00
|
|
|
new_blob=$(echo testing | git hash-object --stdin)
|
2011-08-22 14:10:18 +02:00
|
|
|
cat >input <<INPUT_END
|
|
|
|
tag series-A-blob-2
|
|
|
|
from $(git rev-parse refs/heads/master:file3)
|
|
|
|
data <<EOF
|
|
|
|
Tag blob by sha1.
|
|
|
|
EOF
|
2011-08-22 14:10:19 +02:00
|
|
|
|
|
|
|
blob
|
|
|
|
mark :6
|
|
|
|
data <<EOF
|
|
|
|
testing
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/heads/new_blob
|
|
|
|
committer <> 0 +0000
|
|
|
|
data 0
|
|
|
|
M 644 :6 new_blob
|
|
|
|
#pretend we got sha1 from fast-import
|
|
|
|
ls "new_blob"
|
|
|
|
|
|
|
|
tag series-A-blob-3
|
|
|
|
from $new_blob
|
|
|
|
data <<EOF
|
|
|
|
Tag new_blob.
|
|
|
|
EOF
|
2011-08-22 14:10:18 +02:00
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
object $(git rev-parse refs/heads/master:file3)
|
|
|
|
type blob
|
|
|
|
tag series-A-blob-2
|
|
|
|
|
|
|
|
Tag blob by sha1.
|
2011-08-22 14:10:19 +02:00
|
|
|
object $new_blob
|
|
|
|
type blob
|
|
|
|
tag series-A-blob-3
|
|
|
|
|
|
|
|
Tag new_blob.
|
2011-08-22 14:10:18 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'A: tag blob by sha1' \
|
|
|
|
'git fast-import <input &&
|
|
|
|
git cat-file tag tags/series-A-blob-2 >actual &&
|
2011-08-22 14:10:19 +02:00
|
|
|
git cat-file tag tags/series-A-blob-3 >>actual &&
|
2011-08-22 14:10:18 +02:00
|
|
|
test_cmp expect actual'
|
|
|
|
|
2007-05-24 06:32:31 +02:00
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/verify--import-marks
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
recreate from :5
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from :5
|
|
|
|
M 755 :2 copy-of-file2
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'A: verify marks import does not crash' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import --import-marks=marks.out <input &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git whatchanged verify--import-marks'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'A: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
|
|
|
|
2007-05-24 06:32:31 +02:00
|
|
|
cat >expect <<EOF
|
|
|
|
:000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
|
|
|
|
EOF
|
2007-07-03 07:52:14 +02:00
|
|
|
git diff-tree -M -r master verify--import-marks >actual
|
2007-05-24 06:32:31 +02:00
|
|
|
test_expect_success \
|
|
|
|
'A: verify diff' \
|
|
|
|
'compare_diff_raw expect actual &&
|
2007-07-03 07:52:14 +02:00
|
|
|
test `git rev-parse --verify master:file2` \
|
|
|
|
= `git rev-parse --verify verify--import-marks:copy-of-file2`'
|
2007-05-24 06:32:31 +02:00
|
|
|
|
2010-07-13 13:51:48 +02:00
|
|
|
test_tick
|
|
|
|
mt=$(git hash-object --stdin < /dev/null)
|
|
|
|
: >input.blob
|
|
|
|
: >marks.exp
|
|
|
|
: >tree.exp
|
|
|
|
|
|
|
|
cat >input.commit <<EOF
|
|
|
|
commit refs/heads/verify--dump-marks
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
test the sparse array dumping routines with exponentially growing marks
|
|
|
|
COMMIT
|
|
|
|
EOF
|
|
|
|
|
|
|
|
i=0
|
|
|
|
l=4
|
|
|
|
m=6
|
|
|
|
n=7
|
|
|
|
while test "$i" -lt 27; do
|
|
|
|
cat >>input.blob <<EOF
|
|
|
|
blob
|
|
|
|
mark :$l
|
|
|
|
data 0
|
|
|
|
blob
|
|
|
|
mark :$m
|
|
|
|
data 0
|
|
|
|
blob
|
|
|
|
mark :$n
|
|
|
|
data 0
|
|
|
|
EOF
|
|
|
|
echo "M 100644 :$l l$i" >>input.commit
|
|
|
|
echo "M 100644 :$m m$i" >>input.commit
|
|
|
|
echo "M 100644 :$n n$i" >>input.commit
|
|
|
|
|
|
|
|
echo ":$l $mt" >>marks.exp
|
|
|
|
echo ":$m $mt" >>marks.exp
|
|
|
|
echo ":$n $mt" >>marks.exp
|
|
|
|
|
|
|
|
printf "100644 blob $mt\tl$i\n" >>tree.exp
|
|
|
|
printf "100644 blob $mt\tm$i\n" >>tree.exp
|
|
|
|
printf "100644 blob $mt\tn$i\n" >>tree.exp
|
|
|
|
|
|
|
|
l=$(($l + $l))
|
|
|
|
m=$(($m + $m))
|
|
|
|
n=$(($l + $n))
|
|
|
|
|
|
|
|
i=$((1 + $i))
|
|
|
|
done
|
|
|
|
|
|
|
|
sort tree.exp > tree.exp_s
|
|
|
|
|
|
|
|
test_expect_success 'A: export marks with large values' '
|
|
|
|
cat input.blob input.commit | git fast-import --export-marks=marks.large &&
|
|
|
|
git ls-tree refs/heads/verify--dump-marks >tree.out &&
|
|
|
|
test_cmp tree.exp_s tree.out &&
|
|
|
|
test_cmp marks.exp marks.large'
|
|
|
|
|
2007-01-18 19:26:24 +01:00
|
|
|
###
|
|
|
|
### series B
|
|
|
|
###
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/branch
|
|
|
|
mark :1
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
corrupt
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/master
|
|
|
|
M 755 0000000000000000000000000000000000000001 zero1
|
|
|
|
|
|
|
|
INPUT_END
|
2008-02-01 10:50:53 +01:00
|
|
|
test_expect_success 'B: fail on invalid blob sha1' '
|
2008-09-09 23:25:25 +02:00
|
|
|
test_must_fail git fast-import <input
|
2008-02-01 10:50:53 +01:00
|
|
|
'
|
2007-01-18 19:26:24 +01:00
|
|
|
rm -f .git/objects/pack_* .git/objects/index_*
|
|
|
|
|
2007-08-03 05:37:21 +02:00
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit TEMP_TAG
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
tag base
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/master
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'B: accept branch name "TEMP_TAG"' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-08-03 05:37:21 +02:00
|
|
|
test -f .git/TEMP_TAG &&
|
|
|
|
test `git rev-parse master` = `git rev-parse TEMP_TAG^`'
|
|
|
|
rm -f .git/TEMP_TAG
|
|
|
|
|
2011-08-11 12:21:06 +02:00
|
|
|
git gc 2>/dev/null >/dev/null
|
|
|
|
git prune 2>/dev/null >/dev/null
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/empty-committer-1
|
|
|
|
committer <> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
empty commit
|
|
|
|
COMMIT
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success 'B: accept empty committer' '
|
|
|
|
git fast-import <input &&
|
|
|
|
out=$(git fsck) &&
|
|
|
|
echo "$out" &&
|
|
|
|
test -z "$out"
|
|
|
|
'
|
|
|
|
git update-ref -d refs/heads/empty-committer-1 || true
|
|
|
|
|
|
|
|
git gc 2>/dev/null >/dev/null
|
|
|
|
git prune 2>/dev/null >/dev/null
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/empty-committer-2
|
|
|
|
committer <a@b.com> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
empty commit
|
|
|
|
COMMIT
|
|
|
|
INPUT_END
|
2011-08-11 12:21:07 +02:00
|
|
|
test_expect_success 'B: accept and fixup committer with no name' '
|
2011-08-11 12:21:06 +02:00
|
|
|
git fast-import <input &&
|
|
|
|
out=$(git fsck) &&
|
|
|
|
echo "$out" &&
|
|
|
|
test -z "$out"
|
|
|
|
'
|
|
|
|
git update-ref -d refs/heads/empty-committer-2 || true
|
|
|
|
|
|
|
|
git gc 2>/dev/null >/dev/null
|
|
|
|
git prune 2>/dev/null >/dev/null
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/invalid-committer
|
|
|
|
committer Name email> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
empty commit
|
|
|
|
COMMIT
|
|
|
|
INPUT_END
|
2011-08-11 12:21:08 +02:00
|
|
|
test_expect_success 'B: fail on invalid committer (1)' '
|
2011-08-11 12:21:06 +02:00
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
git update-ref -d refs/heads/invalid-committer || true
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/invalid-committer
|
|
|
|
committer Name <e<mail> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
empty commit
|
|
|
|
COMMIT
|
|
|
|
INPUT_END
|
2011-08-11 12:21:08 +02:00
|
|
|
test_expect_success 'B: fail on invalid committer (2)' '
|
2011-08-11 12:21:06 +02:00
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
git update-ref -d refs/heads/invalid-committer || true
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/invalid-committer
|
|
|
|
committer Name <email>> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
empty commit
|
|
|
|
COMMIT
|
|
|
|
INPUT_END
|
2011-08-11 12:21:08 +02:00
|
|
|
test_expect_success 'B: fail on invalid committer (3)' '
|
2011-08-11 12:21:06 +02:00
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
git update-ref -d refs/heads/invalid-committer || true
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/invalid-committer
|
|
|
|
committer Name <email $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
empty commit
|
|
|
|
COMMIT
|
|
|
|
INPUT_END
|
2011-08-11 12:21:08 +02:00
|
|
|
test_expect_success 'B: fail on invalid committer (4)' '
|
2011-08-11 12:21:06 +02:00
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
git update-ref -d refs/heads/invalid-committer || true
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/invalid-committer
|
|
|
|
committer Name<email> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
empty commit
|
|
|
|
COMMIT
|
|
|
|
INPUT_END
|
2011-08-11 12:21:08 +02:00
|
|
|
test_expect_success 'B: fail on invalid committer (5)' '
|
2011-08-11 12:21:06 +02:00
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
git update-ref -d refs/heads/invalid-committer || true
|
|
|
|
|
2007-01-18 19:26:24 +01:00
|
|
|
###
|
|
|
|
### series C
|
|
|
|
###
|
|
|
|
|
2008-09-09 23:25:25 +02:00
|
|
|
newf=`echo hi newf | git hash-object -w --stdin`
|
2007-07-03 07:52:14 +02:00
|
|
|
oldf=`git rev-parse --verify master:file2`
|
2007-01-18 19:26:24 +01:00
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/branch
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
second
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/master
|
|
|
|
M 644 $oldf file2/oldf
|
|
|
|
M 755 $newf file2/newf
|
|
|
|
D file3
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'C: incremental import create pack from stdin' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git whatchanged branch'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'C: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
|
|
|
|
2007-01-18 19:26:24 +01:00
|
|
|
test_expect_success \
|
|
|
|
'C: validate reuse existing blob' \
|
2010-10-31 02:46:54 +01:00
|
|
|
'test $newf = `git rev-parse --verify branch:file2/newf` &&
|
2007-07-03 07:52:14 +02:00
|
|
|
test $oldf = `git rev-parse --verify branch:file2/oldf`'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
2007-07-03 07:52:14 +02:00
|
|
|
parent `git rev-parse --verify master^0`
|
2007-01-18 19:26:24 +01:00
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
second
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'C: verify commit' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cat-file commit branch | sed 1d >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-01-18 19:26:24 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
|
|
|
|
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2 file2/oldf
|
|
|
|
:100644 000000 0d92e9f3374ae2947c23aa477cbc68ce598135f1 0000000000000000000000000000000000000000 D file3
|
|
|
|
EOF
|
2007-07-03 07:52:14 +02:00
|
|
|
git diff-tree -M -r master branch >actual
|
2007-01-18 19:26:24 +01:00
|
|
|
test_expect_success \
|
|
|
|
'C: validate rename result' \
|
|
|
|
'compare_diff_raw expect actual'
|
|
|
|
|
2007-01-18 21:17:58 +01:00
|
|
|
###
|
|
|
|
### series D
|
|
|
|
###
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/branch
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
third
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
M 644 inline newdir/interesting
|
|
|
|
data <<EOF
|
|
|
|
$file5_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 755 inline newdir/exec.sh
|
|
|
|
data <<EOF
|
|
|
|
$file6_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'D: inline data in commit' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git whatchanged branch'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'D: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
2007-01-18 21:17:58 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
2015-02-15 22:35:19 +01:00
|
|
|
:000000 100755 0000000000000000000000000000000000000000 e74b7d465e52746be2b4bae983670711e6e66657 A newdir/exec.sh
|
|
|
|
:000000 100644 0000000000000000000000000000000000000000 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 A newdir/interesting
|
2007-01-18 21:17:58 +01:00
|
|
|
EOF
|
2007-07-03 07:52:14 +02:00
|
|
|
git diff-tree -M -r branch^ branch >actual
|
2007-01-18 21:17:58 +01:00
|
|
|
test_expect_success \
|
|
|
|
'D: validate new files added' \
|
|
|
|
'compare_diff_raw expect actual'
|
|
|
|
|
|
|
|
echo "$file5_data" >expect
|
|
|
|
test_expect_success \
|
|
|
|
'D: verify file5' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cat-file blob branch:newdir/interesting >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-01-18 21:17:58 +01:00
|
|
|
|
|
|
|
echo "$file6_data" >expect
|
|
|
|
test_expect_success \
|
|
|
|
'D: verify file6' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cat-file blob branch:newdir/exec.sh >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-01-18 21:17:58 +01:00
|
|
|
|
2007-02-06 20:58:30 +01:00
|
|
|
###
|
|
|
|
### series E
|
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/branch
|
|
|
|
author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> Tue Feb 6 11:22:18 2007 -0500
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> Tue Feb 6 12:35:02 2007 -0500
|
|
|
|
data <<COMMIT
|
|
|
|
RFC 2822 type date
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
|
|
|
|
INPUT_END
|
2008-02-01 10:50:53 +01:00
|
|
|
test_expect_success 'E: rfc2822 date, --date-format=raw' '
|
2008-09-09 23:25:25 +02:00
|
|
|
test_must_fail git fast-import --date-format=raw <input
|
2008-02-01 10:50:53 +01:00
|
|
|
'
|
2007-02-06 20:58:30 +01:00
|
|
|
test_expect_success \
|
|
|
|
'E: rfc2822 date, --date-format=rfc2822' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import --date-format=rfc2822 <input'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'E: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
2007-02-06 20:58:30 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1170783302 -0500
|
|
|
|
|
|
|
|
RFC 2822 type date
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'E: verify commit' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cat-file commit branch | sed 1,2d >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-02-06 20:58:30 +01:00
|
|
|
|
2007-02-06 22:08:06 +01:00
|
|
|
###
|
|
|
|
### series F
|
|
|
|
###
|
|
|
|
|
2007-07-03 07:52:14 +02:00
|
|
|
old_branch=`git rev-parse --verify branch^0`
|
2007-02-06 22:08:06 +01:00
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/branch
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
losing things already?
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch~1
|
|
|
|
|
|
|
|
reset refs/heads/other
|
|
|
|
from refs/heads/branch
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'F: non-fast-forward update skips' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'if git fast-import <input
|
2007-02-06 22:08:06 +01:00
|
|
|
then
|
|
|
|
echo BAD gfi did not fail
|
|
|
|
return 1
|
|
|
|
else
|
2007-07-03 07:52:14 +02:00
|
|
|
if test $old_branch = `git rev-parse --verify branch^0`
|
2007-02-06 22:08:06 +01:00
|
|
|
then
|
|
|
|
: branch unaffected and failure returned
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echo BAD gfi changed branch $old_branch
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'F: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
2007-02-06 22:08:06 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
2007-07-03 07:52:14 +02:00
|
|
|
tree `git rev-parse branch~1^{tree}`
|
|
|
|
parent `git rev-parse branch~1`
|
2007-02-06 22:08:06 +01:00
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
losing things already?
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'F: verify other commit' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cat-file commit other >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-02-06 22:08:06 +01:00
|
|
|
|
|
|
|
###
|
|
|
|
### series G
|
|
|
|
###
|
|
|
|
|
2007-07-03 07:52:14 +02:00
|
|
|
old_branch=`git rev-parse --verify branch^0`
|
2007-02-06 22:08:06 +01:00
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/branch
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
losing things already?
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch~1
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'G: non-fast-forward update forced' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import --force <input'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'G: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
|
|
|
|
2007-02-06 22:08:06 +01:00
|
|
|
test_expect_success \
|
|
|
|
'G: branch changed, but logged' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'test $old_branch != `git rev-parse --verify branch^0` &&
|
|
|
|
test $old_branch = `git rev-parse --verify branch@{1}`'
|
2007-02-06 22:08:06 +01:00
|
|
|
|
2007-02-07 08:03:03 +01:00
|
|
|
###
|
|
|
|
### series H
|
|
|
|
###
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/H
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
third
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
M 644 inline i-will-die
|
|
|
|
data <<EOF
|
|
|
|
this file will never exist.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
deleteall
|
|
|
|
M 644 inline h/e/l/lo
|
|
|
|
data <<EOF
|
|
|
|
$file5_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'H: deletall, add 1' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-03 07:52:14 +02:00
|
|
|
git whatchanged H'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'H: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
2007-02-07 08:03:03 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
|
|
|
|
:100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file2/oldf
|
|
|
|
:100755 000000 85df50785d62d3b05ab03d9cbf7e4a0b49449730 0000000000000000000000000000000000000000 D file4
|
|
|
|
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting h/e/l/lo
|
|
|
|
:100755 000000 e74b7d465e52746be2b4bae983670711e6e66657 0000000000000000000000000000000000000000 D newdir/exec.sh
|
|
|
|
EOF
|
2007-07-03 07:52:14 +02:00
|
|
|
git diff-tree -M -r H^ H >actual
|
2007-02-07 08:03:03 +01:00
|
|
|
test_expect_success \
|
|
|
|
'H: validate old files removed, new files added' \
|
|
|
|
'compare_diff_raw expect actual'
|
|
|
|
|
|
|
|
echo "$file5_data" >expect
|
|
|
|
test_expect_success \
|
|
|
|
'H: verify file' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'git cat-file blob H:h/e/l/lo >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-02-07 08:03:03 +01:00
|
|
|
|
2007-02-12 01:45:56 +01:00
|
|
|
###
|
|
|
|
### series I
|
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/export-boundary
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
we have a border. its only 40 characters wide.
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'I: export-pack-edges' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import --export-pack-edges=edges.list <input'
|
2007-02-12 01:45:56 +01:00
|
|
|
|
|
|
|
cat >expect <<EOF
|
2007-07-03 07:52:14 +02:00
|
|
|
.git/objects/pack/pack-.pack: `git rev-parse --verify export-boundary`
|
2007-02-12 01:45:56 +01:00
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'I: verify edge list' \
|
|
|
|
'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-02-12 01:45:56 +01:00
|
|
|
|
2007-02-12 10:08:43 +01:00
|
|
|
###
|
|
|
|
### series J
|
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/J
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
create J
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch
|
|
|
|
|
|
|
|
reset refs/heads/J
|
|
|
|
|
|
|
|
commit refs/heads/J
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
initialize J
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'J: reset existing branch creates empty commit' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input'
|
2007-02-12 10:08:43 +01:00
|
|
|
test_expect_success \
|
|
|
|
'J: branch has 1 commit, empty tree' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'test 1 = `git rev-list J | wc -l` &&
|
2007-02-12 10:08:43 +01:00
|
|
|
test 0 = `git ls-tree J | wc -l`'
|
|
|
|
|
2011-09-22 21:47:04 +02:00
|
|
|
cat >input <<INPUT_END
|
|
|
|
reset refs/heads/J2
|
|
|
|
|
|
|
|
tag wrong_tag
|
|
|
|
from refs/heads/J2
|
|
|
|
data <<EOF
|
|
|
|
Tag branch that was reset.
|
|
|
|
EOF
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'J: tag must fail on empty branch' \
|
|
|
|
'test_must_fail git fast-import <input'
|
2007-02-12 10:08:43 +01:00
|
|
|
###
|
|
|
|
### series K
|
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/K
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
create K
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch
|
|
|
|
|
|
|
|
commit refs/heads/K
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
redo K
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^1
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'K: reinit branch with from' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input'
|
2007-02-12 10:08:43 +01:00
|
|
|
test_expect_success \
|
|
|
|
'K: verify K^1 = branch^1' \
|
2007-07-03 07:52:14 +02:00
|
|
|
'test `git rev-parse --verify branch^1` \
|
|
|
|
= `git rev-parse --verify K^1`'
|
2007-02-12 10:08:43 +01:00
|
|
|
|
2007-03-12 19:58:50 +01:00
|
|
|
###
|
|
|
|
### series L
|
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data <<EOF
|
|
|
|
some data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :2
|
|
|
|
data <<EOF
|
|
|
|
other data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/heads/L
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
create L
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 :1 b.
|
|
|
|
M 644 :1 b/other
|
|
|
|
M 644 :1 ba
|
|
|
|
|
|
|
|
commit refs/heads/L
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
update L
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 :2 b.
|
|
|
|
M 644 :2 b/other
|
|
|
|
M 644 :2 ba
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EXPECT_END
|
|
|
|
:100644 100644 4268632... 55d3a52... M b.
|
|
|
|
:040000 040000 0ae5cac... 443c768... M b
|
|
|
|
:100644 100644 4268632... 55d3a52... M ba
|
|
|
|
EXPECT_END
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'L: verify internal tree sorting' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-29 11:49:56 +02:00
|
|
|
git diff-tree --abbrev --raw L^ L >output &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect output'
|
2007-03-12 19:58:50 +01:00
|
|
|
|
2011-08-14 20:32:23 +02:00
|
|
|
cat >input <<INPUT_END
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data <<EOF
|
|
|
|
the data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/heads/L2
|
|
|
|
committer C O Mitter <committer@example.com> 1112912473 -0700
|
|
|
|
data <<COMMIT
|
|
|
|
init L2
|
|
|
|
COMMIT
|
|
|
|
M 644 :1 a/b/c
|
|
|
|
M 644 :1 a/b/d
|
|
|
|
M 644 :1 a/e/f
|
|
|
|
|
|
|
|
commit refs/heads/L2
|
|
|
|
committer C O Mitter <committer@example.com> 1112912473 -0700
|
|
|
|
data <<COMMIT
|
|
|
|
update L2
|
|
|
|
COMMIT
|
|
|
|
C a g
|
|
|
|
C a/e g/b
|
|
|
|
M 644 :1 g/b/h
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat <<EOF >expect
|
|
|
|
g/b/f
|
|
|
|
g/b/h
|
|
|
|
EOF
|
|
|
|
|
2011-08-14 20:32:24 +02:00
|
|
|
test_expect_success \
|
2011-08-14 20:32:23 +02:00
|
|
|
'L: nested tree copy does not corrupt deltas' \
|
|
|
|
'git fast-import <input &&
|
|
|
|
git ls-tree L2 g/b/ >tmp &&
|
|
|
|
cat tmp | cut -f 2 >actual &&
|
|
|
|
test_cmp expect actual &&
|
|
|
|
git fsck `git rev-parse L2`'
|
|
|
|
|
|
|
|
git update-ref -d refs/heads/L2
|
|
|
|
|
2007-07-10 04:58:23 +02:00
|
|
|
###
|
|
|
|
### series M
|
|
|
|
###
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/M1
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
file rename
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
R file2/newf file2/n.e.w.f
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf file2/n.e.w.f
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'M: rename file in same subdirectory' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-10 04:58:23 +02:00
|
|
|
git diff-tree -M -r M1^ M1 >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/M2
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
file rename
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
R file2/newf i/am/new/to/you
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 file2/newf i/am/new/to/you
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'M: rename file to new subdirectory' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-10 04:58:23 +02:00
|
|
|
git diff-tree -M -r M2^ M2 >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/M3
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
file rename
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/M2^0
|
|
|
|
R i other/sub
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you other/sub/am/new/to/you
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'M: rename subdirectory to new subdirectory' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-10 04:58:23 +02:00
|
|
|
git diff-tree -M -r M3^ M3 >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
2013-06-23 16:58:19 +02:00
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/M4
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
rename root
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/M2^0
|
|
|
|
R "" sub
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 R100 file2/oldf sub/file2/oldf
|
|
|
|
:100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 R100 file4 sub/file4
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc R100 i/am/new/to/you sub/i/am/new/to/you
|
|
|
|
:100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 R100 newdir/exec.sh sub/newdir/exec.sh
|
|
|
|
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 R100 newdir/interesting sub/newdir/interesting
|
|
|
|
EOF
|
2013-06-23 16:58:22 +02:00
|
|
|
test_expect_success \
|
2013-06-23 16:58:19 +02:00
|
|
|
'M: rename root to subdirectory' \
|
|
|
|
'git fast-import <input &&
|
|
|
|
git diff-tree -M -r M4^ M4 >actual &&
|
|
|
|
cat actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
2007-07-15 07:40:37 +02:00
|
|
|
###
|
|
|
|
### series N
|
|
|
|
###
|
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/N1
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
file copy
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
C file2/newf file2/n.e.w.f
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file2/n.e.w.f
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'N: copy file in same subdirectory' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-15 07:40:37 +02:00
|
|
|
git diff-tree -C --find-copies-harder -r N1^ N1 >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/N2
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
clean directory copy
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
C file2 file3
|
|
|
|
|
|
|
|
commit refs/heads/N2
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
modify directory copy
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline file3/file5
|
|
|
|
data <<EOF
|
|
|
|
$file5_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
|
|
|
|
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'N: copy then modify subdirectory' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-07-15 07:40:37 +02:00
|
|
|
git diff-tree -C --find-copies-harder -r N2^^ N2 >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/N3
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
dirty directory copy
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
M 644 inline file2/file5
|
|
|
|
data <<EOF
|
|
|
|
$file5_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
C file2 file3
|
|
|
|
D file2/file5
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'N: copy dirty subdirectory' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
|
|
|
test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
|
2007-07-15 07:40:37 +02:00
|
|
|
|
2010-07-01 05:18:19 +02:00
|
|
|
test_expect_success \
|
|
|
|
'N: copy directory by id' \
|
|
|
|
'cat >expect <<-\EOF &&
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
|
|
|
|
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
|
|
|
|
EOF
|
|
|
|
subdir=$(git rev-parse refs/heads/branch^0:file2) &&
|
|
|
|
cat >input <<-INPUT_END &&
|
|
|
|
commit refs/heads/N4
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy by tree hash
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
M 040000 $subdir file3
|
|
|
|
INPUT_END
|
|
|
|
git fast-import <input &&
|
|
|
|
git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
fast-import: add 'ls' command
Lazy fast-import frontend authors that want to rely on the backend to
keep track of the content of the imported trees _almost_ have what
they need in the 'cat-blob' command (v1.7.4-rc0~30^2~3, 2010-11-28).
But it is not quite enough, since
(1) cat-blob can be used to retrieve the content of files, but
not their mode, and
(2) using cat-blob requires the frontend to keep track of a name
(mark number or object id) for each blob to be retrieved
Introduce an 'ls' command to complement cat-blob and take care of the
remaining needs. The 'ls' command finds what is at a given path
within a given tree-ish (tag, commit, or tree):
'ls' SP <dataref> SP <path> LF
or in fast-import's active commit:
'ls' SP <path> LF
The response is a single line sent through the cat-blob channel,
imitating ls-tree output. So for example:
FE> ls :1 Documentation
gfi> 040000 tree 9e6c2b599341d28a2a375f8207507e0a2a627fe9 Documentation
FE> ls 9e6c2b599341d28a2a375f8207507e0a2a627fe9 git-fast-import.txt
gfi> 100644 blob 4f92954396e3f0f97e75b6838a5635b583708870 git-fast-import.txt
FE> ls :1 RelNotes
gfi> 120000 blob b942e499449d97aeb50c73ca2bdc1c6e6d528743 RelNotes
FE> cat-blob b942e499449d97aeb50c73ca2bdc1c6e6d528743
gfi> b942e499449d97aeb50c73ca2bdc1c6e6d528743 blob 32
gfi> Documentation/RelNotes/1.7.4.txt
The most interesting parts of the reply are the first word, which is
a 6-digit octal mode (regular file, executable, symlink, directory,
or submodule), and the part from the second space to the tab, which is
a <dataref> that can be used in later cat-blob, ls, and filemodify (M)
commands to refer to the content (blob, tree, or commit) at that path.
If there is nothing there, the response is "missing some/path".
The intent is for this command to be used to read files from the
active commit, so a frontend can apply patches to them, and to copy
files and directories from previous revisions.
For example, proposed updates to svn-fe use this command in place of
its internal representation of the repository directory structure.
This simplifies the frontend a great deal and means support for
resuming an import in a separate fast-import run (i.e., incremental
import) is basically free.
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Improved-by: Junio C Hamano <gitster@pobox.com>
Improved-by: Sverre Rabbelier <srabbelier@gmail.com>
2010-12-02 11:40:20 +01:00
|
|
|
test_expect_success PIPE 'N: read and copy directory' '
|
|
|
|
cat >expect <<-\EOF
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
|
|
|
|
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
|
|
|
|
EOF
|
|
|
|
git update-ref -d refs/heads/N4 &&
|
|
|
|
rm -f backflow &&
|
|
|
|
mkfifo backflow &&
|
|
|
|
(
|
|
|
|
exec <backflow &&
|
|
|
|
cat <<-EOF &&
|
|
|
|
commit refs/heads/N4
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy by tree hash, part 2
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
ls "file2"
|
|
|
|
EOF
|
|
|
|
read mode type tree filename &&
|
|
|
|
echo "M 040000 $tree file3"
|
|
|
|
) |
|
|
|
|
git fast-import --cat-blob-fd=3 3>backflow &&
|
|
|
|
git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
|
|
|
|
compare_diff_raw expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success PIPE 'N: empty directory reads as missing' '
|
|
|
|
cat <<-\EOF >expect &&
|
|
|
|
OBJNAME
|
|
|
|
:000000 100644 OBJNAME OBJNAME A unrelated
|
|
|
|
EOF
|
|
|
|
echo "missing src" >expect.response &&
|
|
|
|
git update-ref -d refs/heads/read-empty &&
|
|
|
|
rm -f backflow &&
|
|
|
|
mkfifo backflow &&
|
|
|
|
(
|
|
|
|
exec <backflow &&
|
|
|
|
cat <<-EOF &&
|
|
|
|
commit refs/heads/read-empty
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
read "empty" (missing) directory
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 100644 inline src/greeting
|
|
|
|
data <<BLOB
|
|
|
|
hello
|
|
|
|
BLOB
|
|
|
|
C src/greeting dst1/non-greeting
|
|
|
|
C src/greeting unrelated
|
|
|
|
# leave behind "empty" src directory
|
|
|
|
D src/greeting
|
|
|
|
ls "src"
|
|
|
|
EOF
|
|
|
|
read -r line &&
|
|
|
|
printf "%s\n" "$line" >response &&
|
|
|
|
cat <<-\EOF
|
|
|
|
D dst1
|
|
|
|
D dst2
|
|
|
|
EOF
|
|
|
|
) |
|
|
|
|
git fast-import --cat-blob-fd=3 3>backflow &&
|
|
|
|
test_cmp expect.response response &&
|
|
|
|
git rev-list read-empty |
|
|
|
|
git diff-tree -r --root --stdin |
|
|
|
|
sed "s/$_x40/OBJNAME/g" >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2010-10-10 05:30:15 +02:00
|
|
|
test_expect_success \
|
|
|
|
'N: copy root directory by tree hash' \
|
|
|
|
'cat >expect <<-\EOF &&
|
|
|
|
:100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file3/newf
|
|
|
|
:100644 000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 0000000000000000000000000000000000000000 D file3/oldf
|
|
|
|
EOF
|
|
|
|
root=$(git rev-parse refs/heads/branch^0^{tree}) &&
|
|
|
|
cat >input <<-INPUT_END &&
|
|
|
|
commit refs/heads/N6
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy root directory by tree hash
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
M 040000 $root ""
|
|
|
|
INPUT_END
|
|
|
|
git fast-import <input &&
|
|
|
|
git diff-tree -C --find-copies-harder -r N4 N6 >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
2013-06-23 16:58:21 +02:00
|
|
|
test_expect_success \
|
2013-06-23 16:58:19 +02:00
|
|
|
'N: copy root by path' \
|
|
|
|
'cat >expect <<-\EOF &&
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf oldroot/file2/newf
|
|
|
|
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf oldroot/file2/oldf
|
|
|
|
:100755 100755 85df50785d62d3b05ab03d9cbf7e4a0b49449730 85df50785d62d3b05ab03d9cbf7e4a0b49449730 C100 file4 oldroot/file4
|
|
|
|
:100755 100755 e74b7d465e52746be2b4bae983670711e6e66657 e74b7d465e52746be2b4bae983670711e6e66657 C100 newdir/exec.sh oldroot/newdir/exec.sh
|
|
|
|
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting oldroot/newdir/interesting
|
|
|
|
EOF
|
|
|
|
cat >input <<-INPUT_END &&
|
|
|
|
commit refs/heads/N-copy-root-path
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy root directory by (empty) path
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
C "" oldroot
|
|
|
|
INPUT_END
|
|
|
|
git fast-import <input &&
|
|
|
|
git diff-tree -C --find-copies-harder -r branch N-copy-root-path >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
2011-01-27 07:07:49 +01:00
|
|
|
test_expect_success \
|
|
|
|
'N: delete directory by copying' \
|
|
|
|
'cat >expect <<-\EOF &&
|
|
|
|
OBJID
|
|
|
|
:100644 000000 OBJID OBJID D foo/bar/qux
|
|
|
|
OBJID
|
|
|
|
:000000 100644 OBJID OBJID A foo/bar/baz
|
|
|
|
:000000 100644 OBJID OBJID A foo/bar/qux
|
|
|
|
EOF
|
|
|
|
empty_tree=$(git mktree </dev/null) &&
|
|
|
|
cat >input <<-INPUT_END &&
|
|
|
|
commit refs/heads/N-delete
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
collect data to be deleted
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
deleteall
|
|
|
|
M 100644 inline foo/bar/baz
|
|
|
|
data <<DATA_END
|
|
|
|
hello
|
|
|
|
DATA_END
|
|
|
|
C "foo/bar/baz" "foo/bar/qux"
|
|
|
|
C "foo/bar/baz" "foo/bar/quux/1"
|
|
|
|
C "foo/bar/baz" "foo/bar/quuux"
|
|
|
|
M 040000 $empty_tree foo/bar/quux
|
|
|
|
M 040000 $empty_tree foo/bar/quuux
|
|
|
|
|
|
|
|
commit refs/heads/N-delete
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
delete subdirectory
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 040000 $empty_tree foo/bar/qux
|
|
|
|
INPUT_END
|
|
|
|
git fast-import <input &&
|
|
|
|
git rev-list N-delete |
|
|
|
|
git diff-tree -r --stdin --root --always |
|
|
|
|
sed -e "s/$_x40/OBJID/g" >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
2010-07-01 05:18:19 +02:00
|
|
|
test_expect_success \
|
|
|
|
'N: modify copied tree' \
|
|
|
|
'cat >expect <<-\EOF &&
|
|
|
|
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
|
|
|
|
:100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
|
|
|
|
:100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
|
|
|
|
EOF
|
|
|
|
subdir=$(git rev-parse refs/heads/branch^0:file2) &&
|
|
|
|
cat >input <<-INPUT_END &&
|
|
|
|
commit refs/heads/N5
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy by tree hash
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
M 040000 $subdir file3
|
|
|
|
|
|
|
|
commit refs/heads/N5
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
modify directory copy
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline file3/file5
|
|
|
|
data <<EOF
|
|
|
|
$file5_data
|
|
|
|
EOF
|
|
|
|
INPUT_END
|
|
|
|
git fast-import <input &&
|
|
|
|
git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
|
|
|
|
compare_diff_raw expect actual'
|
|
|
|
|
fast-import: tighten M 040000 syntax
When tree_content_set() is asked to modify the path "foo/bar/",
it first recurses like so:
tree_content_set(root, "foo/bar/", sha1, S_IFDIR) ->
tree_content_set(root:foo, "bar/", ...) ->
tree_content_set(root:foo/bar, "", ...)
And as a side-effect of 2794ad5 (fast-import: Allow filemodify to set
the root, 2010-10-10), this last call is accepted and changes
the tree entry for root:foo/bar to refer to the specified tree.
That seems safe enough but let's reject the new syntax (we never meant
to support it) and make it harder for frontends to introduce pointless
incompatibilities with git fast-import 1.7.3.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-18 03:08:53 +02:00
|
|
|
test_expect_success \
|
|
|
|
'N: reject foo/ syntax' \
|
|
|
|
'subdir=$(git rev-parse refs/heads/branch^0:file2) &&
|
|
|
|
test_must_fail git fast-import <<-INPUT_END
|
|
|
|
commit refs/heads/N5B
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy with invalid syntax
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
M 040000 $subdir file3/
|
|
|
|
INPUT_END'
|
|
|
|
|
2012-03-10 05:07:22 +01:00
|
|
|
test_expect_success \
|
|
|
|
'N: reject foo/ syntax in copy source' \
|
|
|
|
'test_must_fail git fast-import <<-INPUT_END
|
|
|
|
commit refs/heads/N5C
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy with invalid syntax
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
C file2/ file3
|
|
|
|
INPUT_END'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'N: reject foo/ syntax in rename source' \
|
|
|
|
'test_must_fail git fast-import <<-INPUT_END
|
|
|
|
commit refs/heads/N5D
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
rename with invalid syntax
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
R file2/ file3
|
|
|
|
INPUT_END'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'N: reject foo/ syntax in ls argument' \
|
|
|
|
'test_must_fail git fast-import <<-INPUT_END
|
|
|
|
commit refs/heads/N5E
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy with invalid syntax
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/branch^0
|
|
|
|
ls "file2/"
|
|
|
|
INPUT_END'
|
|
|
|
|
2010-10-18 03:03:38 +02:00
|
|
|
test_expect_success \
|
|
|
|
'N: copy to root by id and modify' \
|
|
|
|
'echo "hello, world" >expect.foo &&
|
|
|
|
echo hello >expect.bar &&
|
|
|
|
git fast-import <<-SETUP_END &&
|
|
|
|
commit refs/heads/N7
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
hello, tree
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
deleteall
|
|
|
|
M 644 inline foo/bar
|
|
|
|
data <<EOF
|
|
|
|
hello
|
|
|
|
EOF
|
|
|
|
SETUP_END
|
|
|
|
|
|
|
|
tree=$(git rev-parse --verify N7:) &&
|
|
|
|
git fast-import <<-INPUT_END &&
|
|
|
|
commit refs/heads/N8
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy to root by id and modify
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 040000 $tree ""
|
|
|
|
M 644 inline foo/foo
|
|
|
|
data <<EOF
|
|
|
|
hello, world
|
|
|
|
EOF
|
|
|
|
INPUT_END
|
|
|
|
git show N8:foo/foo >actual.foo &&
|
|
|
|
git show N8:foo/bar >actual.bar &&
|
|
|
|
test_cmp expect.foo actual.foo &&
|
|
|
|
test_cmp expect.bar actual.bar'
|
|
|
|
|
fast-import: tighten M 040000 syntax
When tree_content_set() is asked to modify the path "foo/bar/",
it first recurses like so:
tree_content_set(root, "foo/bar/", sha1, S_IFDIR) ->
tree_content_set(root:foo, "bar/", ...) ->
tree_content_set(root:foo/bar, "", ...)
And as a side-effect of 2794ad5 (fast-import: Allow filemodify to set
the root, 2010-10-10), this last call is accepted and changes
the tree entry for root:foo/bar to refer to the specified tree.
That seems safe enough but let's reject the new syntax (we never meant
to support it) and make it harder for frontends to introduce pointless
incompatibilities with git fast-import 1.7.3.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-18 03:08:53 +02:00
|
|
|
test_expect_success \
|
|
|
|
'N: extract subtree' \
|
|
|
|
'branch=$(git rev-parse --verify refs/heads/branch^{tree}) &&
|
|
|
|
cat >input <<-INPUT_END &&
|
|
|
|
commit refs/heads/N9
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
extract subtree branch:newdir
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 040000 $branch ""
|
2010-10-18 03:44:04 +02:00
|
|
|
C "newdir" ""
|
fast-import: tighten M 040000 syntax
When tree_content_set() is asked to modify the path "foo/bar/",
it first recurses like so:
tree_content_set(root, "foo/bar/", sha1, S_IFDIR) ->
tree_content_set(root:foo, "bar/", ...) ->
tree_content_set(root:foo/bar, "", ...)
And as a side-effect of 2794ad5 (fast-import: Allow filemodify to set
the root, 2010-10-10), this last call is accepted and changes
the tree entry for root:foo/bar to refer to the specified tree.
That seems safe enough but let's reject the new syntax (we never meant
to support it) and make it harder for frontends to introduce pointless
incompatibilities with git fast-import 1.7.3.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-18 03:08:53 +02:00
|
|
|
INPUT_END
|
|
|
|
git fast-import <input &&
|
|
|
|
git diff --exit-code branch:newdir N9'
|
|
|
|
|
2010-10-18 03:44:04 +02:00
|
|
|
test_expect_success \
|
|
|
|
'N: modify subtree, extract it, and modify again' \
|
|
|
|
'echo hello >expect.baz &&
|
|
|
|
echo hello, world >expect.qux &&
|
|
|
|
git fast-import <<-SETUP_END &&
|
|
|
|
commit refs/heads/N10
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
hello, tree
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
deleteall
|
|
|
|
M 644 inline foo/bar/baz
|
|
|
|
data <<EOF
|
|
|
|
hello
|
|
|
|
EOF
|
|
|
|
SETUP_END
|
|
|
|
|
|
|
|
tree=$(git rev-parse --verify N10:) &&
|
|
|
|
git fast-import <<-INPUT_END &&
|
|
|
|
commit refs/heads/N11
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy to root by id and modify
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 040000 $tree ""
|
|
|
|
M 100644 inline foo/bar/qux
|
|
|
|
data <<EOF
|
|
|
|
hello, world
|
|
|
|
EOF
|
|
|
|
R "foo" ""
|
|
|
|
C "bar/qux" "bar/quux"
|
|
|
|
INPUT_END
|
|
|
|
git show N11:bar/baz >actual.baz &&
|
|
|
|
git show N11:bar/qux >actual.qux &&
|
|
|
|
git show N11:bar/quux >actual.quux &&
|
|
|
|
test_cmp expect.baz actual.baz &&
|
|
|
|
test_cmp expect.qux actual.qux &&
|
|
|
|
test_cmp expect.qux actual.quux'
|
|
|
|
|
2007-08-01 06:05:15 +02:00
|
|
|
###
|
|
|
|
### series O
|
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
#we will
|
|
|
|
commit refs/heads/O1
|
|
|
|
# -- ignore all of this text
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
# $GIT_COMMITTER_NAME has inserted here for his benefit.
|
|
|
|
data <<COMMIT
|
|
|
|
dirty directory copy
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
# don't forget the import blank line!
|
|
|
|
#
|
|
|
|
# yes, we started from our usual base of branch^0.
|
|
|
|
# i like branch^0.
|
|
|
|
from refs/heads/branch^0
|
|
|
|
# and we need to reuse file2/file5 from N3 above.
|
|
|
|
M 644 inline file2/file5
|
|
|
|
# otherwise the tree will be different
|
|
|
|
data <<EOF
|
|
|
|
$file5_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# don't forget to copy file2 to file3
|
|
|
|
C file2 file3
|
|
|
|
#
|
|
|
|
# or to delete file5 from file2.
|
|
|
|
D file2/file5
|
|
|
|
# are we done yet?
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'O: comments are all skipped' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
|
|
|
test `git rev-parse N3` = `git rev-parse O1`'
|
2007-08-01 06:05:15 +02:00
|
|
|
|
2007-08-01 06:24:25 +02:00
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/O2
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
dirty directory copy
|
|
|
|
COMMIT
|
|
|
|
from refs/heads/branch^0
|
|
|
|
M 644 inline file2/file5
|
|
|
|
data <<EOF
|
|
|
|
$file5_data
|
|
|
|
EOF
|
|
|
|
C file2 file3
|
|
|
|
D file2/file5
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'O: blank lines not necessary after data commands' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
|
|
|
test `git rev-parse N3` = `git rev-parse O2`'
|
2007-08-01 06:24:25 +02:00
|
|
|
|
2007-08-01 08:22:53 +02:00
|
|
|
test_expect_success \
|
|
|
|
'O: repack before next test' \
|
|
|
|
'git repack -a -d'
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/O3
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
zstring
|
|
|
|
COMMIT
|
|
|
|
commit refs/heads/O3
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
zof
|
|
|
|
COMMIT
|
|
|
|
checkpoint
|
|
|
|
commit refs/heads/O3
|
|
|
|
mark :5
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
zempty
|
|
|
|
COMMIT
|
|
|
|
checkpoint
|
|
|
|
commit refs/heads/O3
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
zcommits
|
|
|
|
COMMIT
|
|
|
|
reset refs/tags/O3-2nd
|
|
|
|
from :5
|
2008-03-07 21:22:17 +01:00
|
|
|
reset refs/tags/O3-3rd
|
|
|
|
from :5
|
2007-08-01 08:22:53 +02:00
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
cat >expect <<INPUT_END
|
|
|
|
string
|
|
|
|
of
|
|
|
|
empty
|
|
|
|
commits
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'O: blank lines not necessary after other commands' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2007-08-01 08:22:53 +02:00
|
|
|
test 8 = `find .git/objects/pack -type f | wc -l` &&
|
|
|
|
test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
|
|
|
|
git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-08-01 08:22:53 +02:00
|
|
|
|
2007-08-01 16:23:08 +02:00
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/O4
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
zstring
|
|
|
|
COMMIT
|
|
|
|
commit refs/heads/O4
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
zof
|
|
|
|
COMMIT
|
|
|
|
progress Two commits down, 2 to go!
|
|
|
|
commit refs/heads/O4
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
zempty
|
|
|
|
COMMIT
|
|
|
|
progress Three commits down, 1 to go!
|
|
|
|
commit refs/heads/O4
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
zcommits
|
|
|
|
COMMIT
|
|
|
|
progress I'm done!
|
|
|
|
INPUT_END
|
|
|
|
test_expect_success \
|
|
|
|
'O: progress outputs as requested by input' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input >actual &&
|
2007-08-01 16:23:08 +02:00
|
|
|
grep "progress " <input >expect &&
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp expect actual'
|
2007-08-01 16:23:08 +02:00
|
|
|
|
2008-07-19 14:21:24 +02:00
|
|
|
###
|
|
|
|
### series P (gitlinks)
|
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data 10
|
|
|
|
test file
|
|
|
|
|
|
|
|
reset refs/heads/sub
|
|
|
|
commit refs/heads/sub
|
|
|
|
mark :2
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data 12
|
|
|
|
sub_initial
|
|
|
|
M 100644 :1 file
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :3
|
|
|
|
data <<DATAEND
|
|
|
|
[submodule "sub"]
|
|
|
|
path = sub
|
|
|
|
url = "`pwd`/sub"
|
|
|
|
DATAEND
|
|
|
|
|
|
|
|
commit refs/heads/subuse1
|
|
|
|
mark :4
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data 8
|
|
|
|
initial
|
|
|
|
from refs/heads/master
|
|
|
|
M 100644 :3 .gitmodules
|
|
|
|
M 160000 :2 sub
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :5
|
|
|
|
data 20
|
|
|
|
test file
|
|
|
|
more data
|
|
|
|
|
|
|
|
commit refs/heads/sub
|
|
|
|
mark :6
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data 11
|
|
|
|
sub_second
|
|
|
|
from :2
|
|
|
|
M 100644 :5 file
|
|
|
|
|
|
|
|
commit refs/heads/subuse1
|
|
|
|
mark :7
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data 7
|
|
|
|
second
|
|
|
|
from :4
|
|
|
|
M 160000 :6 sub
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success \
|
2012-05-20 15:28:26 +02:00
|
|
|
'P: superproject & submodule mix' \
|
2008-09-09 23:25:25 +02:00
|
|
|
'git fast-import <input &&
|
2008-07-19 14:21:24 +02:00
|
|
|
git checkout subuse1 &&
|
2010-09-06 20:39:54 +02:00
|
|
|
rm -rf sub && mkdir sub && (cd sub &&
|
2008-07-19 14:21:24 +02:00
|
|
|
git init &&
|
2008-10-13 11:36:52 +02:00
|
|
|
git fetch --update-head-ok .. refs/heads/sub:refs/heads/master &&
|
2010-09-06 20:39:54 +02:00
|
|
|
git checkout master) &&
|
2008-07-19 14:21:24 +02:00
|
|
|
git submodule init &&
|
|
|
|
git submodule update'
|
|
|
|
|
2008-09-09 23:25:25 +02:00
|
|
|
SUBLAST=$(git rev-parse --verify sub)
|
|
|
|
SUBPREV=$(git rev-parse --verify sub^)
|
2008-07-19 14:21:24 +02:00
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data <<DATAEND
|
|
|
|
[submodule "sub"]
|
|
|
|
path = sub
|
|
|
|
url = "`pwd`/sub"
|
|
|
|
DATAEND
|
|
|
|
|
|
|
|
commit refs/heads/subuse2
|
|
|
|
mark :2
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data 8
|
|
|
|
initial
|
|
|
|
from refs/heads/master
|
|
|
|
M 100644 :1 .gitmodules
|
|
|
|
M 160000 $SUBPREV sub
|
|
|
|
|
|
|
|
commit refs/heads/subuse2
|
|
|
|
mark :3
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data 7
|
|
|
|
second
|
|
|
|
from :2
|
|
|
|
M 160000 $SUBLAST sub
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'P: verbatim SHA gitlinks' \
|
|
|
|
'git branch -D sub &&
|
|
|
|
git gc && git prune &&
|
2008-09-09 23:25:25 +02:00
|
|
|
git fast-import <input &&
|
|
|
|
test $(git rev-parse --verify subuse2) = $(git rev-parse --verify subuse1)'
|
2008-07-19 14:21:24 +02:00
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/subuse3
|
|
|
|
mark :1
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
corrupt
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/subuse2
|
|
|
|
M 160000 inline sub
|
|
|
|
data <<DATA
|
|
|
|
$SUBPREV
|
|
|
|
DATA
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success 'P: fail on inline gitlink' '
|
2008-09-09 23:25:25 +02:00
|
|
|
test_must_fail git fast-import <input'
|
2008-07-19 14:21:24 +02:00
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data <<DATA
|
|
|
|
$SUBPREV
|
|
|
|
DATA
|
|
|
|
|
|
|
|
commit refs/heads/subuse3
|
|
|
|
mark :2
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
corrupt
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
from refs/heads/subuse2
|
|
|
|
M 160000 :1 sub
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success 'P: fail on blob mark in gitlink' '
|
2008-09-09 23:25:25 +02:00
|
|
|
test_must_fail git fast-import <input'
|
2008-07-19 14:21:24 +02:00
|
|
|
|
2009-10-09 12:22:02 +02:00
|
|
|
###
|
|
|
|
### series Q (notes)
|
|
|
|
###
|
|
|
|
|
2009-12-07 12:27:24 +01:00
|
|
|
note1_data="The first note for the first commit"
|
|
|
|
note2_data="The first note for the second commit"
|
|
|
|
note3_data="The first note for the third commit"
|
|
|
|
note1b_data="The second note for the first commit"
|
|
|
|
note1c_data="The third note for the first commit"
|
|
|
|
note2b_data="The second note for the second commit"
|
2009-10-09 12:22:02 +02:00
|
|
|
|
|
|
|
test_tick
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
blob
|
|
|
|
mark :2
|
|
|
|
data <<EOF
|
|
|
|
$file2_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/heads/notes-test
|
|
|
|
mark :3
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
first (:3)
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 :2 file2
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :4
|
|
|
|
data $file4_len
|
|
|
|
$file4_data
|
|
|
|
commit refs/heads/notes-test
|
|
|
|
mark :5
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
second (:5)
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 :4 file4
|
|
|
|
|
|
|
|
commit refs/heads/notes-test
|
|
|
|
mark :6
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
third (:6)
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline file5
|
|
|
|
data <<EOF
|
|
|
|
$file5_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
M 755 inline file6
|
|
|
|
data <<EOF
|
|
|
|
$file6_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :7
|
|
|
|
data <<EOF
|
|
|
|
$note1_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :8
|
|
|
|
data <<EOF
|
|
|
|
$note2_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/notes/foobar
|
|
|
|
mark :9
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
notes (:9)
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
N :7 :3
|
|
|
|
N :8 :5
|
|
|
|
N inline :6
|
|
|
|
data <<EOF
|
|
|
|
$note3_data
|
|
|
|
EOF
|
|
|
|
|
2009-12-07 12:27:24 +01:00
|
|
|
commit refs/notes/foobar
|
|
|
|
mark :10
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
notes (:10)
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
N inline :3
|
|
|
|
data <<EOF
|
|
|
|
$note1b_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/notes/foobar2
|
|
|
|
mark :11
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
notes (:11)
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
N inline :3
|
|
|
|
data <<EOF
|
|
|
|
$note1c_data
|
|
|
|
EOF
|
|
|
|
|
|
|
|
commit refs/notes/foobar
|
|
|
|
mark :12
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
notes (:12)
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
deleteall
|
|
|
|
N inline :5
|
|
|
|
data <<EOF
|
|
|
|
$note2b_data
|
|
|
|
EOF
|
|
|
|
|
2009-10-09 12:22:02 +02:00
|
|
|
INPUT_END
|
2009-12-07 12:27:24 +01:00
|
|
|
|
2009-10-09 12:22:02 +02:00
|
|
|
test_expect_success \
|
|
|
|
'Q: commit notes' \
|
|
|
|
'git fast-import <input &&
|
|
|
|
git whatchanged notes-test'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'Q: verify pack' '
|
|
|
|
verify_packs
|
|
|
|
'
|
2009-10-09 12:22:02 +02:00
|
|
|
|
|
|
|
commit1=$(git rev-parse notes-test~2)
|
|
|
|
commit2=$(git rev-parse notes-test^)
|
|
|
|
commit3=$(git rev-parse notes-test)
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
first (:3)
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify first commit' \
|
|
|
|
'git cat-file commit notes-test~2 | sed 1d >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
parent $commit1
|
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
second (:5)
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify second commit' \
|
|
|
|
'git cat-file commit notes-test^ | sed 1d >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
parent $commit2
|
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
third (:6)
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify third commit' \
|
|
|
|
'git cat-file commit notes-test | sed 1d >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
notes (:9)
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
2009-12-07 12:27:24 +01:00
|
|
|
'Q: verify first notes commit' \
|
|
|
|
'git cat-file commit refs/notes/foobar~2 | sed 1d >actual &&
|
2009-10-09 12:22:02 +02:00
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect.unsorted <<EOF
|
|
|
|
100644 blob $commit1
|
|
|
|
100644 blob $commit2
|
|
|
|
100644 blob $commit3
|
|
|
|
EOF
|
|
|
|
cat expect.unsorted | sort >expect
|
|
|
|
test_expect_success \
|
2009-12-07 12:27:24 +01:00
|
|
|
'Q: verify first notes tree' \
|
|
|
|
'git cat-file -p refs/notes/foobar~2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
|
2009-10-09 12:22:02 +02:00
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
echo "$note1_data" >expect
|
|
|
|
test_expect_success \
|
2009-12-07 12:27:24 +01:00
|
|
|
'Q: verify first note for first commit' \
|
|
|
|
'git cat-file blob refs/notes/foobar~2:$commit1 >actual && test_cmp expect actual'
|
2009-10-09 12:22:02 +02:00
|
|
|
|
|
|
|
echo "$note2_data" >expect
|
|
|
|
test_expect_success \
|
2009-12-07 12:27:24 +01:00
|
|
|
'Q: verify first note for second commit' \
|
|
|
|
'git cat-file blob refs/notes/foobar~2:$commit2 >actual && test_cmp expect actual'
|
|
|
|
|
|
|
|
echo "$note3_data" >expect
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify first note for third commit' \
|
|
|
|
'git cat-file blob refs/notes/foobar~2:$commit3 >actual && test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
parent `git rev-parse --verify refs/notes/foobar~2`
|
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
notes (:10)
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify second notes commit' \
|
|
|
|
'git cat-file commit refs/notes/foobar^ | sed 1d >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect.unsorted <<EOF
|
|
|
|
100644 blob $commit1
|
|
|
|
100644 blob $commit2
|
|
|
|
100644 blob $commit3
|
|
|
|
EOF
|
|
|
|
cat expect.unsorted | sort >expect
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify second notes tree' \
|
|
|
|
'git cat-file -p refs/notes/foobar^^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
echo "$note1b_data" >expect
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify second note for first commit' \
|
|
|
|
'git cat-file blob refs/notes/foobar^:$commit1 >actual && test_cmp expect actual'
|
|
|
|
|
|
|
|
echo "$note2_data" >expect
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify first note for second commit' \
|
|
|
|
'git cat-file blob refs/notes/foobar^:$commit2 >actual && test_cmp expect actual'
|
2009-10-09 12:22:02 +02:00
|
|
|
|
|
|
|
echo "$note3_data" >expect
|
|
|
|
test_expect_success \
|
2009-12-07 12:27:24 +01:00
|
|
|
'Q: verify first note for third commit' \
|
|
|
|
'git cat-file blob refs/notes/foobar^:$commit3 >actual && test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
notes (:11)
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify third notes commit' \
|
|
|
|
'git cat-file commit refs/notes/foobar2 | sed 1d >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect.unsorted <<EOF
|
|
|
|
100644 blob $commit1
|
|
|
|
EOF
|
|
|
|
cat expect.unsorted | sort >expect
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify third notes tree' \
|
|
|
|
'git cat-file -p refs/notes/foobar2^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
echo "$note1c_data" >expect
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify third note for first commit' \
|
|
|
|
'git cat-file blob refs/notes/foobar2:$commit1 >actual && test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
parent `git rev-parse --verify refs/notes/foobar^`
|
|
|
|
author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
|
|
|
|
notes (:12)
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify fourth notes commit' \
|
|
|
|
'git cat-file commit refs/notes/foobar | sed 1d >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
cat >expect.unsorted <<EOF
|
|
|
|
100644 blob $commit2
|
|
|
|
EOF
|
|
|
|
cat expect.unsorted | sort >expect
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify fourth notes tree' \
|
|
|
|
'git cat-file -p refs/notes/foobar^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
|
|
|
|
test_cmp expect actual'
|
|
|
|
|
|
|
|
echo "$note2b_data" >expect
|
|
|
|
test_expect_success \
|
|
|
|
'Q: verify second note for second commit' \
|
|
|
|
'git cat-file blob refs/notes/foobar:$commit2 >actual && test_cmp expect actual'
|
2009-10-09 12:22:02 +02:00
|
|
|
|
2011-09-22 21:47:05 +02:00
|
|
|
cat >input <<EOF
|
|
|
|
reset refs/heads/Q0
|
|
|
|
|
|
|
|
commit refs/heads/note-Q0
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
Note for an empty branch.
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
N inline refs/heads/Q0
|
|
|
|
data <<NOTE
|
|
|
|
some note
|
|
|
|
NOTE
|
|
|
|
EOF
|
|
|
|
test_expect_success \
|
|
|
|
'Q: deny note on empty branch' \
|
|
|
|
'test_must_fail git fast-import <input'
|
2009-12-04 18:06:56 +01:00
|
|
|
###
|
2009-12-04 18:06:58 +01:00
|
|
|
### series R (feature and option)
|
2009-12-04 18:06:56 +01:00
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<EOF
|
|
|
|
feature no-such-feature-exists
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: abort on unsupported feature' '
|
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >input <<EOF
|
|
|
|
feature date-format=now
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: supported feature is accepted' '
|
|
|
|
git fast-import <input
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >input << EOF
|
|
|
|
blob
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
feature date-format=now
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: abort on receiving feature after data command' '
|
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
|
2009-12-04 18:06:59 +01:00
|
|
|
cat >input << EOF
|
|
|
|
feature import-marks=git.marks
|
|
|
|
feature import-marks=git2.marks
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: only one import-marks feature allowed per stream' '
|
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
|
2009-12-04 18:06:56 +01:00
|
|
|
cat >input << EOF
|
|
|
|
feature export-marks=git.marks
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'R: export-marks feature results in a marks file being created' \
|
|
|
|
'cat input | git fast-import &&
|
|
|
|
grep :1 git.marks'
|
|
|
|
|
|
|
|
test_expect_success \
|
2012-06-22 22:03:01 +02:00
|
|
|
'R: export-marks options can be overridden by commandline options' \
|
2009-12-04 18:06:56 +01:00
|
|
|
'cat input | git fast-import --export-marks=other.marks &&
|
|
|
|
grep :1 other.marks'
|
|
|
|
|
2011-01-15 07:31:46 +01:00
|
|
|
test_expect_success 'R: catch typo in marks file name' '
|
|
|
|
test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
|
|
|
|
echo "feature import-marks=nonexistent.marks" |
|
|
|
|
test_must_fail git fast-import
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'R: import and output marks can be the same file' '
|
|
|
|
rm -f io.marks &&
|
|
|
|
blob=$(echo hi | git hash-object --stdin) &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
:1 $blob
|
|
|
|
:2 $blob
|
|
|
|
EOF
|
|
|
|
git fast-import --export-marks=io.marks <<-\EOF &&
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
|
|
|
|
blob
|
|
|
|
mark :2
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
test_cmp expect io.marks
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
|
|
|
|
rm -f io.marks &&
|
|
|
|
test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'R: --import-marks-if-exists' '
|
|
|
|
rm -f io.marks &&
|
|
|
|
blob=$(echo hi | git hash-object --stdin) &&
|
|
|
|
echo ":1 $blob" >expect &&
|
|
|
|
git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
test_cmp expect io.marks
|
|
|
|
'
|
|
|
|
|
2011-08-17 12:42:58 +02:00
|
|
|
test_expect_success 'R: feature import-marks-if-exists' '
|
|
|
|
rm -f io.marks &&
|
|
|
|
>expect &&
|
|
|
|
|
|
|
|
git fast-import --export-marks=io.marks <<-\EOF &&
|
|
|
|
feature import-marks-if-exists=not_io.marks
|
|
|
|
EOF
|
|
|
|
test_cmp expect io.marks &&
|
|
|
|
|
|
|
|
blob=$(echo hi | git hash-object --stdin) &&
|
|
|
|
|
|
|
|
echo ":1 $blob" >io.marks &&
|
|
|
|
echo ":1 $blob" >expect &&
|
|
|
|
echo ":2 $blob" >>expect &&
|
|
|
|
|
|
|
|
git fast-import --export-marks=io.marks <<-\EOF &&
|
|
|
|
feature import-marks-if-exists=io.marks
|
|
|
|
blob
|
|
|
|
mark :2
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
test_cmp expect io.marks &&
|
|
|
|
|
|
|
|
echo ":3 $blob" >>expect &&
|
|
|
|
|
|
|
|
git fast-import --import-marks=io.marks \
|
|
|
|
--export-marks=io.marks <<-\EOF &&
|
|
|
|
feature import-marks-if-exists=not_io.marks
|
|
|
|
blob
|
|
|
|
mark :3
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
test_cmp expect io.marks &&
|
|
|
|
|
|
|
|
>expect &&
|
|
|
|
|
|
|
|
git fast-import --import-marks-if-exists=not_io.marks \
|
|
|
|
--export-marks=io.marks <<-\EOF
|
|
|
|
feature import-marks-if-exists=io.marks
|
|
|
|
EOF
|
|
|
|
test_cmp expect io.marks
|
|
|
|
'
|
|
|
|
|
2009-12-04 18:06:56 +01:00
|
|
|
cat >input << EOF
|
|
|
|
feature import-marks=marks.out
|
|
|
|
feature export-marks=marks.new
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'R: import to output marks works without any content' \
|
|
|
|
'cat input | git fast-import &&
|
|
|
|
test_cmp marks.out marks.new'
|
|
|
|
|
|
|
|
cat >input <<EOF
|
2011-06-16 15:42:48 +02:00
|
|
|
feature import-marks=nonexistent.marks
|
2009-12-04 18:06:56 +01:00
|
|
|
feature export-marks=marks.new
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'R: import marks prefers commandline marks file over the stream' \
|
|
|
|
'cat input | git fast-import --import-marks=marks.out &&
|
|
|
|
test_cmp marks.out marks.new'
|
|
|
|
|
2009-12-04 18:06:59 +01:00
|
|
|
|
|
|
|
cat >input <<EOF
|
2011-06-16 15:42:48 +02:00
|
|
|
feature import-marks=nonexistent.marks
|
2009-12-04 18:06:59 +01:00
|
|
|
feature export-marks=combined.marks
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: multiple --import-marks= should be honoured' '
|
|
|
|
head -n2 marks.out > one.marks &&
|
|
|
|
tail -n +3 marks.out > two.marks &&
|
|
|
|
git fast-import --import-marks=one.marks --import-marks=two.marks <input &&
|
|
|
|
test_cmp marks.out combined.marks
|
|
|
|
'
|
|
|
|
|
2009-12-04 18:07:00 +01:00
|
|
|
cat >input <<EOF
|
|
|
|
feature relative-marks
|
|
|
|
feature import-marks=relative.in
|
|
|
|
feature export-marks=relative.out
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: feature relative-marks should be honoured' '
|
|
|
|
mkdir -p .git/info/fast-import/ &&
|
|
|
|
cp marks.new .git/info/fast-import/relative.in &&
|
|
|
|
git fast-import <input &&
|
|
|
|
test_cmp marks.new .git/info/fast-import/relative.out
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >input <<EOF
|
|
|
|
feature relative-marks
|
|
|
|
feature import-marks=relative.in
|
|
|
|
feature no-relative-marks
|
|
|
|
feature export-marks=non-relative.out
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: feature no-relative-marks should be honoured' '
|
|
|
|
git fast-import <input &&
|
|
|
|
test_cmp marks.new non-relative.out
|
|
|
|
'
|
|
|
|
|
fast-import: add 'ls' command
Lazy fast-import frontend authors that want to rely on the backend to
keep track of the content of the imported trees _almost_ have what
they need in the 'cat-blob' command (v1.7.4-rc0~30^2~3, 2010-11-28).
But it is not quite enough, since
(1) cat-blob can be used to retrieve the content of files, but
not their mode, and
(2) using cat-blob requires the frontend to keep track of a name
(mark number or object id) for each blob to be retrieved
Introduce an 'ls' command to complement cat-blob and take care of the
remaining needs. The 'ls' command finds what is at a given path
within a given tree-ish (tag, commit, or tree):
'ls' SP <dataref> SP <path> LF
or in fast-import's active commit:
'ls' SP <path> LF
The response is a single line sent through the cat-blob channel,
imitating ls-tree output. So for example:
FE> ls :1 Documentation
gfi> 040000 tree 9e6c2b599341d28a2a375f8207507e0a2a627fe9 Documentation
FE> ls 9e6c2b599341d28a2a375f8207507e0a2a627fe9 git-fast-import.txt
gfi> 100644 blob 4f92954396e3f0f97e75b6838a5635b583708870 git-fast-import.txt
FE> ls :1 RelNotes
gfi> 120000 blob b942e499449d97aeb50c73ca2bdc1c6e6d528743 RelNotes
FE> cat-blob b942e499449d97aeb50c73ca2bdc1c6e6d528743
gfi> b942e499449d97aeb50c73ca2bdc1c6e6d528743 blob 32
gfi> Documentation/RelNotes/1.7.4.txt
The most interesting parts of the reply are the first word, which is
a 6-digit octal mode (regular file, executable, symlink, directory,
or submodule), and the part from the second space to the tab, which is
a <dataref> that can be used in later cat-blob, ls, and filemodify (M)
commands to refer to the content (blob, tree, or commit) at that path.
If there is nothing there, the response is "missing some/path".
The intent is for this command to be used to read files from the
active commit, so a frontend can apply patches to them, and to copy
files and directories from previous revisions.
For example, proposed updates to svn-fe use this command in place of
its internal representation of the repository directory structure.
This simplifies the frontend a great deal and means support for
resuming an import in a separate fast-import run (i.e., incremental
import) is basically free.
Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Improved-by: Junio C Hamano <gitster@pobox.com>
Improved-by: Sverre Rabbelier <srabbelier@gmail.com>
2010-12-02 11:40:20 +01:00
|
|
|
test_expect_success 'R: feature ls supported' '
|
|
|
|
echo "feature ls" |
|
|
|
|
git fast-import
|
|
|
|
'
|
|
|
|
|
2010-11-28 20:45:01 +01:00
|
|
|
test_expect_success 'R: feature cat-blob supported' '
|
|
|
|
echo "feature cat-blob" |
|
|
|
|
git fast-import
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'R: cat-blob-fd must be a nonnegative integer' '
|
|
|
|
test_must_fail git fast-import --cat-blob-fd=-1 </dev/null
|
|
|
|
'
|
|
|
|
|
2014-07-22 00:09:27 +02:00
|
|
|
test_expect_success !MINGW 'R: print old blob' '
|
2010-11-28 20:45:01 +01:00
|
|
|
blob=$(echo "yes it can" | git hash-object -w --stdin) &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
${blob} blob 11
|
|
|
|
yes it can
|
|
|
|
|
|
|
|
EOF
|
|
|
|
echo "cat-blob $blob" |
|
|
|
|
git fast-import --cat-blob-fd=6 6>actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2014-07-22 00:09:27 +02:00
|
|
|
test_expect_success !MINGW 'R: in-stream cat-blob-fd not respected' '
|
2010-11-28 20:45:01 +01:00
|
|
|
echo hello >greeting &&
|
|
|
|
blob=$(git hash-object -w greeting) &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
${blob} blob 6
|
|
|
|
hello
|
|
|
|
|
|
|
|
EOF
|
|
|
|
git fast-import --cat-blob-fd=3 3>actual.3 >actual.1 <<-EOF &&
|
|
|
|
cat-blob $blob
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual.3 &&
|
|
|
|
test_cmp empty actual.1 &&
|
|
|
|
git fast-import 3>actual.3 >actual.1 <<-EOF &&
|
|
|
|
option cat-blob-fd=3
|
|
|
|
cat-blob $blob
|
|
|
|
EOF
|
|
|
|
test_cmp empty actual.3 &&
|
|
|
|
test_cmp expect actual.1
|
|
|
|
'
|
|
|
|
|
2014-07-22 00:09:27 +02:00
|
|
|
test_expect_success !MINGW 'R: print new blob' '
|
2010-11-28 20:45:01 +01:00
|
|
|
blob=$(echo "yep yep yep" | git hash-object --stdin) &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
${blob} blob 12
|
|
|
|
yep yep yep
|
|
|
|
|
|
|
|
EOF
|
|
|
|
git fast-import --cat-blob-fd=6 6>actual <<-\EOF &&
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data <<BLOB_END
|
|
|
|
yep yep yep
|
|
|
|
BLOB_END
|
|
|
|
cat-blob :1
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2014-07-22 00:09:27 +02:00
|
|
|
test_expect_success !MINGW 'R: print new blob by sha1' '
|
2010-11-28 20:45:01 +01:00
|
|
|
blob=$(echo "a new blob named by sha1" | git hash-object --stdin) &&
|
|
|
|
cat >expect <<-EOF &&
|
|
|
|
${blob} blob 25
|
|
|
|
a new blob named by sha1
|
|
|
|
|
|
|
|
EOF
|
|
|
|
git fast-import --cat-blob-fd=6 6>actual <<-EOF &&
|
|
|
|
blob
|
|
|
|
data <<BLOB_END
|
|
|
|
a new blob named by sha1
|
|
|
|
BLOB_END
|
|
|
|
cat-blob $blob
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup: big file' '
|
|
|
|
(
|
|
|
|
echo "the quick brown fox jumps over the lazy dog" >big &&
|
|
|
|
for i in 1 2 3
|
|
|
|
do
|
|
|
|
cat big big big big >bigger &&
|
|
|
|
cat bigger bigger bigger bigger >big ||
|
|
|
|
exit
|
|
|
|
done
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'R: print two blobs to stdout' '
|
|
|
|
blob1=$(git hash-object big) &&
|
|
|
|
blob1_len=$(wc -c <big) &&
|
|
|
|
blob2=$(echo hello | git hash-object --stdin) &&
|
|
|
|
{
|
|
|
|
echo ${blob1} blob $blob1_len &&
|
|
|
|
cat big &&
|
|
|
|
cat <<-EOF
|
|
|
|
|
|
|
|
${blob2} blob 6
|
|
|
|
hello
|
|
|
|
|
|
|
|
EOF
|
|
|
|
} >expect &&
|
|
|
|
{
|
|
|
|
cat <<-\END_PART1 &&
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data <<data_end
|
|
|
|
END_PART1
|
|
|
|
cat big &&
|
|
|
|
cat <<-\EOF
|
|
|
|
data_end
|
|
|
|
blob
|
|
|
|
mark :2
|
|
|
|
data <<data_end
|
|
|
|
hello
|
|
|
|
data_end
|
|
|
|
cat-blob :1
|
|
|
|
cat-blob :2
|
|
|
|
EOF
|
|
|
|
} |
|
|
|
|
git fast-import >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success PIPE 'R: copy using cat-file' '
|
|
|
|
expect_id=$(git hash-object big) &&
|
|
|
|
expect_len=$(wc -c <big) &&
|
|
|
|
echo $expect_id blob $expect_len >expect.response &&
|
|
|
|
|
|
|
|
rm -f blobs &&
|
|
|
|
cat >frontend <<-\FRONTEND_END &&
|
|
|
|
#!/bin/sh
|
|
|
|
FRONTEND_END
|
|
|
|
|
|
|
|
mkfifo blobs &&
|
|
|
|
(
|
|
|
|
export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_COMMITTER_DATE &&
|
2010-12-13 10:28:05 +01:00
|
|
|
cat <<-\EOF &&
|
|
|
|
feature cat-blob
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data <<BLOB
|
|
|
|
EOF
|
|
|
|
cat big &&
|
|
|
|
cat <<-\EOF &&
|
|
|
|
BLOB
|
|
|
|
cat-blob :1
|
|
|
|
EOF
|
|
|
|
|
|
|
|
read blob_id type size <&3 &&
|
|
|
|
echo "$blob_id $type $size" >response &&
|
|
|
|
head_c $size >blob <&3 &&
|
|
|
|
read newline <&3 &&
|
|
|
|
|
|
|
|
cat <<-EOF &&
|
|
|
|
commit refs/heads/copied
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
copy big file as file3
|
|
|
|
COMMIT
|
|
|
|
M 644 inline file3
|
|
|
|
data <<BLOB
|
|
|
|
EOF
|
|
|
|
cat blob &&
|
|
|
|
echo BLOB
|
|
|
|
) 3<blobs |
|
|
|
|
git fast-import --cat-blob-fd=3 3>blobs &&
|
2010-11-28 20:45:01 +01:00
|
|
|
git show copied:file3 >actual &&
|
|
|
|
test_cmp expect.response response &&
|
|
|
|
test_cmp big actual
|
|
|
|
'
|
|
|
|
|
2010-11-28 20:45:58 +01:00
|
|
|
test_expect_success PIPE 'R: print blob mid-commit' '
|
|
|
|
rm -f blobs &&
|
|
|
|
echo "A blob from _before_ the commit." >expect &&
|
|
|
|
mkfifo blobs &&
|
|
|
|
(
|
|
|
|
exec 3<blobs &&
|
|
|
|
cat <<-EOF &&
|
|
|
|
feature cat-blob
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data <<BLOB
|
|
|
|
A blob from _before_ the commit.
|
|
|
|
BLOB
|
|
|
|
commit refs/heads/temporary
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
Empty commit
|
|
|
|
COMMIT
|
|
|
|
cat-blob :1
|
|
|
|
EOF
|
|
|
|
|
|
|
|
read blob_id type size <&3 &&
|
2010-12-13 10:28:05 +01:00
|
|
|
head_c $size >actual <&3 &&
|
2010-11-28 20:45:58 +01:00
|
|
|
read newline <&3 &&
|
|
|
|
|
|
|
|
echo
|
|
|
|
) |
|
|
|
|
git fast-import --cat-blob-fd=3 3>blobs &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success PIPE 'R: print staged blob within commit' '
|
|
|
|
rm -f blobs &&
|
|
|
|
echo "A blob from _within_ the commit." >expect &&
|
|
|
|
mkfifo blobs &&
|
|
|
|
(
|
|
|
|
exec 3<blobs &&
|
|
|
|
cat <<-EOF &&
|
|
|
|
feature cat-blob
|
|
|
|
commit refs/heads/within
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
Empty commit
|
|
|
|
COMMIT
|
|
|
|
M 644 inline within
|
|
|
|
data <<BLOB
|
|
|
|
A blob from _within_ the commit.
|
|
|
|
BLOB
|
|
|
|
EOF
|
|
|
|
|
|
|
|
to_get=$(
|
|
|
|
echo "A blob from _within_ the commit." |
|
|
|
|
git hash-object --stdin
|
|
|
|
) &&
|
|
|
|
echo "cat-blob $to_get" &&
|
|
|
|
|
|
|
|
read blob_id type size <&3 &&
|
2010-12-13 10:28:05 +01:00
|
|
|
head_c $size >actual <&3 &&
|
2010-11-28 20:45:58 +01:00
|
|
|
read newline <&3 &&
|
|
|
|
|
|
|
|
echo deleteall
|
|
|
|
) |
|
|
|
|
git fast-import --cat-blob-fd=3 3>blobs &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2009-12-04 18:06:58 +01:00
|
|
|
cat >input << EOF
|
|
|
|
option git quiet
|
|
|
|
blob
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: quiet option results in no stats being output' '
|
|
|
|
cat input | git fast-import 2> output &&
|
|
|
|
test_cmp empty output
|
|
|
|
'
|
|
|
|
|
2011-07-16 15:03:32 +02:00
|
|
|
test_expect_success 'R: feature done means terminating "done" is mandatory' '
|
|
|
|
echo feature done | test_must_fail git fast-import &&
|
|
|
|
test_must_fail git fast-import --done </dev/null
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'R: terminating "done" with trailing gibberish is ok' '
|
|
|
|
git fast-import <<-\EOF &&
|
|
|
|
feature done
|
|
|
|
done
|
|
|
|
trailing gibberish
|
|
|
|
EOF
|
|
|
|
git fast-import <<-\EOF
|
|
|
|
done
|
|
|
|
more trailing gibberish
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'R: terminating "done" within commit' '
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
OBJID
|
|
|
|
:000000 100644 OBJID OBJID A hello.c
|
|
|
|
:000000 100644 OBJID OBJID A hello2.c
|
|
|
|
EOF
|
|
|
|
git fast-import <<-EOF &&
|
|
|
|
commit refs/heads/done-ends
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<EOT
|
|
|
|
Commit terminated by "done" command
|
|
|
|
EOT
|
|
|
|
M 100644 inline hello.c
|
|
|
|
data <<EOT
|
|
|
|
Hello, world.
|
|
|
|
EOT
|
|
|
|
C hello.c hello2.c
|
|
|
|
done
|
|
|
|
EOF
|
|
|
|
git rev-list done-ends |
|
|
|
|
git diff-tree -r --stdin --root --always |
|
|
|
|
sed -e "s/$_x40/OBJID/g" >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2009-12-04 18:06:58 +01:00
|
|
|
cat >input <<EOF
|
|
|
|
option git non-existing-option
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: die on unknown option' '
|
|
|
|
test_must_fail git fast-import <input
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'R: unknown commandline options are rejected' '\
|
|
|
|
test_must_fail git fast-import --non-existing-option < /dev/null
|
|
|
|
'
|
|
|
|
|
2010-11-28 20:42:46 +01:00
|
|
|
test_expect_success 'R: die on invalid option argument' '
|
|
|
|
echo "option git active-branches=-5" |
|
|
|
|
test_must_fail git fast-import &&
|
|
|
|
echo "option git depth=" |
|
|
|
|
test_must_fail git fast-import &&
|
|
|
|
test_must_fail git fast-import --depth="5 elephants" </dev/null
|
|
|
|
'
|
|
|
|
|
2009-12-04 18:06:58 +01:00
|
|
|
cat >input <<EOF
|
|
|
|
option non-existing-vcs non-existing-option
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'R: ignore non-git options' '
|
|
|
|
git fast-import <input
|
|
|
|
'
|
|
|
|
|
2010-02-01 18:27:35 +01:00
|
|
|
##
|
|
|
|
## R: very large blobs
|
|
|
|
##
|
|
|
|
blobsize=$((2*1024*1024 + 53))
|
|
|
|
test-genrandom bar $blobsize >expect
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/big-file
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
R - big file
|
|
|
|
COMMIT
|
|
|
|
|
|
|
|
M 644 inline big1
|
|
|
|
data $blobsize
|
|
|
|
INPUT_END
|
|
|
|
cat expect >>input
|
|
|
|
cat >>input <<INPUT_END
|
|
|
|
M 644 inline big2
|
|
|
|
data $blobsize
|
|
|
|
INPUT_END
|
|
|
|
cat expect >>input
|
|
|
|
echo >>input
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'R: blob bigger than threshold' \
|
|
|
|
'test_create_repo R &&
|
|
|
|
git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
|
2012-04-20 08:25:09 +02:00
|
|
|
|
|
|
|
test_expect_success 'R: verify created pack' '
|
|
|
|
(
|
|
|
|
cd R &&
|
|
|
|
verify_packs -v > ../verify
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2010-02-01 18:27:35 +01:00
|
|
|
test_expect_success \
|
|
|
|
'R: verify written objects' \
|
|
|
|
'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&
|
2014-09-12 21:47:34 +02:00
|
|
|
test_cmp_bin expect actual &&
|
2010-02-01 18:27:35 +01:00
|
|
|
a=$(git --git-dir=R/.git rev-parse big-file:big1) &&
|
|
|
|
b=$(git --git-dir=R/.git rev-parse big-file:big2) &&
|
|
|
|
test $a = $b'
|
|
|
|
test_expect_success \
|
|
|
|
'R: blob appears only once' \
|
|
|
|
'n=$(grep $a verify | wc -l) &&
|
|
|
|
test 1 = $n'
|
|
|
|
|
2012-04-08 00:59:20 +02:00
|
|
|
###
|
|
|
|
### series S
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Make sure missing spaces and EOLs after mark references
|
|
|
|
# cause errors.
|
|
|
|
#
|
|
|
|
# Setup:
|
|
|
|
#
|
|
|
|
# 1--2--4
|
|
|
|
# \ /
|
|
|
|
# -3-
|
|
|
|
#
|
|
|
|
# commit marks: 301, 302, 303, 304
|
|
|
|
# blob marks: 403, 404, resp.
|
|
|
|
# note mark: 202
|
|
|
|
#
|
|
|
|
# The error message when a space is missing not at the
|
|
|
|
# end of the line is:
|
|
|
|
#
|
|
|
|
# Missing space after ..
|
|
|
|
#
|
|
|
|
# or when extra characters come after the mark at the end
|
|
|
|
# of the line:
|
|
|
|
#
|
|
|
|
# Garbage after ..
|
|
|
|
#
|
|
|
|
# or when the dataref is neither "inline " or a known SHA1,
|
|
|
|
#
|
|
|
|
# Invalid dataref ..
|
|
|
|
#
|
|
|
|
test_tick
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/S
|
|
|
|
mark :301
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit 1
|
|
|
|
COMMIT
|
|
|
|
M 100644 inline hello.c
|
|
|
|
data <<BLOB
|
|
|
|
blob 1
|
|
|
|
BLOB
|
|
|
|
|
|
|
|
commit refs/heads/S
|
|
|
|
mark :302
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit 2
|
|
|
|
COMMIT
|
|
|
|
from :301
|
|
|
|
M 100644 inline hello.c
|
|
|
|
data <<BLOB
|
|
|
|
blob 2
|
|
|
|
BLOB
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :403
|
|
|
|
data <<BLOB
|
|
|
|
blob 3
|
|
|
|
BLOB
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :202
|
|
|
|
data <<BLOB
|
|
|
|
note 2
|
|
|
|
BLOB
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success 'S: initialize for S tests' '
|
|
|
|
git fast-import --export-marks=marks <input
|
|
|
|
'
|
|
|
|
|
|
|
|
#
|
|
|
|
# filemodify, three datarefs
|
|
|
|
#
|
|
|
|
test_expect_success 'S: filemodify with garbage after mark must fail' '
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
commit refs/heads/S
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit N
|
|
|
|
COMMIT
|
|
|
|
M 100644 :403x hello.c
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "space after mark" err
|
|
|
|
'
|
|
|
|
|
|
|
|
# inline is misspelled; fast-import thinks it is some unknown dataref
|
|
|
|
test_expect_success 'S: filemodify with garbage after inline must fail' '
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
commit refs/heads/S
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit N
|
|
|
|
COMMIT
|
|
|
|
M 100644 inlineX hello.c
|
|
|
|
data <<BLOB
|
|
|
|
inline
|
|
|
|
BLOB
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "nvalid dataref" err
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'S: filemodify with garbage after sha1 must fail' '
|
|
|
|
sha1=$(grep :403 marks | cut -d\ -f2) &&
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
commit refs/heads/S
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit N
|
|
|
|
COMMIT
|
|
|
|
M 100644 ${sha1}x hello.c
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "space after SHA1" err
|
|
|
|
'
|
|
|
|
|
|
|
|
#
|
|
|
|
# notemodify, three ways to say dataref
|
|
|
|
#
|
|
|
|
test_expect_success 'S: notemodify with garabge after mark dataref must fail' '
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
commit refs/heads/S
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit S note dataref markref
|
|
|
|
COMMIT
|
|
|
|
N :202x :302
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "space after mark" err
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'S: notemodify with garbage after inline dataref must fail' '
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
commit refs/heads/S
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit S note dataref inline
|
|
|
|
COMMIT
|
|
|
|
N inlineX :302
|
|
|
|
data <<BLOB
|
|
|
|
note blob
|
|
|
|
BLOB
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "nvalid dataref" err
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
|
|
|
|
sha1=$(grep :202 marks | cut -d\ -f2) &&
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
commit refs/heads/S
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit S note dataref sha1
|
|
|
|
COMMIT
|
|
|
|
N ${sha1}x :302
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "space after SHA1" err
|
|
|
|
'
|
|
|
|
|
|
|
|
#
|
2013-09-04 21:04:31 +02:00
|
|
|
# notemodify, mark in commit-ish
|
2012-04-08 00:59:20 +02:00
|
|
|
#
|
2014-09-21 17:02:57 +02:00
|
|
|
test_expect_success 'S: notemodify with garbage after mark commit-ish must fail' '
|
2012-04-08 00:59:20 +02:00
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
commit refs/heads/Snotes
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
2013-09-04 21:04:31 +02:00
|
|
|
commit S note commit-ish
|
2012-04-08 00:59:20 +02:00
|
|
|
COMMIT
|
|
|
|
N :202 :302x
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "after mark" err
|
|
|
|
'
|
|
|
|
|
|
|
|
#
|
|
|
|
# from
|
|
|
|
#
|
|
|
|
test_expect_success 'S: from with garbage after mark must fail' '
|
|
|
|
# no &&
|
|
|
|
git fast-import --import-marks=marks --export-marks=marks <<-EOF 2>err
|
|
|
|
commit refs/heads/S2
|
|
|
|
mark :303
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit 3
|
|
|
|
COMMIT
|
|
|
|
from :301x
|
|
|
|
M 100644 :403 hello.c
|
|
|
|
EOF
|
|
|
|
|
|
|
|
ret=$? &&
|
|
|
|
echo returned $ret &&
|
|
|
|
test $ret -ne 0 && # failed, but it created the commit
|
|
|
|
|
|
|
|
# go create the commit, need it for merge test
|
|
|
|
git fast-import --import-marks=marks --export-marks=marks <<-EOF &&
|
|
|
|
commit refs/heads/S2
|
|
|
|
mark :303
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
commit 3
|
|
|
|
COMMIT
|
|
|
|
from :301
|
|
|
|
M 100644 :403 hello.c
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# now evaluate the error
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "after mark" err
|
|
|
|
'
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# merge
|
|
|
|
#
|
|
|
|
test_expect_success 'S: merge with garbage after mark must fail' '
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
commit refs/heads/S
|
|
|
|
mark :304
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
merge 4
|
|
|
|
COMMIT
|
|
|
|
from :302
|
|
|
|
merge :303x
|
|
|
|
M 100644 :403 hello.c
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "after mark" err
|
|
|
|
'
|
|
|
|
|
|
|
|
#
|
|
|
|
# tag, from markref
|
|
|
|
#
|
|
|
|
test_expect_success 'S: tag with garbage after mark must fail' '
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
tag refs/tags/Stag
|
|
|
|
from :302x
|
|
|
|
tagger $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<TAG
|
|
|
|
tag S
|
|
|
|
TAG
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "after mark" err
|
|
|
|
'
|
|
|
|
|
|
|
|
#
|
|
|
|
# cat-blob markref
|
|
|
|
#
|
|
|
|
test_expect_success 'S: cat-blob with garbage after mark must fail' '
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
cat-blob :403x
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "after mark" err
|
|
|
|
'
|
|
|
|
|
|
|
|
#
|
|
|
|
# ls markref
|
|
|
|
#
|
|
|
|
test_expect_success 'S: ls with garbage after mark must fail' '
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
ls :302x hello.c
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "space after mark" err
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'S: ls with garbage after sha1 must fail' '
|
|
|
|
sha1=$(grep :302 marks | cut -d\ -f2) &&
|
|
|
|
test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
|
|
|
|
ls ${sha1}x hello.c
|
|
|
|
EOF
|
|
|
|
cat err &&
|
|
|
|
test_i18ngrep "space after tree-ish" err
|
|
|
|
'
|
|
|
|
|
2013-06-23 16:58:19 +02:00
|
|
|
###
|
|
|
|
### series T (ls)
|
|
|
|
###
|
|
|
|
# Setup is carried over from series S.
|
|
|
|
|
2013-06-23 16:58:21 +02:00
|
|
|
test_expect_success 'T: ls root tree' '
|
2013-06-23 16:58:19 +02:00
|
|
|
sed -e "s/Z\$//" >expect <<-EOF &&
|
|
|
|
040000 tree $(git rev-parse S^{tree}) Z
|
|
|
|
EOF
|
|
|
|
sha1=$(git rev-parse --verify S) &&
|
|
|
|
git fast-import --import-marks=marks <<-EOF >actual &&
|
|
|
|
ls $sha1 ""
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2014-04-20 20:59:27 +02:00
|
|
|
test_expect_success 'T: delete branch' '
|
|
|
|
git branch to-delete &&
|
|
|
|
git fast-import <<-EOF &&
|
|
|
|
reset refs/heads/to-delete
|
|
|
|
from 0000000000000000000000000000000000000000
|
|
|
|
EOF
|
|
|
|
test_must_fail git rev-parse --verify refs/heads/to-delete
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'T: empty reset doesnt delete branch' '
|
|
|
|
git branch not-to-delete &&
|
|
|
|
git fast-import <<-EOF &&
|
|
|
|
reset refs/heads/not-to-delete
|
|
|
|
EOF
|
|
|
|
git show-ref &&
|
|
|
|
git rev-parse --verify refs/heads/not-to-delete
|
|
|
|
'
|
|
|
|
|
2014-08-29 13:53:36 +02:00
|
|
|
###
|
|
|
|
### series U (filedelete)
|
|
|
|
###
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/U
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
test setup
|
|
|
|
COMMIT
|
|
|
|
M 100644 inline hello.c
|
|
|
|
data <<BLOB
|
|
|
|
blob 1
|
|
|
|
BLOB
|
|
|
|
M 100644 inline good/night.txt
|
|
|
|
data <<BLOB
|
|
|
|
sleep well
|
|
|
|
BLOB
|
|
|
|
M 100644 inline good/bye.txt
|
|
|
|
data <<BLOB
|
|
|
|
au revoir
|
|
|
|
BLOB
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success 'U: initialize for U tests' '
|
|
|
|
git fast-import <input
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/U
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
delete good/night.txt
|
|
|
|
COMMIT
|
|
|
|
from refs/heads/U^0
|
|
|
|
D good/night.txt
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success 'U: filedelete file succeeds' '
|
|
|
|
git fast-import <input
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100644 000000 2907ebb4bf85d91bf0716bb3bd8a68ef48d6da76 0000000000000000000000000000000000000000 D good/night.txt
|
|
|
|
EOF
|
|
|
|
|
|
|
|
git diff-tree -M -r U^1 U >actual
|
|
|
|
|
|
|
|
test_expect_success 'U: validate file delete result' '
|
|
|
|
compare_diff_raw expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/U
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
delete good dir
|
|
|
|
COMMIT
|
|
|
|
from refs/heads/U^0
|
|
|
|
D good
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
|
|
|
test_expect_success 'U: filedelete directory succeeds' '
|
|
|
|
git fast-import <input
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100644 000000 69cb75792f55123d8389c156b0b41c2ff00ed507 0000000000000000000000000000000000000000 D good/bye.txt
|
|
|
|
EOF
|
|
|
|
|
|
|
|
git diff-tree -M -r U^1 U >actual
|
|
|
|
|
|
|
|
test_expect_success 'U: validate directory delete result' '
|
|
|
|
compare_diff_raw expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >input <<INPUT_END
|
|
|
|
commit refs/heads/U
|
|
|
|
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
|
|
|
|
data <<COMMIT
|
|
|
|
must succeed
|
|
|
|
COMMIT
|
|
|
|
from refs/heads/U^0
|
|
|
|
D ""
|
|
|
|
|
|
|
|
INPUT_END
|
|
|
|
|
2014-08-29 13:53:37 +02:00
|
|
|
test_expect_success 'U: filedelete root succeeds' '
|
2014-08-29 13:53:36 +02:00
|
|
|
git fast-import <input
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
:100644 000000 c18147dc648481eeb65dc5e66628429a64843327 0000000000000000000000000000000000000000 D hello.c
|
|
|
|
EOF
|
|
|
|
|
|
|
|
git diff-tree -M -r U^1 U >actual
|
|
|
|
|
2014-08-29 13:53:37 +02:00
|
|
|
test_expect_success 'U: validate root delete result' '
|
2014-08-29 13:53:36 +02:00
|
|
|
compare_diff_raw expect actual
|
|
|
|
'
|
|
|
|
|
2007-01-18 19:26:24 +01:00
|
|
|
test_done
|