2007-12-02 14:14:13 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Johannes E. Schindelin
|
|
|
|
#
|
|
|
|
|
2008-09-09 21:25:25 +00:00
|
|
|
test_description='git fast-export'
|
2007-12-02 14:14:13 +00:00
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
|
2009-03-25 23:53:23 +00:00
|
|
|
echo break it > file0 &&
|
|
|
|
git add file0 &&
|
|
|
|
test_tick &&
|
2007-12-02 14:14:13 +00:00
|
|
|
echo Wohlauf > file &&
|
|
|
|
git add file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
echo die Luft > file &&
|
|
|
|
echo geht frisch > file2 &&
|
|
|
|
git add file file2 &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m second &&
|
|
|
|
echo und > file2 &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m third file2 &&
|
|
|
|
test_tick &&
|
|
|
|
git tag rein &&
|
|
|
|
git checkout -b wer HEAD^ &&
|
2010-10-31 01:46:54 +00:00
|
|
|
echo lange > file2 &&
|
2007-12-02 14:14:13 +00:00
|
|
|
test_tick &&
|
|
|
|
git commit -m sitzt file2 &&
|
|
|
|
test_tick &&
|
|
|
|
git tag -a -m valentin muss &&
|
|
|
|
git merge -s ours master
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'fast-export | fast-import' '
|
|
|
|
|
|
|
|
MASTER=$(git rev-parse --verify master) &&
|
|
|
|
REIN=$(git rev-parse --verify rein) &&
|
|
|
|
WER=$(git rev-parse --verify wer) &&
|
|
|
|
MUSS=$(git rev-parse --verify muss) &&
|
|
|
|
mkdir new &&
|
|
|
|
git --git-dir=new/.git init &&
|
|
|
|
git fast-export --all |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
test $MASTER = $(git rev-parse --verify refs/heads/master) &&
|
|
|
|
test $REIN = $(git rev-parse --verify refs/tags/rein) &&
|
|
|
|
test $WER = $(git rev-parse --verify refs/heads/wer) &&
|
|
|
|
test $MUSS = $(git rev-parse --verify refs/tags/muss))
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'fast-export master~2..master' '
|
|
|
|
|
|
|
|
git fast-export master~2..master |
|
|
|
|
sed "s/master/partial/" |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
test $MASTER != $(git rev-parse --verify refs/heads/partial) &&
|
2009-03-25 23:53:23 +00:00
|
|
|
git diff --exit-code master partial &&
|
|
|
|
git diff --exit-code master^ partial^ &&
|
2008-07-12 15:47:52 +00:00
|
|
|
test_must_fail git rev-parse partial~2)
|
2007-12-02 14:14:13 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'iso-8859-1' '
|
|
|
|
|
2009-05-18 23:44:44 +00:00
|
|
|
git config i18n.commitencoding ISO8859-1 &&
|
2007-12-02 14:14:13 +00:00
|
|
|
# use author and committer name in ISO-8859-1 to match it.
|
2008-08-08 09:26:28 +00:00
|
|
|
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
|
2007-12-02 14:14:13 +00:00
|
|
|
test_tick &&
|
|
|
|
echo rosten >file &&
|
|
|
|
git commit -s -m den file &&
|
|
|
|
git fast-export wer^..wer |
|
|
|
|
sed "s/wer/i18n/" |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
git cat-file commit i18n | grep "Áéí óú")
|
|
|
|
|
2008-06-11 11:17:04 +00:00
|
|
|
'
|
|
|
|
test_expect_success 'import/export-marks' '
|
|
|
|
|
|
|
|
git checkout -b marks master &&
|
|
|
|
git fast-export --export-marks=tmp-marks HEAD &&
|
|
|
|
test -s tmp-marks &&
|
2012-04-11 11:24:01 +00:00
|
|
|
test_line_count = 3 tmp-marks &&
|
2008-06-11 11:17:04 +00:00
|
|
|
test $(
|
|
|
|
git fast-export --import-marks=tmp-marks\
|
|
|
|
--export-marks=tmp-marks HEAD |
|
|
|
|
grep ^commit |
|
|
|
|
wc -l) \
|
|
|
|
-eq 0 &&
|
|
|
|
echo change > file &&
|
|
|
|
git commit -m "last commit" file &&
|
|
|
|
test $(
|
|
|
|
git fast-export --import-marks=tmp-marks \
|
|
|
|
--export-marks=tmp-marks HEAD |
|
|
|
|
grep ^commit\ |
|
|
|
|
wc -l) \
|
|
|
|
-eq 1 &&
|
2012-04-11 11:24:01 +00:00
|
|
|
test_line_count = 4 tmp-marks
|
2008-06-11 11:17:04 +00:00
|
|
|
|
2007-12-02 14:14:13 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
cat > signed-tag-import << EOF
|
|
|
|
tag sign-your-name
|
|
|
|
from $(git rev-parse HEAD)
|
|
|
|
tagger C O Mitter <committer@example.com> 1112911993 -0700
|
|
|
|
data 210
|
|
|
|
A message for a sign
|
|
|
|
-----BEGIN PGP SIGNATURE-----
|
|
|
|
Version: GnuPG v1.4.5 (GNU/Linux)
|
|
|
|
|
|
|
|
fakedsignaturefakedsignaturefakedsignaturefakedsignaturfakedsign
|
|
|
|
aturefakedsignaturefake=
|
|
|
|
=/59v
|
|
|
|
-----END PGP SIGNATURE-----
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'set up faked signed tag' '
|
|
|
|
|
|
|
|
cat signed-tag-import | git fast-import
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'signed-tags=abort' '
|
|
|
|
|
2008-07-12 15:47:52 +00:00
|
|
|
test_must_fail git fast-export --signed-tags=abort sign-your-name
|
2007-12-02 14:14:13 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-12-03 22:44:39 +00:00
|
|
|
test_expect_success 'signed-tags=verbatim' '
|
2007-12-02 14:14:13 +00:00
|
|
|
|
2007-12-03 22:44:39 +00:00
|
|
|
git fast-export --signed-tags=verbatim sign-your-name > output &&
|
2007-12-02 14:14:13 +00:00
|
|
|
grep PGP output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'signed-tags=strip' '
|
|
|
|
|
|
|
|
git fast-export --signed-tags=strip sign-your-name > output &&
|
|
|
|
! grep PGP output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2013-04-14 10:57:06 +00:00
|
|
|
test_expect_success 'signed-tags=warn-strip' '
|
|
|
|
git fast-export --signed-tags=warn-strip sign-your-name >output 2>err &&
|
|
|
|
! grep PGP output &&
|
|
|
|
test -s err
|
|
|
|
'
|
|
|
|
|
2008-07-19 12:21:24 +00:00
|
|
|
test_expect_success 'setup submodule' '
|
|
|
|
|
|
|
|
git checkout -f master &&
|
|
|
|
mkdir sub &&
|
2010-03-29 00:42:11 +00:00
|
|
|
(
|
|
|
|
cd sub &&
|
|
|
|
git init &&
|
|
|
|
echo test file > file &&
|
|
|
|
git add file &&
|
|
|
|
git commit -m sub_initial
|
|
|
|
) &&
|
2008-07-19 12:21:24 +00:00
|
|
|
git submodule add "`pwd`/sub" sub &&
|
|
|
|
git commit -m initial &&
|
|
|
|
test_tick &&
|
2010-03-29 00:42:11 +00:00
|
|
|
(
|
|
|
|
cd sub &&
|
|
|
|
echo more data >> file &&
|
|
|
|
git add file &&
|
|
|
|
git commit -m sub_second
|
|
|
|
) &&
|
2008-07-19 12:21:24 +00:00
|
|
|
git add sub &&
|
|
|
|
git commit -m second
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'submodule fast-export | fast-import' '
|
|
|
|
|
|
|
|
SUBENT1=$(git ls-tree master^ sub) &&
|
|
|
|
SUBENT2=$(git ls-tree master sub) &&
|
|
|
|
rm -rf new &&
|
|
|
|
mkdir new &&
|
|
|
|
git --git-dir=new/.git init &&
|
|
|
|
git fast-export --signed-tags=strip --all |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
test "$SUBENT1" = "$(git ls-tree refs/heads/master^ sub)" &&
|
|
|
|
test "$SUBENT2" = "$(git ls-tree refs/heads/master sub)" &&
|
|
|
|
git checkout master &&
|
|
|
|
git submodule init &&
|
|
|
|
git submodule update &&
|
|
|
|
cmp sub/file ../sub/file)
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-02-18 19:17:27 +00:00
|
|
|
GIT_AUTHOR_NAME='A U Thor'; export GIT_AUTHOR_NAME
|
|
|
|
GIT_COMMITTER_NAME='C O Mitter'; export GIT_COMMITTER_NAME
|
2008-07-26 20:52:54 +00:00
|
|
|
|
|
|
|
test_expect_success 'setup copies' '
|
|
|
|
|
|
|
|
git config --unset i18n.commitencoding &&
|
|
|
|
git checkout -b copy rein &&
|
|
|
|
git mv file file3 &&
|
|
|
|
git commit -m move1 &&
|
|
|
|
test_tick &&
|
|
|
|
cp file2 file4 &&
|
|
|
|
git add file4 &&
|
|
|
|
git mv file2 file5 &&
|
|
|
|
git commit -m copy1 &&
|
|
|
|
test_tick &&
|
|
|
|
cp file3 file6 &&
|
|
|
|
git add file6 &&
|
|
|
|
git commit -m copy2 &&
|
|
|
|
test_tick &&
|
|
|
|
echo more text >> file6 &&
|
|
|
|
echo even more text >> file6 &&
|
|
|
|
git add file6 &&
|
|
|
|
git commit -m modify &&
|
|
|
|
test_tick &&
|
|
|
|
cp file6 file7 &&
|
|
|
|
echo test >> file7 &&
|
|
|
|
git add file7 &&
|
|
|
|
git commit -m copy_modify
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'fast-export -C -C | fast-import' '
|
|
|
|
|
|
|
|
ENTRY=$(git rev-parse --verify copy) &&
|
|
|
|
rm -rf new &&
|
|
|
|
mkdir new &&
|
|
|
|
git --git-dir=new/.git init &&
|
|
|
|
git fast-export -C -C --signed-tags=strip --all > output &&
|
fast-export: quote paths in output
Many pathnames in a fast-import stream need to be quoted. In
particular:
1. Pathnames at the end of an "M" or "D" line need quoting
if they contain a LF or start with double-quote.
2. Pathnames on a "C" or "R" line need quoting as above,
but also if they contain spaces.
For (1), we weren't quoting at all. For (2), we put
double-quotes around the paths to handle spaces, but ignored
the possibility that they would need further quoting.
This patch checks whether each pathname needs c-style
quoting, and uses it. This is slightly overkill for (1),
which doesn't actually need to quote many characters that
vanilla c-style quoting does. However, it shouldn't hurt, as
any implementation needs to be ready to handle quoted
strings anyway.
In addition to adding a test, we have to tweak a test which
blindly assumed that case (2) would always use
double-quotes, whether it needed to or not.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-05 22:36:22 +00:00
|
|
|
grep "^C file6 file7\$" output &&
|
2008-07-26 20:52:54 +00:00
|
|
|
cat output |
|
|
|
|
(cd new &&
|
|
|
|
git fast-import &&
|
|
|
|
test $ENTRY = $(git rev-parse --verify refs/heads/copy))
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-11-23 11:55:54 +00:00
|
|
|
test_expect_success 'fast-export | fast-import when master is tagged' '
|
2008-11-22 18:22:48 +00:00
|
|
|
|
|
|
|
git tag -m msg last &&
|
|
|
|
git fast-export -C -C --signed-tags=strip --all > output &&
|
|
|
|
test $(grep -c "^tag " output) = 3
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-12-20 00:00:27 +00:00
|
|
|
cat > tag-content << EOF
|
|
|
|
object $(git rev-parse HEAD)
|
|
|
|
type commit
|
|
|
|
tag rosten
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'cope with tagger-less tags' '
|
|
|
|
|
|
|
|
TAG=$(git hash-object -t tag -w tag-content) &&
|
|
|
|
git update-ref refs/tags/sonnenschein $TAG &&
|
|
|
|
git fast-export -C -C --signed-tags=strip --all > output &&
|
|
|
|
test $(grep -c "^tag " output) = 4 &&
|
|
|
|
! grep "Unspecified Tagger" output &&
|
|
|
|
git fast-export -C -C --signed-tags=strip --all \
|
|
|
|
--fake-missing-tagger > output &&
|
|
|
|
test $(grep -c "^tag " output) = 4 &&
|
|
|
|
grep "Unspecified Tagger" output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-06-26 04:48:32 +00:00
|
|
|
test_expect_success 'setup for limiting exports by PATH' '
|
|
|
|
mkdir limit-by-paths &&
|
2010-03-29 00:42:11 +00:00
|
|
|
(
|
|
|
|
cd limit-by-paths &&
|
|
|
|
git init &&
|
|
|
|
echo hi > there &&
|
|
|
|
git add there &&
|
|
|
|
git commit -m "First file" &&
|
|
|
|
echo foo > bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m "Second file" &&
|
|
|
|
git tag -a -m msg mytag &&
|
|
|
|
echo morefoo >> bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m "Change to second file"
|
|
|
|
)
|
2009-06-26 04:48:32 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
cat > limit-by-paths/expected << EOF
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
reset refs/tags/mytag
|
|
|
|
commit refs/tags/mytag
|
|
|
|
mark :2
|
|
|
|
author A U Thor <author@example.com> 1112912713 -0700
|
|
|
|
committer C O Mitter <committer@example.com> 1112912713 -0700
|
|
|
|
data 11
|
|
|
|
First file
|
|
|
|
M 100644 :1 there
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'dropping tag of filtered out object' '
|
2010-03-29 00:42:11 +00:00
|
|
|
(
|
2009-06-26 04:48:32 +00:00
|
|
|
cd limit-by-paths &&
|
|
|
|
git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
|
2012-11-28 22:11:09 +00:00
|
|
|
test_cmp expected output
|
2010-03-29 00:42:11 +00:00
|
|
|
)
|
2009-06-26 04:48:32 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
cat >> limit-by-paths/expected << EOF
|
|
|
|
tag mytag
|
|
|
|
from :2
|
|
|
|
tagger C O Mitter <committer@example.com> 1112912713 -0700
|
|
|
|
data 4
|
|
|
|
msg
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'rewriting tag of filtered out object' '
|
2010-03-29 00:42:11 +00:00
|
|
|
(
|
2009-06-26 04:48:32 +00:00
|
|
|
cd limit-by-paths &&
|
|
|
|
git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
|
2012-11-28 22:11:09 +00:00
|
|
|
test_cmp expected output
|
2010-03-29 00:42:11 +00:00
|
|
|
)
|
2009-06-26 04:48:32 +00:00
|
|
|
'
|
|
|
|
|
|
|
|
cat > limit-by-paths/expected << EOF
|
|
|
|
blob
|
|
|
|
mark :1
|
|
|
|
data 4
|
|
|
|
foo
|
|
|
|
|
|
|
|
blob
|
|
|
|
mark :2
|
|
|
|
data 3
|
|
|
|
hi
|
|
|
|
|
|
|
|
reset refs/heads/master
|
|
|
|
commit refs/heads/master
|
|
|
|
mark :3
|
|
|
|
author A U Thor <author@example.com> 1112912713 -0700
|
|
|
|
committer C O Mitter <committer@example.com> 1112912713 -0700
|
|
|
|
data 12
|
|
|
|
Second file
|
|
|
|
M 100644 :1 bar
|
|
|
|
M 100644 :2 there
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_failure 'no exact-ref revisions included' '
|
2010-03-29 00:42:11 +00:00
|
|
|
(
|
|
|
|
cd limit-by-paths &&
|
|
|
|
git fast-export master~2..master~1 > output &&
|
2012-11-28 22:11:09 +00:00
|
|
|
test_cmp expected output
|
2010-03-29 00:42:11 +00:00
|
|
|
)
|
2009-06-26 04:48:32 +00:00
|
|
|
'
|
|
|
|
|
2010-07-17 17:00:50 +00:00
|
|
|
test_expect_success 'path limiting with import-marks does not lose unmodified files' '
|
|
|
|
git checkout -b simple marks~2 &&
|
|
|
|
git fast-export --export-marks=marks simple -- file > /dev/null &&
|
|
|
|
echo more content >> file &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -mnext file &&
|
|
|
|
git fast-export --import-marks=marks simple -- file file0 | grep file0
|
|
|
|
'
|
|
|
|
|
2010-07-17 17:00:51 +00:00
|
|
|
test_expect_success 'full-tree re-shows unmodified files' '
|
|
|
|
git checkout -f simple &&
|
|
|
|
test $(git fast-export --full-tree simple | grep -c file0) -eq 3
|
|
|
|
'
|
|
|
|
|
2009-03-23 12:53:06 +00:00
|
|
|
test_expect_success 'set-up a few more tags for tag export tests' '
|
|
|
|
git checkout -f master &&
|
|
|
|
HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&
|
|
|
|
git tag tree_tag -m "tagging a tree" $HEAD_TREE &&
|
|
|
|
git tag -a tree_tag-obj -m "tagging a tree" $HEAD_TREE &&
|
|
|
|
git tag tag-obj_tag -m "tagging a tag" tree_tag-obj &&
|
|
|
|
git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj
|
|
|
|
'
|
|
|
|
|
2009-06-26 04:48:28 +00:00
|
|
|
test_expect_success 'tree_tag' '
|
|
|
|
mkdir result &&
|
|
|
|
(cd result && git init) &&
|
|
|
|
git fast-export tree_tag > fe-stream &&
|
|
|
|
(cd result && git fast-import < ../fe-stream)
|
|
|
|
'
|
|
|
|
|
2009-03-23 12:53:06 +00:00
|
|
|
# NEEDSWORK: not just check return status, but validate the output
|
2009-03-23 12:53:08 +00:00
|
|
|
test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj'
|
2009-03-23 12:53:09 +00:00
|
|
|
test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag'
|
|
|
|
test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'
|
2009-03-23 12:53:06 +00:00
|
|
|
|
2013-06-07 20:53:28 +00:00
|
|
|
test_expect_success 'directory becomes symlink' '
|
2010-07-09 13:10:51 +00:00
|
|
|
git init dirtosymlink &&
|
|
|
|
git init result &&
|
|
|
|
(
|
|
|
|
cd dirtosymlink &&
|
|
|
|
mkdir foo &&
|
|
|
|
mkdir bar &&
|
|
|
|
echo hello > foo/world &&
|
|
|
|
echo hello > bar/world &&
|
|
|
|
git add foo/world bar/world &&
|
|
|
|
git commit -q -mone &&
|
|
|
|
git rm -r foo &&
|
2013-06-07 20:53:28 +00:00
|
|
|
test_ln_s_add bar foo &&
|
2010-07-09 13:10:51 +00:00
|
|
|
git commit -q -mtwo
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
cd dirtosymlink &&
|
|
|
|
git fast-export master -- foo |
|
|
|
|
(cd ../result && git fast-import --quiet)
|
|
|
|
) &&
|
|
|
|
(cd result && git show master:foo)
|
|
|
|
'
|
|
|
|
|
fast-export: quote paths in output
Many pathnames in a fast-import stream need to be quoted. In
particular:
1. Pathnames at the end of an "M" or "D" line need quoting
if they contain a LF or start with double-quote.
2. Pathnames on a "C" or "R" line need quoting as above,
but also if they contain spaces.
For (1), we weren't quoting at all. For (2), we put
double-quotes around the paths to handle spaces, but ignored
the possibility that they would need further quoting.
This patch checks whether each pathname needs c-style
quoting, and uses it. This is slightly overkill for (1),
which doesn't actually need to quote many characters that
vanilla c-style quoting does. However, it shouldn't hurt, as
any implementation needs to be ready to handle quoted
strings anyway.
In addition to adding a test, we have to tweak a test which
blindly assumed that case (2) would always use
double-quotes, whether it needed to or not.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-05 22:36:22 +00:00
|
|
|
test_expect_success 'fast-export quotes pathnames' '
|
|
|
|
git init crazy-paths &&
|
|
|
|
(cd crazy-paths &&
|
|
|
|
blob=`echo foo | git hash-object -w --stdin` &&
|
|
|
|
git update-index --add \
|
|
|
|
--cacheinfo 100644 $blob "$(printf "path with\\nnewline")" \
|
|
|
|
--cacheinfo 100644 $blob "path with \"quote\"" \
|
|
|
|
--cacheinfo 100644 $blob "path with \\backslash" \
|
|
|
|
--cacheinfo 100644 $blob "path with space" &&
|
|
|
|
git commit -m addition &&
|
2012-06-12 16:49:59 +00:00
|
|
|
git ls-files -z -s | "$PERL_PATH" -0pe "s{\\t}{$&subdir/}" >index &&
|
fast-export: quote paths in output
Many pathnames in a fast-import stream need to be quoted. In
particular:
1. Pathnames at the end of an "M" or "D" line need quoting
if they contain a LF or start with double-quote.
2. Pathnames on a "C" or "R" line need quoting as above,
but also if they contain spaces.
For (1), we weren't quoting at all. For (2), we put
double-quotes around the paths to handle spaces, but ignored
the possibility that they would need further quoting.
This patch checks whether each pathname needs c-style
quoting, and uses it. This is slightly overkill for (1),
which doesn't actually need to quote many characters that
vanilla c-style quoting does. However, it shouldn't hurt, as
any implementation needs to be ready to handle quoted
strings anyway.
In addition to adding a test, we have to tweak a test which
blindly assumed that case (2) would always use
double-quotes, whether it needed to or not.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-05 22:36:22 +00:00
|
|
|
git read-tree --empty &&
|
|
|
|
git update-index -z --index-info <index &&
|
|
|
|
git commit -m rename &&
|
|
|
|
git read-tree --empty &&
|
|
|
|
git commit -m deletion &&
|
2012-06-27 21:58:01 +00:00
|
|
|
git fast-export -M HEAD >export.out &&
|
fast-export: quote paths in output
Many pathnames in a fast-import stream need to be quoted. In
particular:
1. Pathnames at the end of an "M" or "D" line need quoting
if they contain a LF or start with double-quote.
2. Pathnames on a "C" or "R" line need quoting as above,
but also if they contain spaces.
For (1), we weren't quoting at all. For (2), we put
double-quotes around the paths to handle spaces, but ignored
the possibility that they would need further quoting.
This patch checks whether each pathname needs c-style
quoting, and uses it. This is slightly overkill for (1),
which doesn't actually need to quote many characters that
vanilla c-style quoting does. However, it shouldn't hurt, as
any implementation needs to be ready to handle quoted
strings anyway.
In addition to adding a test, we have to tweak a test which
blindly assumed that case (2) would always use
double-quotes, whether it needed to or not.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-05 22:36:22 +00:00
|
|
|
git rev-list HEAD >expect &&
|
|
|
|
git init result &&
|
|
|
|
cd result &&
|
|
|
|
git fast-import <../export.out &&
|
|
|
|
git rev-list HEAD >actual &&
|
|
|
|
test_cmp ../expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2012-11-24 03:17:01 +00:00
|
|
|
test_expect_success 'test bidirectionality' '
|
|
|
|
>marks-cur &&
|
|
|
|
>marks-new &&
|
|
|
|
git init marks-test &&
|
|
|
|
git fast-export --export-marks=marks-cur --import-marks=marks-cur --branches | \
|
|
|
|
git --git-dir=marks-test/.git fast-import --export-marks=marks-new --import-marks=marks-new &&
|
|
|
|
(cd marks-test &&
|
|
|
|
git reset --hard &&
|
|
|
|
echo Wohlauf > file &&
|
|
|
|
git commit -a -m "back in time") &&
|
|
|
|
git --git-dir=marks-test/.git fast-export --export-marks=marks-new --import-marks=marks-new --branches | \
|
|
|
|
git fast-import --export-marks=marks-cur --import-marks=marks-cur
|
|
|
|
'
|
|
|
|
|
fast-export: don't handle uninteresting refs
They have been marked as UNINTERESTING for a reason, lets respect
that. Currently the first ref is handled properly, but not the
rest. Assuming that all the refs point at the same commit in the
following example:
% git fast-export master ^uninteresting ^foo ^bar
reset refs/heads/bar
from :0
reset refs/heads/foo
from :0
reset refs/heads/uninteresting
from :0
% git fast-export ^uninteresting ^foo ^bar master
reset refs/heads/master
from :0
reset refs/heads/bar
from :0
reset refs/heads/foo
from :0
Clearly this is wrong; the negative refs should be ignored.
After this patch:
% git fast-export ^uninteresting ^foo ^bar master
# nothing
% git fast-export master ^uninteresting ^foo ^bar
# nothing
And even more, it would only happen if the ref is pointing to exactly
the same commit, but not otherwise:
% git fast-export ^next next
reset refs/heads/next
from :0
% git fast-export ^next next^{commit}
# nothing
% git fast-export ^next next~0
# nothing
% git fast-export ^next next~1
# nothing
% git fast-export ^next next~2
# nothing
The reason this happens is that before traversing the commits,
fast-export checks if any of the refs point to the same object, and any
duplicated ref gets added to a list in order to issue 'reset' commands
after the traversing. Unfortunately, it's not even checking if the
commit is flagged as UNINTERESTING. The fix of course, is to check it.
However, in order to do it properly we need to get the UNINTERESTING
flag from the command line, not from the commit object, because
"^foo bar" will mark the commit 'bar' uninteresting if foo and bar
points at the same commit. rev_cmdline_info, which was introduced
exactly to handle this situation, contains all the information we
need for get_tags_and_duplicates(), plus the ref flag. This way the
rest of the positive refs will remain untouched; it's only the
negative ones that change in behavior.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-28 22:23:59 +00:00
|
|
|
cat > expected << EOF
|
|
|
|
blob
|
|
|
|
mark :13
|
|
|
|
data 5
|
|
|
|
bump
|
|
|
|
|
|
|
|
commit refs/heads/master
|
|
|
|
mark :14
|
|
|
|
author A U Thor <author@example.com> 1112912773 -0700
|
|
|
|
committer C O Mitter <committer@example.com> 1112912773 -0700
|
|
|
|
data 5
|
|
|
|
bump
|
|
|
|
from :12
|
|
|
|
M 100644 :13 file
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'avoid uninteresting refs' '
|
|
|
|
> tmp-marks &&
|
|
|
|
git fast-export --import-marks=tmp-marks \
|
|
|
|
--export-marks=tmp-marks master > /dev/null &&
|
|
|
|
git tag v1.0 &&
|
|
|
|
git branch uninteresting &&
|
|
|
|
echo bump > file &&
|
|
|
|
git commit -a -m bump &&
|
|
|
|
git fast-export --import-marks=tmp-marks \
|
|
|
|
--export-marks=tmp-marks ^uninteresting ^v1.0 master > actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
fast-export: make sure updated refs get updated
When an object has already been exported (and thus is in the marks) it's
flagged as SHOWN, so it will not be exported again, even if in a later
time it's exported through a different ref.
We don't need the object to be exported again, but we want the ref
updated, which doesn't happen.
Since we can't know if a ref was exported or not, let's just assume that
if the commit was marked (flags & SHOWN), the user still wants the ref
updated.
IOW: If it's specified in the command line, it will get updated,
regardless of whether or not the object was marked.
So:
% git branch test master
% git fast-export $mark_flags master
% git fast-export $mark_flags test
Would export 'test' properly.
Additionally, this fixes issues with remote helpers; now they can push
refs whose objects have already been exported, and a few other issues as
well. Update the tests accordingly.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-28 22:24:00 +00:00
|
|
|
cat > expected << EOF
|
|
|
|
reset refs/heads/master
|
|
|
|
from :14
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'refs are updated even if no commits need to be exported' '
|
|
|
|
> tmp-marks &&
|
|
|
|
git fast-export --import-marks=tmp-marks \
|
|
|
|
--export-marks=tmp-marks master > /dev/null &&
|
|
|
|
git fast-export --import-marks=tmp-marks \
|
|
|
|
--export-marks=tmp-marks master > actual &&
|
|
|
|
test_cmp expected actual
|
|
|
|
'
|
|
|
|
|
2007-12-02 14:14:13 +00:00
|
|
|
test_done
|