2007-01-16 04:31:49 +03:00
|
|
|
#!/bin/sh
|
2006-11-12 18:29:42 +03:00
|
|
|
#
|
|
|
|
# Copyright (c) Robin Rosenberg
|
|
|
|
#
|
2008-02-13 06:11:22 +03:00
|
|
|
test_description='Test export of commits to CVS'
|
2006-11-12 18:29:42 +03:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2009-04-03 23:33:59 +04:00
|
|
|
if ! test_have_prereq PERL; then
|
2010-06-24 21:44:48 +04:00
|
|
|
skip_all='skipping git cvsexportcommit tests, perl not available'
|
2009-04-03 23:33:59 +04:00
|
|
|
test_done
|
|
|
|
fi
|
|
|
|
|
2006-11-12 18:29:42 +03:00
|
|
|
cvs >/dev/null 2>&1
|
|
|
|
if test $? -ne 1
|
|
|
|
then
|
2010-06-24 21:44:48 +04:00
|
|
|
skip_all='skipping git cvsexportcommit tests, cvs not found'
|
2006-11-12 18:29:42 +03:00
|
|
|
test_done
|
|
|
|
fi
|
|
|
|
|
2012-10-26 20:18:24 +04:00
|
|
|
CVSROOT=$PWD/tmpcvsroot
|
2012-01-11 13:20:14 +04:00
|
|
|
CVSWORK=$PWD/cvswork
|
|
|
|
GIT_DIR=$PWD/.git
|
2006-12-28 12:10:52 +03:00
|
|
|
export CVSROOT CVSWORK GIT_DIR
|
|
|
|
|
2006-11-12 18:29:42 +03:00
|
|
|
rm -rf "$CVSROOT" "$CVSWORK"
|
2012-12-25 05:09:49 +04:00
|
|
|
|
2006-11-12 18:29:42 +03:00
|
|
|
cvs init &&
|
2012-12-25 05:09:49 +04:00
|
|
|
test -d "$CVSROOT" &&
|
2006-11-12 18:29:42 +03:00
|
|
|
cvs -Q co -d "$CVSWORK" . &&
|
|
|
|
echo >empty &&
|
|
|
|
git add empty &&
|
2006-12-28 12:10:52 +03:00
|
|
|
git commit -q -a -m "Initial" 2>/dev/null ||
|
2006-11-12 18:29:42 +03:00
|
|
|
exit 1
|
|
|
|
|
2007-07-25 10:25:38 +04:00
|
|
|
check_entries () {
|
|
|
|
# $1 == directory, $2 == expected
|
2016-02-21 20:32:22 +03:00
|
|
|
sed -ne '/^\//p' "$1/CVS/Entries" | sort | cut -d/ -f2,3,5 >actual
|
2007-07-25 10:25:38 +04:00
|
|
|
if test -z "$2"
|
|
|
|
then
|
|
|
|
>expected
|
|
|
|
else
|
|
|
|
printf '%s\n' "$2" | tr '|' '\012' >expected
|
|
|
|
fi
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp expected actual
|
2007-07-25 10:25:38 +04:00
|
|
|
}
|
|
|
|
|
2006-11-12 18:29:42 +03:00
|
|
|
test_expect_success \
|
|
|
|
'New file' \
|
|
|
|
'mkdir A B C D E F &&
|
|
|
|
echo hello1 >A/newfile1.txt &&
|
|
|
|
echo hello2 >B/newfile2.txt &&
|
2011-07-19 21:21:47 +04:00
|
|
|
cp "$TEST_DIRECTORY"/test-binary-1.png C/newfile3.png &&
|
|
|
|
cp "$TEST_DIRECTORY"/test-binary-1.png D/newfile4.png &&
|
2006-11-12 18:29:42 +03:00
|
|
|
git add A/newfile1.txt &&
|
|
|
|
git add B/newfile2.txt &&
|
|
|
|
git add C/newfile3.png &&
|
|
|
|
git add D/newfile4.png &&
|
|
|
|
git commit -a -m "Test: New file" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
|
|
|
git cvsexportcommit -c $id &&
|
2007-07-25 10:25:38 +04:00
|
|
|
check_entries A "newfile1.txt/1.1/" &&
|
|
|
|
check_entries B "newfile2.txt/1.1/" &&
|
|
|
|
check_entries C "newfile3.png/1.1/-kb" &&
|
|
|
|
check_entries D "newfile4.png/1.1/-kb" &&
|
2010-05-14 13:31:37 +04:00
|
|
|
test_cmp A/newfile1.txt ../A/newfile1.txt &&
|
|
|
|
test_cmp B/newfile2.txt ../B/newfile2.txt &&
|
|
|
|
test_cmp C/newfile3.png ../C/newfile3.png &&
|
|
|
|
test_cmp D/newfile4.png ../D/newfile4.png
|
2006-11-12 18:29:42 +03:00
|
|
|
)'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'Remove two files, add two and update two' \
|
|
|
|
'echo Hello1 >>A/newfile1.txt &&
|
|
|
|
rm -f B/newfile2.txt &&
|
|
|
|
rm -f C/newfile3.png &&
|
|
|
|
echo Hello5 >E/newfile5.txt &&
|
2011-07-19 21:21:47 +04:00
|
|
|
cp "$TEST_DIRECTORY"/test-binary-2.png D/newfile4.png &&
|
|
|
|
cp "$TEST_DIRECTORY"/test-binary-1.png F/newfile6.png &&
|
2006-11-12 18:29:42 +03:00
|
|
|
git add E/newfile5.txt &&
|
|
|
|
git add F/newfile6.png &&
|
|
|
|
git commit -a -m "Test: Remove, add and update" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
|
|
|
git cvsexportcommit -c $id &&
|
2007-07-25 10:25:38 +04:00
|
|
|
check_entries A "newfile1.txt/1.2/" &&
|
|
|
|
check_entries B "" &&
|
|
|
|
check_entries C "" &&
|
|
|
|
check_entries D "newfile4.png/1.2/-kb" &&
|
|
|
|
check_entries E "newfile5.txt/1.1/" &&
|
|
|
|
check_entries F "newfile6.png/1.1/-kb" &&
|
2010-05-14 13:31:37 +04:00
|
|
|
test_cmp A/newfile1.txt ../A/newfile1.txt &&
|
|
|
|
test_cmp D/newfile4.png ../D/newfile4.png &&
|
|
|
|
test_cmp E/newfile5.txt ../E/newfile5.txt &&
|
|
|
|
test_cmp F/newfile6.png ../F/newfile6.png
|
2006-11-12 18:29:42 +03:00
|
|
|
)'
|
|
|
|
|
2008-09-10 01:25:24 +04:00
|
|
|
# Should fail (but only on the git cvsexportcommit stage)
|
2006-11-12 18:29:42 +03:00
|
|
|
test_expect_success \
|
|
|
|
'Fail to change binary more than one generation old' \
|
|
|
|
'cat F/newfile6.png >>D/newfile4.png &&
|
|
|
|
git commit -a -m "generatiion 1" &&
|
|
|
|
cat F/newfile6.png >>D/newfile4.png &&
|
|
|
|
git commit -a -m "generation 2" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
2008-07-12 19:47:52 +04:00
|
|
|
test_must_fail git cvsexportcommit -c $id
|
2006-11-12 18:29:42 +03:00
|
|
|
)'
|
|
|
|
|
2006-12-11 02:30:06 +03:00
|
|
|
#test_expect_success \
|
|
|
|
# 'Fail to remove binary file more than one generation old' \
|
|
|
|
# 'git reset --hard HEAD^ &&
|
|
|
|
# cat F/newfile6.png >>D/newfile4.png &&
|
|
|
|
# git commit -a -m "generation 2 (again)" &&
|
|
|
|
# rm -f D/newfile4.png &&
|
|
|
|
# git commit -a -m "generation 3" &&
|
|
|
|
# id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
# (cd "$CVSWORK" &&
|
2008-07-12 19:47:52 +04:00
|
|
|
# test_must_fail git cvsexportcommit -c $id
|
2006-12-11 02:30:06 +03:00
|
|
|
# )'
|
2006-11-12 18:29:42 +03:00
|
|
|
|
|
|
|
# We reuse the state from two tests back here
|
|
|
|
|
|
|
|
# This test is here because a patch for only binary files will
|
|
|
|
# fail with gnu patch, so cvsexportcommit must handle that.
|
|
|
|
test_expect_success \
|
|
|
|
'Remove only binary files' \
|
2006-12-11 02:30:06 +03:00
|
|
|
'git reset --hard HEAD^^ &&
|
2006-11-12 18:29:42 +03:00
|
|
|
rm -f D/newfile4.png &&
|
|
|
|
git commit -a -m "test: remove only a binary file" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
|
|
|
git cvsexportcommit -c $id &&
|
2007-07-25 10:25:38 +04:00
|
|
|
check_entries A "newfile1.txt/1.2/" &&
|
|
|
|
check_entries B "" &&
|
|
|
|
check_entries C "" &&
|
|
|
|
check_entries D "" &&
|
|
|
|
check_entries E "newfile5.txt/1.1/" &&
|
|
|
|
check_entries F "newfile6.png/1.1/-kb" &&
|
2010-05-14 13:31:37 +04:00
|
|
|
test_cmp A/newfile1.txt ../A/newfile1.txt &&
|
|
|
|
test_cmp E/newfile5.txt ../E/newfile5.txt &&
|
|
|
|
test_cmp F/newfile6.png ../F/newfile6.png
|
2006-11-12 18:29:42 +03:00
|
|
|
)'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'Remove only a text file' \
|
|
|
|
'rm -f A/newfile1.txt &&
|
|
|
|
git commit -a -m "test: remove only a binary file" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
|
|
|
git cvsexportcommit -c $id &&
|
2007-07-25 10:25:38 +04:00
|
|
|
check_entries A "" &&
|
|
|
|
check_entries B "" &&
|
|
|
|
check_entries C "" &&
|
|
|
|
check_entries D "" &&
|
|
|
|
check_entries E "newfile5.txt/1.1/" &&
|
|
|
|
check_entries F "newfile6.png/1.1/-kb" &&
|
2010-05-14 13:31:37 +04:00
|
|
|
test_cmp E/newfile5.txt ../E/newfile5.txt &&
|
|
|
|
test_cmp F/newfile6.png ../F/newfile6.png
|
2006-11-12 18:29:42 +03:00
|
|
|
)'
|
|
|
|
|
2006-12-11 02:30:06 +03:00
|
|
|
test_expect_success \
|
|
|
|
'New file with spaces in file name' \
|
|
|
|
'mkdir "G g" &&
|
|
|
|
echo ok then >"G g/with spaces.txt" &&
|
|
|
|
git add "G g/with spaces.txt" && \
|
2011-07-19 21:21:47 +04:00
|
|
|
cp "$TEST_DIRECTORY"/test-binary-1.png "G g/with spaces.png" && \
|
2006-12-11 02:30:06 +03:00
|
|
|
git add "G g/with spaces.png" &&
|
|
|
|
git commit -a -m "With spaces" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
2008-09-10 01:25:24 +04:00
|
|
|
git cvsexportcommit -c $id &&
|
2007-07-25 10:25:38 +04:00
|
|
|
check_entries "G g" "with spaces.png/1.1/-kb|with spaces.txt/1.1/"
|
2006-12-11 02:30:06 +03:00
|
|
|
)'
|
|
|
|
|
|
|
|
test_expect_success \
|
|
|
|
'Update file with spaces in file name' \
|
|
|
|
'echo Ok then >>"G g/with spaces.txt" &&
|
2011-07-19 21:21:47 +04:00
|
|
|
cat "$TEST_DIRECTORY"/test-binary-1.png >>"G g/with spaces.png" && \
|
2006-12-11 02:30:06 +03:00
|
|
|
git add "G g/with spaces.png" &&
|
|
|
|
git commit -a -m "Update with spaces" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
2008-09-10 01:25:24 +04:00
|
|
|
git cvsexportcommit -c $id
|
2007-07-25 10:25:38 +04:00
|
|
|
check_entries "G g" "with spaces.png/1.2/-kb|with spaces.txt/1.2/"
|
2006-12-11 02:30:06 +03:00
|
|
|
)'
|
|
|
|
|
2007-02-05 04:30:58 +03:00
|
|
|
# Some filesystems mangle pathnames with UTF-8 characters --
|
|
|
|
# check and skip
|
|
|
|
if p="Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" &&
|
|
|
|
mkdir -p "tst/$p" &&
|
|
|
|
date >"tst/$p/day" &&
|
|
|
|
found=$(find tst -type f -print) &&
|
|
|
|
test "z$found" = "ztst/$p/day" &&
|
|
|
|
rm -fr tst
|
|
|
|
then
|
|
|
|
|
2007-02-01 01:21:48 +03:00
|
|
|
# This test contains UTF-8 characters
|
mingw: do not bother to test funny file names
MSYS2 actually allows to create files or directories whose names contain
tabs, newlines or colors, even if plain Win32 API cannot access them.
As we are using an MSYS2 bash to run the tests, such files or
directories are created successfully, but Git itself has no chance to
work with them because it is a regular Windows program, hence limited by
the Win32 API.
With this change, on Windows otherwise failing tests in
t3300-funny-names.sh, t3600-rm.sh, t3703-add-magic-pathspec.sh,
t3902-quoted.sh, t4016-diff-quote.sh, t4135-apply-weird-filenames.sh,
t9200-git-cvsexportcommit.sh, and t9903-bash-prompt.sh are skipped.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-01-27 19:20:26 +03:00
|
|
|
test_expect_success !MINGW \
|
2006-12-11 02:30:06 +03:00
|
|
|
'File with non-ascii file name' \
|
2007-02-01 01:21:48 +03:00
|
|
|
'mkdir -p Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö &&
|
|
|
|
echo Foo >Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
|
|
|
|
git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.txt &&
|
2011-07-19 21:21:47 +04:00
|
|
|
cp "$TEST_DIRECTORY"/test-binary-1.png Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
|
2007-02-01 01:21:48 +03:00
|
|
|
git add Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö/gårdetsågårdet.png &&
|
|
|
|
git commit -a -m "Går det så går det" && \
|
2006-12-11 02:30:06 +03:00
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
2008-09-10 01:25:24 +04:00
|
|
|
git cvsexportcommit -v -c $id &&
|
2007-07-25 10:25:38 +04:00
|
|
|
check_entries \
|
|
|
|
"Å/goo/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z/å/ä/ö" \
|
|
|
|
"gårdetsågårdet.png/1.1/-kb|gårdetsågårdet.txt/1.1/"
|
2006-12-11 02:30:06 +03:00
|
|
|
)'
|
|
|
|
|
2007-02-05 04:30:58 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
rm -fr tst
|
|
|
|
|
2006-12-11 02:30:06 +03:00
|
|
|
test_expect_success \
|
|
|
|
'Mismatching patch should fail' \
|
|
|
|
'date >>"E/newfile5.txt" &&
|
|
|
|
git add "E/newfile5.txt" &&
|
|
|
|
git commit -a -m "Update one" &&
|
|
|
|
date >>"E/newfile5.txt" &&
|
|
|
|
git add "E/newfile5.txt" &&
|
|
|
|
git commit -a -m "Update two" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$CVSWORK" &&
|
2008-09-10 01:25:24 +04:00
|
|
|
test_must_fail git cvsexportcommit -c $id
|
2006-12-11 02:30:06 +03:00
|
|
|
)'
|
|
|
|
|
2009-02-28 00:20:57 +03:00
|
|
|
test_expect_success FILEMODE \
|
2006-12-11 02:30:06 +03:00
|
|
|
'Retain execute bit' \
|
|
|
|
'mkdir G &&
|
|
|
|
echo executeon >G/on &&
|
|
|
|
chmod +x G/on &&
|
|
|
|
echo executeoff >G/off &&
|
|
|
|
git add G/on &&
|
|
|
|
git add G/off &&
|
|
|
|
git commit -a -m "Execute test" &&
|
|
|
|
(cd "$CVSWORK" &&
|
2008-09-10 01:25:24 +04:00
|
|
|
git cvsexportcommit -c HEAD
|
2006-12-11 02:30:06 +03:00
|
|
|
test -x G/on &&
|
|
|
|
! test -x G/off
|
|
|
|
)'
|
2006-12-04 10:44:08 +03:00
|
|
|
|
2008-02-12 02:43:41 +03:00
|
|
|
test_expect_success '-w option should work with relative GIT_DIR' '
|
2008-02-13 06:11:22 +03:00
|
|
|
mkdir W &&
|
|
|
|
echo foobar >W/file1.txt &&
|
|
|
|
echo bazzle >W/file2.txt &&
|
|
|
|
git add W/file1.txt &&
|
|
|
|
git add W/file2.txt &&
|
|
|
|
git commit -m "More updates" &&
|
|
|
|
id=$(git rev-list --max-count=1 HEAD) &&
|
|
|
|
(cd "$GIT_DIR" &&
|
|
|
|
GIT_DIR=. git cvsexportcommit -w "$CVSWORK" -c $id &&
|
|
|
|
check_entries "$CVSWORK/W" "file1.txt/1.1/|file2.txt/1.1/" &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp "$CVSWORK/W/file1.txt" ../W/file1.txt &&
|
|
|
|
test_cmp "$CVSWORK/W/file2.txt" ../W/file2.txt
|
2008-02-13 06:11:22 +03:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2008-02-18 20:55:22 +03:00
|
|
|
test_expect_success 'check files before directories' '
|
|
|
|
|
|
|
|
echo Notes > release-notes &&
|
|
|
|
git add release-notes &&
|
|
|
|
git commit -m "Add release notes" release-notes &&
|
|
|
|
id=$(git rev-parse HEAD) &&
|
|
|
|
git cvsexportcommit -w "$CVSWORK" -c $id &&
|
|
|
|
|
|
|
|
echo new > DS &&
|
|
|
|
echo new > E/DS &&
|
|
|
|
echo modified > release-notes &&
|
|
|
|
git add DS E/DS release-notes &&
|
|
|
|
git commit -m "Add two files with the same basename" &&
|
|
|
|
id=$(git rev-parse HEAD) &&
|
|
|
|
git cvsexportcommit -w "$CVSWORK" -c $id &&
|
|
|
|
check_entries "$CVSWORK/E" "DS/1.1/|newfile5.txt/1.1/" &&
|
|
|
|
check_entries "$CVSWORK" "DS/1.1/|release-notes/1.2/" &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp "$CVSWORK/DS" DS &&
|
|
|
|
test_cmp "$CVSWORK/E/DS" E/DS &&
|
|
|
|
test_cmp "$CVSWORK/release-notes" release-notes
|
2008-02-18 20:55:22 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-07-15 18:34:24 +04:00
|
|
|
test_expect_success 're-commit a removed filename which remains in CVS attic' '
|
|
|
|
|
|
|
|
(cd "$CVSWORK" &&
|
|
|
|
echo >attic_gremlin &&
|
|
|
|
cvs -Q add attic_gremlin &&
|
|
|
|
cvs -Q ci -m "added attic_gremlin" &&
|
|
|
|
rm attic_gremlin &&
|
|
|
|
cvs -Q rm attic_gremlin &&
|
|
|
|
cvs -Q ci -m "removed attic_gremlin") &&
|
|
|
|
|
|
|
|
echo > attic_gremlin &&
|
|
|
|
git add attic_gremlin &&
|
|
|
|
git commit -m "Added attic_gremlin" &&
|
|
|
|
git cvsexportcommit -w "$CVSWORK" -c HEAD &&
|
|
|
|
(cd "$CVSWORK"; cvs -Q update -d) &&
|
|
|
|
test -f "$CVSWORK/attic_gremlin"
|
|
|
|
'
|
|
|
|
|
|
|
|
# the state of the CVS sandbox may be indeterminate for ' space'
|
|
|
|
# after this test on some platforms / with some versions of CVS
|
|
|
|
# consider adding new tests above this point
|
2008-02-18 20:55:22 +03:00
|
|
|
test_expect_success 'commit a file with leading spaces in the name' '
|
|
|
|
|
|
|
|
echo space > " space" &&
|
|
|
|
git add " space" &&
|
|
|
|
git commit -m "Add a file with a leading space" &&
|
|
|
|
id=$(git rev-parse HEAD) &&
|
|
|
|
git cvsexportcommit -w "$CVSWORK" -c $id &&
|
2009-07-15 18:34:24 +04:00
|
|
|
check_entries "$CVSWORK" " space/1.1/|DS/1.1/|attic_gremlin/1.3/|release-notes/1.2/" &&
|
2008-03-13 00:36:36 +03:00
|
|
|
test_cmp "$CVSWORK/ space" " space"
|
2008-02-18 20:55:22 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-05-14 18:29:49 +04:00
|
|
|
test_expect_success 'use the same checkout for Git and CVS' '
|
|
|
|
|
|
|
|
(mkdir shared &&
|
|
|
|
cd shared &&
|
2012-02-12 05:05:12 +04:00
|
|
|
sane_unset GIT_DIR &&
|
2008-05-14 18:29:49 +04:00
|
|
|
cvs co . &&
|
|
|
|
git init &&
|
|
|
|
git add " space" &&
|
|
|
|
git commit -m "fake initial commit" &&
|
|
|
|
echo Hello >> " space" &&
|
|
|
|
git commit -m "Another change" " space" &&
|
|
|
|
git cvsexportcommit -W -p -u -c HEAD &&
|
|
|
|
grep Hello " space" &&
|
|
|
|
git diff-files)
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2006-11-12 18:29:42 +03:00
|
|
|
test_done
|