summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <junkio@cox.net>2005-12-03 23:46:02 -0800
committerLibravatar Junio C Hamano <junkio@cox.net>2005-12-03 23:46:02 -0800
commit423325a2d24638ddcc82ce47be5e40be550f4507 (patch)
tree00960b001d786299d3da04a4467bd0c798bf8cda /t
parentGIT 0.99.9k (diff)
parent[PATCH] daemon.c and path.enter_repo(): revamp path validation. (diff)
downloadtgif-423325a2d24638ddcc82ce47be5e40be550f4507.tar.xz
GIT 0.99.9l aka 1.0rc4
Diffstat (limited to 't')
-rwxr-xr-xt/t0000-basic.sh5
-rwxr-xr-xt/t3100-ls-tree-restrict.sh53
-rw-r--r--t/t3101-ls-tree-dirname.sh38
-rwxr-xr-xt/t6020-merge-df.sh25
-rwxr-xr-xt/t6021-merge-criss-cross.sh92
-rwxr-xr-xt/t7001-mv.sh27
-rwxr-xr-xt/test-lib.sh13
7 files changed, 207 insertions, 46 deletions
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index dff7d69163..22bdacaf78 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -126,19 +126,18 @@ test_expect_success \
'git-ls-tree output for a known tree.' \
'diff current expected'
+# This changed in ls-tree pathspec change -- recursive does
+# not show tree nodes anymore.
test_expect_success \
'showing tree with git-ls-tree -r' \
'git-ls-tree -r $tree >current'
cat >expected <<\EOF
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
-040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2
100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
120000 blob d8ce161addc5173867a3c3c730924388daedbc38 path2/file2sym
-040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
100644 blob 0aa34cae68d0878578ad119c86ca2b5ed5b28376 path3/file3
120000 blob 8599103969b43aff7e430efea79ca4636466794f path3/file3sym
-040000 tree 3c5e5399f3a333eddecce7a9b9465b63f65f51e2 path3/subp3
100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3
120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
EOF
diff --git a/t/t3100-ls-tree-restrict.sh b/t/t3100-ls-tree-restrict.sh
index c6ce56c86b..2ec06d3d39 100755
--- a/t/t3100-ls-tree-restrict.sh
+++ b/t/t3100-ls-tree-restrict.sh
@@ -54,6 +54,18 @@ test_expect_success \
cat >expected <<\EOF &&
100644 blob X path0
120000 blob X path1
+100644 blob X path2/baz/b
+120000 blob X path2/bazbo
+100644 blob X path2/foo
+EOF
+ test_output'
+
+test_expect_success \
+ 'ls-tree recursive with -t' \
+ 'git-ls-tree -r -t $tree >current &&
+ cat >expected <<\EOF &&
+100644 blob X path0
+120000 blob X path1
040000 tree X path2
040000 tree X path2/baz
100644 blob X path2/baz/b
@@ -63,6 +75,15 @@ EOF
test_output'
test_expect_success \
+ 'ls-tree recursive with -d' \
+ 'git-ls-tree -r -d $tree >current &&
+ cat >expected <<\EOF &&
+040000 tree X path2
+040000 tree X path2/baz
+EOF
+ test_output'
+
+test_expect_success \
'ls-tree filtered with path' \
'git-ls-tree $tree path >current &&
cat >expected <<\EOF &&
@@ -70,12 +91,14 @@ EOF
test_output'
+# it used to be path1 and then path0, but with pathspec semantics
+# they are shown in canonical order.
test_expect_success \
'ls-tree filtered with path1 path0' \
'git-ls-tree $tree path1 path0 >current &&
cat >expected <<\EOF &&
-120000 blob X path1
100644 blob X path0
+120000 blob X path1
EOF
test_output'
@@ -86,45 +109,49 @@ test_expect_success \
EOF
test_output'
+# It used to show path2 and its immediate children but
+# with pathspec semantics it shows only path2
test_expect_success \
'ls-tree filtered with path2' \
'git-ls-tree $tree path2 >current &&
cat >expected <<\EOF &&
040000 tree X path2
+EOF
+ test_output'
+
+# ... and path2/ shows the children.
+test_expect_success \
+ 'ls-tree filtered with path2/' \
+ 'git-ls-tree $tree path2/ >current &&
+ cat >expected <<\EOF &&
040000 tree X path2/baz
120000 blob X path2/bazbo
100644 blob X path2/foo
EOF
test_output'
+# The same change -- exact match does not show children of
+# path2/baz
test_expect_success \
'ls-tree filtered with path2/baz' \
'git-ls-tree $tree path2/baz >current &&
cat >expected <<\EOF &&
040000 tree X path2/baz
-100644 blob X path2/baz/b
EOF
test_output'
test_expect_success \
- 'ls-tree filtered with path2' \
- 'git-ls-tree $tree path2 >current &&
+ 'ls-tree filtered with path2/bak' \
+ 'git-ls-tree $tree path2/bak >current &&
cat >expected <<\EOF &&
-040000 tree X path2
-040000 tree X path2/baz
-120000 blob X path2/bazbo
-100644 blob X path2/foo
EOF
test_output'
test_expect_success \
- 'ls-tree filtered with path2/' \
- 'git-ls-tree $tree path2/ >current &&
+ 'ls-tree -t filtered with path2/bak' \
+ 'git-ls-tree -t $tree path2/bak >current &&
cat >expected <<\EOF &&
040000 tree X path2
-040000 tree X path2/baz
-120000 blob X path2/bazbo
-100644 blob X path2/foo
EOF
test_output'
diff --git a/t/t3101-ls-tree-dirname.sh b/t/t3101-ls-tree-dirname.sh
index 5410368348..d78deb1e71 100644
--- a/t/t3101-ls-tree-dirname.sh
+++ b/t/t3101-ls-tree-dirname.sh
@@ -59,24 +59,16 @@ test_expect_success \
EOF
test_output'
+# Recursive does not show tree nodes anymore...
test_expect_success \
'ls-tree recursive' \
'git-ls-tree -r $tree >current &&
cat >expected <<\EOF &&
100644 blob X 1.txt
100644 blob X 2.txt
-040000 tree X path0
-040000 tree X path0/a
-040000 tree X path0/a/b
-040000 tree X path0/a/b/c
100644 blob X path0/a/b/c/1.txt
-040000 tree X path1
-040000 tree X path1/b
-040000 tree X path1/b/c
100644 blob X path1/b/c/1.txt
-040000 tree X path2
100644 blob X path2/1.txt
-040000 tree X path3
100644 blob X path3/1.txt
100644 blob X path3/2.txt
EOF
@@ -110,41 +102,27 @@ test_expect_success \
EOF
test_output'
+# I am not so sure about this one after ls-tree doing pathspec match.
+# Having both path0/a and path0/a/b/c makes path0/a redundant, and
+# it behaves as if path0/a/b/c, path1/b/c, path2 and path3 are specified.
test_expect_success \
'ls-tree filter directories' \
'git-ls-tree $tree path3 path2 path0/a/b/c path1/b/c path0/a >current &&
cat >expected <<\EOF &&
-040000 tree X path3
-100644 blob X path3/1.txt
-100644 blob X path3/2.txt
-040000 tree X path2
-100644 blob X path2/1.txt
040000 tree X path0/a/b/c
-100644 blob X path0/a/b/c/1.txt
040000 tree X path1/b/c
-100644 blob X path1/b/c/1.txt
-040000 tree X path0/a
-040000 tree X path0/a/b
+040000 tree X path2
+040000 tree X path3
EOF
test_output'
+# Again, duplicates are filtered away so this is equivalent to
+# having 1.txt and path3
test_expect_success \
'ls-tree filter odd names' \
'git-ls-tree $tree 1.txt /1.txt //1.txt path3/1.txt /path3/1.txt //path3//1.txt path3 /path3/ path3// >current &&
cat >expected <<\EOF &&
100644 blob X 1.txt
-100644 blob X 1.txt
-100644 blob X 1.txt
-100644 blob X path3/1.txt
-100644 blob X path3/1.txt
-100644 blob X path3/1.txt
-040000 tree X path3
-100644 blob X path3/1.txt
-100644 blob X path3/2.txt
-040000 tree X path3
-100644 blob X path3/1.txt
-100644 blob X path3/2.txt
-040000 tree X path3
100644 blob X path3/1.txt
100644 blob X path3/2.txt
EOF
diff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh
new file mode 100755
index 0000000000..a19d49de28
--- /dev/null
+++ b/t/t6020-merge-df.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Fredrik Kuivinen
+#
+
+test_description='Test merge with directory/file conflicts'
+. ./test-lib.sh
+
+test_expect_success 'prepare repository' \
+'echo "Hello" > init &&
+git add init &&
+git commit -m "Initial commit" &&
+git branch B &&
+mkdir dir &&
+echo "foo" > dir/foo &&
+git add dir/foo &&
+git commit -m "File: dir/foo" &&
+git checkout B &&
+echo "file dir" > dir &&
+git add dir &&
+git commit -m "File: dir"'
+
+test_expect_code 1 'Merge with d/f conflicts' 'git merge "merge msg" B master'
+
+test_done
diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh
new file mode 100755
index 0000000000..e8606c751d
--- /dev/null
+++ b/t/t6021-merge-criss-cross.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Fredrik Kuivinen
+#
+
+# See http://marc.theaimsgroup.com/?l=git&m=111463358500362&w=2 for a
+# nice decription of what this is about.
+
+
+test_description='Test criss-cross merge'
+. ./test-lib.sh
+
+test_expect_success 'prepare repository' \
+'echo "1
+2
+3
+4
+5
+6
+7
+8
+9" > file &&
+git add file &&
+git commit -m "Initial commit" file &&
+git branch A &&
+git branch B &&
+git checkout A &&
+echo "1
+2
+3
+4
+5
+6
+7
+8 changed in B8, branch A
+9" > file &&
+git commit -m "B8" file &&
+git checkout B &&
+echo "1
+2
+3 changed in C3, branch B
+4
+5
+6
+7
+8
+9
+" > file &&
+git commit -m "C3" file &&
+git branch C3 &&
+git merge "pre E3 merge" B A &&
+echo "1
+2
+3 changed in E3, branch B. New file size
+4
+5
+6
+7
+8 changed in B8, branch A
+9
+" > file &&
+git commit -m "E3" file &&
+git checkout A &&
+git merge "pre D8 merge" A C3 &&
+echo "1
+2
+3 changed in C3, branch B
+4
+5
+6
+7
+8 changed in D8, branch A. New file size 2
+9" > file &&
+git commit -m D8 file'
+
+test_expect_success 'Criss-cross merge' 'git merge "final merge" A B'
+
+cat > file-expect <<EOF
+1
+2
+3 changed in E3, branch B. New file size
+4
+5
+6
+7
+8 changed in D8, branch A. New file size 2
+9
+EOF
+
+test_expect_success 'Criss-cross merge result' 'cmp file file-expect'
+
+test_done
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
new file mode 100755
index 0000000000..43d74c502e
--- /dev/null
+++ b/t/t7001-mv.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+test_description='git-mv in subdirs'
+. ./test-lib.sh
+
+test_expect_success \
+ 'prepare reference tree' \
+ 'mkdir path0 path1 &&
+ cp ../../COPYING path0/COPYING &&
+ git-add path0/COPYING &&
+ git-commit -m add -a'
+
+test_expect_success \
+ 'moving the file' \
+ 'cd path0 && git-mv COPYING ../path1/COPYING'
+
+# in path0 currently
+test_expect_success \
+ 'commiting the change' \
+ 'cd .. && git-commit -m move -a'
+
+test_expect_success \
+ 'checking the commit' \
+ 'git-diff-tree -r -M --name-status HEAD^ HEAD | \
+ grep -E "^R100.+path0/COPYING.+path1/COPYING"'
+
+test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index e654155a2e..f2eccd7918 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -133,6 +133,19 @@ test_expect_success () {
fi
}
+test_expect_code () {
+ test "$#" = 3 ||
+ error "bug in the test script: not 3 parameters to test-expect-code"
+ say >&3 "expecting exit code $1: $3"
+ test_run_ "$3"
+ if [ "$?" = 0 -a "$eval_ret" = "$1" ]
+ then
+ test_ok_ "$2"
+ else
+ test_failure_ "$@"
+ fi
+}
+
test_done () {
trap - exit
case "$test_failure" in