summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/t0000-basic.sh29
-rw-r--r--t/t1300-repo-config.sh20
-rwxr-xr-xt/t3300-funny-names.sh28
-rwxr-xr-xt/t5501-old-fetch-and-upload.sh13
-rwxr-xr-xt/t6022-merge-rename.sh164
-rwxr-xr-xt/test-lib.sh25
6 files changed, 236 insertions, 43 deletions
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 22bdacaf78..bc3e711a52 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -17,8 +17,37 @@ IDs. When object ID computation changes, like in the previous case of
swapping compression and hashing order, the person who is making the
modification *should* take notice and update the test vectors here.
'
+
+################################################################
+# It appears that people are getting bitten by not installing
+# 'merge' (usually part of RCS package in binary distributions)
+# or have too old python without subprocess. Check them and error
+# out before running any tests. Also catch the bogosity of trying
+# to run tests without building while we are at it.
+
+../git >/dev/null
+if test $? != 1
+then
+ echo >&2 'You do not seem to have built git yet.'
+ exit 1
+fi
+
+merge >/dev/null 2>/dev/null
+if test $? == 127
+then
+ echo >&2 'You do not seem to have "merge" installed.
+Please check INSTALL document.'
+ exit 1
+fi
+
. ./test-lib.sh
+"$PYTHON" -c 'import subprocess' || {
+ echo >&2 'Your python seem to lack "subprocess" module.
+Please check INSTALL document.'
+ exit 1
+}
+
################################################################
# init-db has been done in an empty repository.
# make sure it is empty.
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 5e994ff009..207dd3de64 100644
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -12,10 +12,6 @@ test -f .git/config && rm .git/config
git-repo-config core.penguin "little blue"
cat > expect << EOF
-#
-# This is the config file
-#
-
[core]
penguin = little blue
EOF
@@ -25,10 +21,6 @@ test_expect_success 'initial' 'cmp .git/config expect'
git-repo-config Core.Movie BadPhysics
cat > expect << EOF
-#
-# This is the config file
-#
-
[core]
penguin = little blue
Movie = BadPhysics
@@ -39,10 +31,6 @@ test_expect_success 'mixed case' 'cmp .git/config expect'
git-repo-config Cores.WhatEver Second
cat > expect << EOF
-#
-# This is the config file
-#
-
[core]
penguin = little blue
Movie = BadPhysics
@@ -55,10 +43,6 @@ test_expect_success 'similar section' 'cmp .git/config expect'
git-repo-config CORE.UPPERCASE true
cat > expect << EOF
-#
-# This is the config file
-#
-
[core]
penguin = little blue
Movie = BadPhysics
@@ -76,10 +60,6 @@ test_expect_success 'replace with non-match (actually matching)' \
'git-repo-config core.penguin "very blue" !kingpin'
cat > expect << EOF
-#
-# This is the config file
-#
-
[core]
penguin = very blue
Movie = BadPhysics
diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh
index 897c378422..6a85d67c57 100755
--- a/t/t3300-funny-names.sh
+++ b/t/t3300-funny-names.sh
@@ -15,7 +15,7 @@ test "$(uname -o 2>/dev/null)" = Cygwin && exit 0
. ./test-lib.sh
p0='no-funny'
-p1='tabs and spaces'
+p1='tabs ," (dq) and spaces'
p2='just space'
cat >"$p0" <<\EOF
@@ -39,7 +39,7 @@ echo "$t0" >t0
echo 'just space
no-funny
-"tabs\tand spaces"' >expected
+"tabs\t,\" (dq) and spaces"' >expected
test_expect_success 'git-ls-files with-funny' \
'git-update-index --add "$p1" &&
git-ls-files >current &&
@@ -47,7 +47,7 @@ test_expect_success 'git-ls-files with-funny' \
echo 'just space
no-funny
-tabs and spaces' >expected
+tabs ," (dq) and spaces' >expected
test_expect_success 'git-ls-files -z with-funny' \
'git-ls-files -z | tr \\0 \\012 >current &&
diff -u expected current'
@@ -57,12 +57,12 @@ echo "$t1" >t1
echo 'just space
no-funny
-"tabs\tand spaces"' >expected
+"tabs\t,\" (dq) and spaces"' >expected
test_expect_success 'git-ls-tree with funny' \
'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
diff -u expected current'
-echo 'A "tabs\tand spaces"' >expected
+echo 'A "tabs\t,\" (dq) and spaces"' >expected
test_expect_success 'git-diff-index with-funny' \
'git-diff-index --name-status $t0 >current &&
diff -u expected current'
@@ -72,7 +72,7 @@ test_expect_success 'git-diff-tree with-funny' \
diff -u expected current'
echo 'A
-tabs and spaces' >expected
+tabs ," (dq) and spaces' >expected
test_expect_success 'git-diff-index -z with-funny' \
'git-diff-index -z --name-status $t0 | tr \\0 \\012 >current &&
diff -u expected current'
@@ -81,23 +81,23 @@ test_expect_success 'git-diff-tree -z with-funny' \
'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
diff -u expected current'
-echo 'CNUM no-funny "tabs\tand spaces"' >expected
+echo 'CNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
test_expect_success 'git-diff-tree -C with-funny' \
'git-diff-tree -C --find-copies-harder --name-status \
$t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
diff -u expected current'
-echo 'RNUM no-funny "tabs\tand spaces"' >expected
+echo 'RNUM no-funny "tabs\t,\" (dq) and spaces"' >expected
test_expect_success 'git-diff-tree delete with-funny' \
'git-update-index --force-remove "$p0" &&
git-diff-index -M --name-status \
$t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
diff -u expected current'
-echo 'diff --git a/no-funny "b/tabs\tand spaces"
+echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
similarity index NUM%
rename from no-funny
-rename to "tabs\tand spaces"' >expected
+rename to "tabs\t,\" (dq) and spaces"' >expected
test_expect_success 'git-diff-tree delete with-funny' \
'git-diff-index -M -p $t0 |
@@ -105,19 +105,19 @@ test_expect_success 'git-diff-tree delete with-funny' \
diff -u expected current'
chmod +x "$p1"
-echo 'diff --git a/no-funny "b/tabs\tand spaces"
+echo 'diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
old mode 100644
new mode 100755
similarity index NUM%
rename from no-funny
-rename to "tabs\tand spaces"' >expected
+rename to "tabs\t,\" (dq) and spaces"' >expected
test_expect_success 'git-diff-tree delete with-funny' \
'git-diff-index -M -p $t0 |
sed -e "s/index [0-9]*%/index NUM%/" >current &&
diff -u expected current'
-echo >expected ' "tabs\tand spaces"
+echo >expected ' "tabs\t,\" (dq) and spaces"
1 files changed, 0 insertions(+), 0 deletions(-)'
test_expect_success 'git-diff-tree rename with-funny applied' \
'git-diff-index -M -p $t0 |
@@ -125,7 +125,7 @@ test_expect_success 'git-diff-tree rename with-funny applied' \
diff -u expected current'
echo >expected ' no-funny
- "tabs\tand spaces"
+ "tabs\t,\" (dq) and spaces"
2 files changed, 3 insertions(+), 3 deletions(-)'
test_expect_success 'git-diff-tree delete with-funny applied' \
diff --git a/t/t5501-old-fetch-and-upload.sh b/t/t5501-old-fetch-and-upload.sh
index ada5130328..596c88b1c2 100755
--- a/t/t5501-old-fetch-and-upload.sh
+++ b/t/t5501-old-fetch-and-upload.sh
@@ -7,8 +7,9 @@
# an old counterpart
cd $(dirname $0) || exit 1
+: ${SHELL_PATH=/bin/sh}
-tmp=$(mktemp /tmp/tmp-XXXXXXXX)
+tmp=`pwd`/.tmp$$
retval=0
@@ -25,13 +26,17 @@ for i in $list; do
both) pgm="old-git-upload-pack"; replace="old-git-fetch-pack --exec=$pgm";;
esac
- if which $pgm 2>/dev/null; then
+ if where=`LANG=C LC_ALL=C which "$pgm" 2>/dev/null` &&
+ case "$where" in
+ "no "*) (exit 1) ;;
+ esac
+ then
echo "Testing with $pgm"
sed -e "s/git-fetch-pack/$replace/g" \
-e "s/# old fails/warn/" < t5500-fetch-pack.sh > $tmp
- sh $tmp || retval=$?
- rm $tmp
+ "$SHELL_PATH" "$tmp" || retval=$?
+ rm -f "$tmp"
test $retval != 0 && exit $retval
else
diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh
new file mode 100755
index 0000000000..153b9e49f2
--- /dev/null
+++ b/t/t6022-merge-rename.sh
@@ -0,0 +1,164 @@
+#!/bin/sh
+
+test_description='Merge-recursive merging renames'
+. ./test-lib.sh
+
+test_expect_success setup \
+'
+cat >A <<\EOF &&
+a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+c cccccccccccccccccccccccccccccccccccccccccccccccc
+d dddddddddddddddddddddddddddddddddddddddddddddddd
+e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
+f ffffffffffffffffffffffffffffffffffffffffffffffff
+g gggggggggggggggggggggggggggggggggggggggggggggggg
+h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
+j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
+k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+l llllllllllllllllllllllllllllllllllllllllllllllll
+m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
+o oooooooooooooooooooooooooooooooooooooooooooooooo
+EOF
+
+cat >M <<\EOF &&
+A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
+E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
+F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
+G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
+H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
+J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
+K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
+L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
+M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
+N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
+O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
+EOF
+
+git add A M &&
+git commit -m initial &&
+git branch white &&
+git branch red &&
+git branch blue &&
+
+sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
+mv A+ A &&
+git commit -a -m "master updates A" &&
+
+git checkout white &&
+sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
+sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
+rm -f A M &&
+git update-index --add --remove A B M N &&
+git commit -m "white renames A->B, M->N" &&
+
+git checkout red &&
+sed -e "/^g /s/.*/g : red changes a line/" <A >B &&
+sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
+rm -f A M &&
+git update-index --add --remove A B M N &&
+git commit -m "red renames A->B, M->N" &&
+
+git checkout blue &&
+sed -e "/^g /s/.*/g : blue changes a line/" <A >C &&
+sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
+rm -f A M &&
+git update-index --add --remove A C M N &&
+git commit -m "blue renames A->C, M->N" &&
+
+git checkout master'
+
+test_expect_success 'pull renaming branch into unrenaming one' \
+'
+ git show-branch
+ git pull . white && {
+ echo "BAD: should have conflicted"
+ exit 1
+ }
+ git ls-files -s
+ test "$(git ls-files -u B | wc -l)" -eq 3 || {
+ echo "BAD: should have left stages for B"
+ exit 1
+ }
+ test "$(git ls-files -s N | wc -l)" -eq 1 || {
+ echo "BAD: should have merged N"
+ exit 1
+ }
+ sed -ne "/^g/{
+ p
+ q
+ }" B | grep master || {
+ echo "BAD: should have listed our change first"
+ exit 1
+ }
+ test "$(git diff white N | wc -l)" -eq 0 || {
+ echo "BAD: should have taken colored branch"
+ exit 1
+ }
+'
+
+test_expect_success 'pull renaming branch into another renaming one' \
+'
+ git reset --hard
+ git checkout red
+ git pull . white && {
+ echo "BAD: should have conflicted"
+ exit 1
+ }
+ test "$(git ls-files -u B | wc -l)" -eq 3 || {
+ echo "BAD: should have left stages"
+ exit 1
+ }
+ test "$(git ls-files -s N | wc -l)" -eq 1 || {
+ echo "BAD: should have merged N"
+ exit 1
+ }
+ sed -ne "/^g/{
+ p
+ q
+ }" B | grep red || {
+ echo "BAD: should have listed our change first"
+ exit 1
+ }
+ test "$(git diff white N | wc -l)" -eq 0 || {
+ echo "BAD: should have taken colored branch"
+ exit 1
+ }
+'
+
+test_expect_success 'pull unrenaming branch into renaming one' \
+'
+ git reset --hard
+ git show-branch
+ git pull . master && {
+ echo "BAD: should have conflicted"
+ exit 1
+ }
+ test "$(git ls-files -u B | wc -l)" -eq 3 || {
+ echo "BAD: should have left stages"
+ exit 1
+ }
+ test "$(git ls-files -s N | wc -l)" -eq 1 || {
+ echo "BAD: should have merged N"
+ exit 1
+ }
+ sed -ne "/^g/{
+ p
+ q
+ }" B | grep red || {
+ echo "BAD: should have listed our change first"
+ exit 1
+ }
+ test "$(git diff white N | wc -l)" -eq 0 || {
+ echo "BAD: should have taken colored branch"
+ exit 1
+ }
+'
+
+test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index f2eccd7918..2819bef1c4 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -149,7 +149,7 @@ test_expect_code () {
test_done () {
trap - exit
case "$test_failure" in
- 0)
+ 0)
# We could:
# cd .. && rm -fr trash
# but that means we forbid any tests that use their own
@@ -172,15 +172,30 @@ test_done () {
# t/ subdirectory and are run in trash subdirectory.
PATH=$(pwd)/..:$PATH
GIT_EXEC_PATH=$(pwd)/..
-export GIT_EXEC_PATH
+export PATH GIT_EXEC_PATH
+
+# Similarly use ../compat/subprocess.py if our python does not
+# have subprocess.py on its own.
+PYTHON=`sed -e '1{
+ s/^#!//
+ q
+}' ../git-merge-recursive` || {
+ error "You haven't built things yet, have you?"
+}
+"$PYTHON" -c 'import subprocess' 2>/dev/null || {
+ PYTHONPATH=$(pwd)/../compat
+ export PYTHONPATH
+}
+test -d ../templates/blt || {
+ error "You haven't built things yet, have you?"
+}
# Test repository
test=trash
rm -fr "$test"
mkdir "$test"
cd "$test"
-git-init-db --template=../../templates/blt/ 2>/dev/null ||
-error "cannot run git-init-db"
+"$GIT_EXEC_PATH/git" init-db --template=../../templates/blt/ 2>/dev/null ||
+error "cannot run git init-db -- have you built things yet?"
mv .git/hooks .git/hooks-disabled
-