aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/t1200-tutorial.sh2
-rwxr-xr-xt/t3200-branch.sh12
-rwxr-xr-xt/t3700-add.sh2
-rw-r--r--t/t4013/diff.diff-tree_--pretty_--root_--summary_initial2
-rwxr-xr-xt/t4015-diff-whitespace.sh122
-rwxr-xr-xt/t4118-apply-empty-context.sh55
-rwxr-xr-xt/t5000-tar-tree.sh35
-rwxr-xr-xt/t5600-clone-fail-cleanup.sh6
-rwxr-xr-xt/t6001-rev-list-graft.sh113
-rwxr-xr-xt/t7001-mv.sh19
-rwxr-xr-xt/t7201-co.sh9
-rwxr-xr-xt/test-lib.sh7
12 files changed, 380 insertions, 4 deletions
diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh
index c7db20e7f..0272dd429 100755
--- a/t/t1200-tutorial.sh
+++ b/t/t1200-tutorial.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2005 Johannes Schindelin
#
-test_description='Test git-rev-parse with different parent options'
+test_description='A simple turial in the form of a test case'
. ./test-lib.sh
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 5b04efc89..6907cbcd2 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -61,4 +61,16 @@ test_expect_success \
test -f .git/logs/refs/heads/g/h/i &&
diff expect .git/logs/refs/heads/g/h/i'
+test_expect_success \
+ 'git branch j/k should work after branch j has been deleted' \
+ 'git-branch j &&
+ git-branch -d j &&
+ git-branch j/k'
+
+test_expect_success \
+ 'git branch l should work after branch l/m has been deleted' \
+ 'git-branch l/m &&
+ git-branch -d l/m &&
+ git-branch l'
+
test_done
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index d36f22d7d..c20e4c29f 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -35,7 +35,7 @@ test_expect_success \
'git repo-config core.filemode 0 &&
echo foo >xfoo2 &&
chmod 755 xfoo2 &&
- git-add xfoo2 &&
+ git-update-index --add xfoo2 &&
case "`git-ls-files --stage xfoo2`" in
100644" "*xfoo2) echo ok;;
*) echo fail; git-ls-files --stage xfoo2; exit 1;;
diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial b/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial
index ea4820553..58e5f74ae 100644
--- a/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial
+++ b/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial
@@ -5,7 +5,7 @@ Date: Mon Jun 26 00:00:00 2006 +0000
Initial
- create mode 040000 dir
+ create mode 100644 dir/sub
create mode 100644 file0
create mode 100644 file2
$
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
new file mode 100755
index 000000000..1bc5b7a41
--- /dev/null
+++ b/t/t4015-diff-whitespace.sh
@@ -0,0 +1,122 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Johannes E. Schindelin
+#
+
+test_description='Test special whitespace in diff engine.
+
+'
+. ./test-lib.sh
+. ../diff-lib.sh
+
+# Ray Lehtiniemi's example
+
+cat << EOF > x
+do {
+ nothing;
+} while (0);
+EOF
+
+git-update-index --add x
+
+cat << EOF > x
+do
+{
+ nothing;
+}
+while (0);
+EOF
+
+cat << EOF > expect
+diff --git a/x b/x
+index adf3937..6edc172 100644
+--- a/x
++++ b/x
+@@ -1,3 +1,5 @@
+-do {
++do
++{
+ nothing;
+-} while (0);
++}
++while (0);
+EOF
+
+git-diff > out
+test_expect_success "Ray's example without options" 'diff -u expect out'
+
+git-diff -w > out
+test_expect_success "Ray's example with -w" 'diff -u expect out'
+
+git-diff -b > out
+test_expect_success "Ray's example with -b" 'diff -u expect out'
+
+tr 'Q' '\015' << EOF > x
+whitespace at beginning
+whitespace change
+whitespace in the middle
+whitespace at end
+unchanged line
+CR at endQ
+EOF
+
+git-update-index x
+
+cat << EOF > x
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end
+unchanged line
+CR at end
+EOF
+
+tr 'Q' '\015' << EOF > expect
+diff --git a/x b/x
+index d99af23..8b32fb5 100644
+--- a/x
++++ b/x
+@@ -1,6 +1,6 @@
+-whitespace at beginning
+-whitespace change
+-whitespace in the middle
+-whitespace at end
++ whitespace at beginning
++whitespace change
++white space in the middle
++whitespace at end
+ unchanged line
+-CR at endQ
++CR at end
+EOF
+git-diff > out
+test_expect_success 'another test, without options' 'diff -u expect out'
+
+cat << EOF > expect
+diff --git a/x b/x
+index d99af23..8b32fb5 100644
+EOF
+git-diff -w > out
+test_expect_success 'another test, with -w' 'diff -u expect out'
+
+tr 'Q' '\015' << EOF > expect
+diff --git a/x b/x
+index d99af23..8b32fb5 100644
+--- a/x
++++ b/x
+@@ -1,6 +1,6 @@
+-whitespace at beginning
++ whitespace at beginning
+ whitespace change
+-whitespace in the middle
+-whitespace at end
++white space in the middle
++whitespace at end
+ unchanged line
+-CR at endQ
++CR at end
+EOF
+git-diff -b > out
+test_expect_success 'another test, with -b' 'diff -u expect out'
+
+test_done
diff --git a/t/t4118-apply-empty-context.sh b/t/t4118-apply-empty-context.sh
new file mode 100755
index 000000000..7309422fe
--- /dev/null
+++ b/t/t4118-apply-empty-context.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Junio C Hamano
+#
+
+test_description='git-apply with new style GNU diff with empty context
+
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ {
+ echo; echo;
+ echo A; echo B; echo C;
+ echo;
+ } >file1 &&
+ cat file1 >file1.orig &&
+ {
+ cat file1 &&
+ echo Q | tr -d "\\012"
+ } >file2 &&
+ cat file2 >file2.orig
+ git add file1 file2 &&
+ sed -e "/^B/d" <file1.orig >file1 &&
+ sed -e "/^B/d" <file2.orig >file2 &&
+ cat file1 >file1.mods &&
+ cat file2 >file2.mods &&
+ git diff |
+ sed -e "s/^ \$//" >diff.output
+'
+
+test_expect_success 'apply --numstat' '
+
+ git apply --numstat diff.output >actual &&
+ {
+ echo "0 1 file1" &&
+ echo "0 1 file2"
+ } >expect &&
+ diff -u expect actual
+
+'
+
+test_expect_success 'apply --apply' '
+
+ cat file1.orig >file1 &&
+ cat file2.orig >file2 &&
+ git update-index file1 file2 &&
+ git apply --index diff.output &&
+ diff -u file1.mods file1 &&
+ diff -u file2.mods file2
+'
+
+test_done
+
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 278eb6670..cf08e9279 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -26,6 +26,7 @@ commit id embedding:
. ./test-lib.sh
TAR=${TAR:-tar}
+UNZIP=${UNZIP:-unzip}
test_expect_success \
'populate workdir' \
@@ -95,4 +96,38 @@ test_expect_success \
'validate file contents with prefix' \
'diff -r a c/prefix/a'
+test_expect_success \
+ 'git-archive --format=zip' \
+ 'git-archive --format=zip HEAD >d.zip'
+
+test_expect_success \
+ 'extract ZIP archive' \
+ '(mkdir d && cd d && $UNZIP ../d.zip)'
+
+test_expect_success \
+ 'validate filenames' \
+ '(cd d/a && find .) | sort >d.lst &&
+ diff a.lst d.lst'
+
+test_expect_success \
+ 'validate file contents' \
+ 'diff -r a d/a'
+
+test_expect_success \
+ 'git-archive --format=zip with prefix' \
+ 'git-archive --format=zip --prefix=prefix/ HEAD >e.zip'
+
+test_expect_success \
+ 'extract ZIP archive with prefix' \
+ '(mkdir e && cd e && $UNZIP ../e.zip)'
+
+test_expect_success \
+ 'validate filenames with prefix' \
+ '(cd e/prefix/a && find .) | sort >e.lst &&
+ diff a.lst e.lst'
+
+test_expect_success \
+ 'validate file contents with prefix' \
+ 'diff -r a e/prefix/a'
+
test_done
diff --git a/t/t5600-clone-fail-cleanup.sh b/t/t5600-clone-fail-cleanup.sh
index 0c6a363be..041be04f5 100755
--- a/t/t5600-clone-fail-cleanup.sh
+++ b/t/t5600-clone-fail-cleanup.sh
@@ -25,6 +25,12 @@ test_create_repo foo
# clone doesn't like it if there is no HEAD. Is that a bug?
(cd foo && touch file && git add file && git commit -m 'add file' >/dev/null 2>&1)
+# source repository given to git-clone should be relative to the
+# current path not to the target dir
+test_expect_failure \
+ 'clone of non-existent (relative to $PWD) source should fail' \
+ 'git-clone ../foo baz'
+
test_expect_success \
'clone should work now that source exists' \
'git-clone foo bar'
diff --git a/t/t6001-rev-list-graft.sh b/t/t6001-rev-list-graft.sh
new file mode 100755
index 000000000..b2131cdac
--- /dev/null
+++ b/t/t6001-rev-list-graft.sh
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+test_description='Revision traversal vs grafts and path limiter'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ mkdir subdir &&
+ echo >fileA fileA &&
+ echo >subdir/fileB fileB &&
+ git add fileA subdir/fileB &&
+ git commit -a -m "Initial in one history." &&
+ A0=`git rev-parse --verify HEAD` &&
+
+ echo >fileA fileA modified &&
+ git commit -a -m "Second in one history." &&
+ A1=`git rev-parse --verify HEAD` &&
+
+ echo >subdir/fileB fileB modified &&
+ git commit -a -m "Third in one history." &&
+ A2=`git rev-parse --verify HEAD` &&
+
+ rm -f .git/refs/heads/master .git/index &&
+
+ echo >fileA fileA again &&
+ echo >subdir/fileB fileB again &&
+ git add fileA subdir/fileB &&
+ git commit -a -m "Initial in alternate history." &&
+ B0=`git rev-parse --verify HEAD` &&
+
+ echo >fileA fileA modified in alternate history &&
+ git commit -a -m "Second in alternate history." &&
+ B1=`git rev-parse --verify HEAD` &&
+
+ echo >subdir/fileB fileB modified in alternate history &&
+ git commit -a -m "Third in alternate history." &&
+ B2=`git rev-parse --verify HEAD` &&
+ : done
+'
+
+check () {
+ type=$1
+ shift
+
+ arg=
+ which=arg
+ rm -f test.expect
+ for a
+ do
+ if test "z$a" = z--
+ then
+ which=expect
+ child=
+ continue
+ fi
+ if test "$which" = arg
+ then
+ arg="$arg$a "
+ continue
+ fi
+ if test "$type" = basic
+ then
+ echo "$a"
+ else
+ if test "z$child" != z
+ then
+ echo "$child $a"
+ fi
+ child="$a"
+ fi
+ done >test.expect
+ if test "$type" != basic && test "z$child" != z
+ then
+ echo >>test.expect $child
+ fi
+ if test $type = basic
+ then
+ git rev-list $arg >test.actual
+ elif test $type = parents
+ then
+ git rev-list --parents $arg >test.actual
+ elif test $type = parents-raw
+ then
+ git rev-list --parents --pretty=raw $arg |
+ sed -n -e 's/^commit //p' >test.actual
+ fi
+ diff test.expect test.actual
+}
+
+for type in basic parents parents-raw
+do
+ test_expect_success 'without grafts' "
+ rm -f .git/info/grafts
+ check $type $B2 -- $B2 $B1 $B0
+ "
+
+ test_expect_success 'with grafts' "
+ echo '$B0 $A2' >.git/info/grafts
+ check $type $B2 -- $B2 $B1 $B0 $A2 $A1 $A0
+ "
+
+ test_expect_success 'without grafts, with pathlimit' "
+ rm -f .git/info/grafts
+ check $type $B2 subdir -- $B2 $B0
+ "
+
+ test_expect_success 'with grafts, with pathlimit' "
+ echo '$B0 $A2' >.git/info/grafts
+ check $type $B2 subdir -- $B2 $B0 $A2 $A0
+ "
+
+done
+test_done
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index b7fcdb390..23a1eff3b 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -86,4 +86,23 @@ test_expect_success \
'move into "."' \
'git-mv path1/path2/ .'
+test_expect_success "Michael Cassar's test case" '
+ rm -fr .git papers partA &&
+ git init-db &&
+ mkdir -p papers/unsorted papers/all-papers partA &&
+ echo a > papers/unsorted/Thesis.pdf &&
+ echo b > partA/outline.txt &&
+ echo c > papers/unsorted/_another &&
+ git add papers partA &&
+ T1=`git write-tree` &&
+
+ git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf &&
+
+ T=`git write-tree` &&
+ git ls-tree -r $T | grep partA/outline.txt || {
+ git ls-tree -r $T
+ (exit 1)
+ }
+'
+
test_done
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index b64e8b7d7..085d4a096 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -31,6 +31,15 @@ test_expect_success setup '
git checkout master
'
+test_expect_success "checkout from non-existing branch" '
+
+ git checkout -b delete-me master &&
+ rm .git/refs/heads/delete-me &&
+ test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
+ git checkout master &&
+ test refs/heads/master = "$(git symbolic-ref HEAD)"
+'
+
test_expect_success "checkout with dirty tree without -m" '
fill 0 1 2 3 4 5 >one &&
diff --git a/t/test-lib.sh b/t/test-lib.sh
index e75ad5faa..2488e6eae 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -135,6 +135,7 @@ test_expect_failure () {
else
test_failure_ "$@"
fi
+ echo >&3 ""
}
test_expect_success () {
@@ -148,6 +149,7 @@ test_expect_success () {
else
test_failure_ "$@"
fi
+ echo >&3 ""
}
test_expect_code () {
@@ -161,6 +163,7 @@ test_expect_code () {
else
test_failure_ "$@"
fi
+ echo >&3 ""
}
# Most tests can use the created repository, but some amy need to create more.
@@ -211,13 +214,15 @@ export PATH GIT_EXEC_PATH
PYTHON=`sed -e '1{
s/^#!//
q
-}' ../git-merge-recursive` || {
+}' ../git-merge-recursive-old` || {
error "You haven't built things yet, have you?"
}
"$PYTHON" -c 'import subprocess' 2>/dev/null || {
PYTHONPATH=$(pwd)/../compat
export PYTHONPATH
}
+GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
+export GITPERLLIB
test -d ../templates/blt || {
error "You haven't built things yet, have you?"
}