summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/Makefile12
-rw-r--r--t/README4
-rw-r--r--t/annotate-tests.sh1
-rw-r--r--t/lib-git-svn.sh41
-rwxr-xr-xt/t0000-basic.sh55
-rwxr-xr-xt/t1004-read-tree-m-u-wf.sh119
-rwxr-xr-xt/t1200-tutorial.sh4
-rwxr-xr-xt/t1300-repo-config.sh85
-rwxr-xr-xt/t1400-update-ref.sh93
-rwxr-xr-xt/t1410-reflog.sh178
-rwxr-xr-xt/t3200-branch.sh70
-rwxr-xr-xt/t3210-pack-refs.sh99
-rwxr-xr-xt/t3401-rebase-partial.sh5
-rwxr-xr-xt/t3402-rebase-merge.sh6
-rwxr-xr-xt/t3403-rebase-skip.sh10
-rwxr-xr-xt/t3600-rm.sh78
-rwxr-xr-xt/t3700-add.sh65
-rwxr-xr-xt/t3900-i18n-commit.sh122
-rw-r--r--t/t3900/1-UTF-8.txt3
-rw-r--r--t/t3900/2-UTF-8.txt4
-rw-r--r--t/t3900/EUCJP.txt4
-rw-r--r--t/t3900/ISO-2022-JP.txt4
-rw-r--r--t/t3900/ISO-8859-1.txt3
-rwxr-xr-xt/t4013-diff-various.sh1
-rw-r--r--t/t4013/diff.diff-tree_--pretty_--root_--summary_initial2
-rwxr-xr-xt/t4015-diff-whitespace.sh120
-rwxr-xr-xt/t4103-apply-binary.sh4
-rwxr-xr-xt/t4104-apply-boundary.sh115
-rwxr-xr-xt/t4116-apply-reverse.sh47
-rwxr-xr-xt/t4117-apply-reject.sh157
-rwxr-xr-xt/t4118-apply-empty-context.sh55
-rwxr-xr-xt/t4200-rerere.sh154
-rwxr-xr-xt/t5000-tar-tree.sh35
-rwxr-xr-xt/t5300-pack-object.sh6
-rwxr-xr-xt/t5301-sliding-window.sh60
-rwxr-xr-xt/t5400-send-pack.sh67
-rwxr-xr-xt/t5401-update-hooks.sh81
-rwxr-xr-xt/t5500-fetch-pack.sh52
-rwxr-xr-xt/t5510-fetch.sh84
-rwxr-xr-xt/t5520-pull.sh33
-rwxr-xr-xt/t5600-clone-fail-cleanup.sh6
-rwxr-xr-xt/t5710-info-alternate.sh2
-rwxr-xr-xt/t6001-rev-list-graft.sh113
-rwxr-xr-xt/t6005-rev-list-count.sh51
-rwxr-xr-xt/t6021-merge-criss-cross.sh6
-rwxr-xr-xt/t6022-merge-rename.sh171
-rw-r--r--t/t6023-merge-file.sh138
-rwxr-xr-xt/t6023-merge-rename-nocruft.sh97
-rw-r--r--t/t6024-recursive-merge.sh84
-rwxr-xr-xt/t7001-mv.sh32
-rwxr-xr-xt/t7201-co.sh9
-rwxr-xr-xt/t9100-git-svn-basic.sh285
-rwxr-xr-xt/t9101-git-svn-props.sh13
-rwxr-xr-xt/t9102-git-svn-deep-rmdir.sh2
-rwxr-xr-xt/t9103-git-svn-graft-branches.sh16
-rwxr-xr-xt/t9104-git-svn-follow-parent.sh7
-rwxr-xr-xt/t9105-git-svn-commit-diff.sh9
-rwxr-xr-xt/t9106-git-svn-commit-diff-clobber.sh67
-rwxr-xr-xt/t9200-git-cvsexportcommit.sh215
-rwxr-xr-xt/test-lib.sh139
-rw-r--r--t/test9200a.pngbin0 -> 5660 bytes
-rw-r--r--t/test9200b.pngbin0 -> 275 bytes
62 files changed, 3191 insertions, 409 deletions
diff --git a/t/Makefile b/t/Makefile
index 89835093fb..19e38508a7 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -13,10 +13,6 @@ SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
TSVN = $(wildcard t91[0-9][0-9]-*.sh)
-ifdef NO_PYTHON
- GIT_TEST_OPTS += --no-python
-endif
-
all: $(T) clean
$(T):
@@ -27,12 +23,8 @@ clean:
# we can test NO_OPTIMIZE_COMMITS independently of LC_ALL
full-svn-test:
- $(MAKE) $(TSVN) GIT_SVN_NO_LIB=1 GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C
- $(MAKE) $(TSVN) GIT_SVN_NO_LIB=0 GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C
- $(MAKE) $(TSVN) GIT_SVN_NO_LIB=1 GIT_SVN_NO_OPTIMIZE_COMMITS=0 \
- LC_ALL=en_US.UTF-8
- $(MAKE) $(TSVN) GIT_SVN_NO_LIB=0 GIT_SVN_NO_OPTIMIZE_COMMITS=0 \
- LC_ALL=en_US.UTF-8
+ $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=1 LC_ALL=C
+ $(MAKE) $(TSVN) GIT_SVN_NO_OPTIMIZE_COMMITS=0 LC_ALL=en_US.UTF-8
.PHONY: $(T) clean
.NOTPARALLEL:
diff --git a/t/README b/t/README
index c5db5804df..36f2517617 100644
--- a/t/README
+++ b/t/README
@@ -18,7 +18,7 @@ The easiest way to run tests is to say "make". This runs all
the tests.
*** t0000-basic.sh ***
- * ok 1: .git/objects should be empty after git-init-db in an empty repo.
+ * ok 1: .git/objects should be empty after git-init in an empty repo.
* ok 2: .git/objects should have 256 subdirectories.
* ok 3: git-update-index without --add should fail adding.
...
@@ -74,6 +74,8 @@ First digit tells the family:
5 - the pull and exporting commands
6 - the revision tree commands (even e.g. merge-base)
7 - the porcelainish commands concerning the working tree
+ 8 - the porcelainish commands concerning forensics
+ 9 - the git tools
Second digit tells the particular command we are testing.
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 8baf2fef69..b5ceba4acf 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -4,6 +4,7 @@
check_count () {
head=
case "$1" in -h) head="$2"; shift; shift ;; esac
+ echo "$PROG file $head" >&4
$PROG file $head >.result || return 1
cat .result | perl -e '
my %expect = (@ARGV);
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 29a1e72c61..a0f2814083 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -11,21 +11,6 @@ GIT_DIR=$PWD/.git
GIT_SVN_DIR=$GIT_DIR/svn/git-svn
SVN_TREE=$GIT_SVN_DIR/svn-tree
-perl -e 'use SVN::Core' >/dev/null 2>&1
-if test $? -ne 0
-then
- echo 'Perl SVN libraries not found, tests requiring those will be skipped'
- GIT_SVN_NO_LIB=1
-fi
-
-svnadmin >/dev/null 2>&1
-if test $? -ne 1
-then
- test_expect_success 'skipping git-svn tests, svnadmin not found' :
- test_done
- exit
-fi
-
svn >/dev/null 2>&1
if test $? -ne 1
then
@@ -36,15 +21,27 @@ fi
svnrepo=$PWD/svnrepo
-set -e
-
-if svnadmin create --help | grep fs-type >/dev/null
+perl -w -e "
+use SVN::Core;
+use SVN::Repos;
+\$SVN::Core::VERSION gt '1.1.0' or exit(42);
+system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41);
+"
+x=$?
+if test $x -ne 0
then
- svnadmin create --fs-type fsfs "$svnrepo"
-else
- svnadmin create "$svnrepo"
+ if test $x -eq 42; then
+ err='Perl SVN libraries must be >= 1.1.0'
+ elif test $x -eq 41; then
+ err='svnadmin failed to create fsfs repository'
+ else
+ err='Perl SVN libraries not found or unusable, skipping test'
+ fi
+ test_expect_success "$err" :
+ test_done
+ exit
fi
-svnrepo="file://$svnrepo/test-git-svn"
+svnrepo="file://$svnrepo"
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 2c9bbb59b0..186de70243 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -19,11 +19,7 @@ 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.
+# It appears that people try to run tests without building...
../git >/dev/null
if test $? != 1
@@ -32,29 +28,15 @@ then
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
-test "$no_python" || "$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.
+# git-init has been done in an empty repository.
# make sure it is empty.
find .git/objects -type f -print >should-be-empty
test_expect_success \
- '.git/objects should be empty after git-init-db in an empty repo.' \
+ '.git/objects should be empty after git-init in an empty repo.' \
'cmp -s /dev/null should-be-empty'
# also it should have 2 subdirectories; no fan-out anymore, pack, and info.
@@ -209,6 +191,28 @@ test_expect_success \
'validate object ID for a known tree.' \
'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2'
+cat >badobjects <<EOF
+100644 blob 1000000000000000000000000000000000000000 dir/file1
+100644 blob 2000000000000000000000000000000000000000 dir/file2
+100644 blob 3000000000000000000000000000000000000000 dir/file3
+100644 blob 4000000000000000000000000000000000000000 dir/file4
+100644 blob 5000000000000000000000000000000000000000 dir/file5
+EOF
+
+rm .git/index
+test_expect_success \
+ 'put invalid objects into the index.' \
+ 'git-update-index --index-info < badobjects'
+
+test_expect_failure \
+ 'writing this tree without --missing-ok.' \
+ 'git-write-tree'
+
+test_expect_success \
+ 'writing this tree with --missing-ok.' \
+ 'git-write-tree --missing-ok'
+
+
################################################################
rm .git/index
test_expect_success \
@@ -268,4 +272,13 @@ test_expect_success \
wc -l) &&
test $numparent = 1'
+test_expect_success 'update-index D/F conflict' '
+ mv path0 tmp &&
+ mv path2 path0 &&
+ mv tmp path2 &&
+ git update-index --add --replace path2 path0/file2 &&
+ numpath0=$(git ls-files path0 | wc -l) &&
+ test $numpath0 = 1
+'
+
test_done
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
new file mode 100755
index 0000000000..4f664f6adf
--- /dev/null
+++ b/t/t1004-read-tree-m-u-wf.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+test_description='read-tree -m -u checks working tree files'
+
+. ./test-lib.sh
+
+# two-tree test
+
+test_expect_success 'two-way setup' '
+
+ mkdir subdir &&
+ echo >file1 file one &&
+ echo >file2 file two &&
+ echo >subdir/file1 file one in subdirectory &&
+ echo >subdir/file2 file two in subdirectory &&
+ git update-index --add file1 file2 subdir/file1 subdir/file2 &&
+ git commit -m initial &&
+
+ git branch side &&
+ git tag -f branch-point &&
+
+ echo file2 is not tracked on the master anymore &&
+ rm -f file2 subdir/file2 &&
+ git update-index --remove file2 subdir/file2 &&
+ git commit -a -m "master removes file2 and subdir/file2"
+'
+
+test_expect_success 'two-way not clobbering' '
+
+ echo >file2 master creates untracked file2 &&
+ echo >subdir/file2 master creates untracked subdir/file2 &&
+ if err=`git read-tree -m -u master side 2>&1`
+ then
+ echo should have complained
+ false
+ else
+ echo "happy to see $err"
+ fi
+'
+
+echo file2 >.gitignore
+
+test_expect_success 'two-way with incorrect --exclude-per-directory (1)' '
+
+ if err=`git read-tree -m --exclude-per-directory=.gitignore master side 2>&1`
+ then
+ echo should have complained
+ false
+ else
+ echo "happy to see $err"
+ fi
+'
+
+test_expect_success 'two-way with incorrect --exclude-per-directory (2)' '
+
+ if err=`git read-tree -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore master side 2>&1`
+ then
+ echo should have complained
+ false
+ else
+ echo "happy to see $err"
+ fi
+'
+
+test_expect_success 'two-way clobbering a ignored file' '
+
+ git read-tree -m -u --exclude-per-directory=.gitignore master side
+'
+
+rm -f .gitignore
+
+# three-tree test
+
+test_expect_success 'three-way not complaining on an untracked path in both' '
+
+ rm -f file2 subdir/file2 &&
+ git checkout side &&
+ echo >file3 file three &&
+ echo >subdir/file3 file three &&
+ git update-index --add file3 subdir/file3 &&
+ git commit -a -m "side adds file3 and removes file2" &&
+
+ git checkout master &&
+ echo >file2 file two is untracked on the master side &&
+ echo >subdir/file2 file two is untracked on the master side &&
+
+ git-read-tree -m -u branch-point master side
+'
+
+test_expect_success 'three-way not cloberring a working tree file' '
+
+ git reset --hard &&
+ rm -f file2 subdir/file2 file3 subdir/file3 &&
+ git checkout master &&
+ echo >file3 file three created in master, untracked &&
+ echo >subdir/file3 file three created in master, untracked &&
+ if err=`git read-tree -m -u branch-point master side 2>&1`
+ then
+ echo should have complained
+ false
+ else
+ echo "happy to see $err"
+ fi
+'
+
+echo >.gitignore file3
+
+test_expect_success 'three-way not complaining on an untracked file' '
+
+ git reset --hard &&
+ rm -f file2 subdir/file2 file3 subdir/file3 &&
+ git checkout master &&
+ echo >file3 file three created in master, untracked &&
+ echo >subdir/file3 file three created in master, untracked &&
+
+ git read-tree -m -u --exclude-per-directory=.gitignore branch-point master side
+'
+
+test_done
diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh
index c7db20e7f3..eebe643bda 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
@@ -37,8 +37,6 @@ test_expect_success 'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tre
output="$(echo "Initial commit" | git-commit-tree $(git-write-tree) 2>&1 > .git/refs/heads/master)"
-test_expect_success 'commit' "test 'Committing initial tree 8988da15d077d4829fc51d8544c097def6644dbb' = \"$output\""
-
git-diff-index -p HEAD > diff.output
test_expect_success 'git-diff-index -p HEAD' 'cmp diff.expect diff.output'
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 0de2497746..60acdd368b 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -265,6 +265,16 @@ EOF
test_expect_success '--get-regexp' \
'git-repo-config --get-regexp in > output && cmp output expect'
+git-repo-config --add nextsection.nonewline "wow4 for you"
+
+cat > expect << EOF
+wow2 for me
+wow4 for you
+EOF
+
+test_expect_success '--add' \
+ 'git-repo-config --get-all nextsection.nonewline > output && cmp output expect'
+
cat > .git/config << EOF
[novalue]
variable
@@ -333,5 +343,80 @@ EOF
test_expect_success '--set in alternative GIT_CONFIG' 'cmp other-config expect'
+cat > .git/config << EOF
+# Hallo
+ #Bello
+[branch "eins"]
+ x = 1
+[branch.eins]
+ y = 1
+ [branch "1 234 blabl/a"]
+weird
+EOF
+
+test_expect_success "rename section" \
+ "git-repo-config --rename-section branch.eins branch.zwei"
+
+cat > expect << EOF
+# Hallo
+ #Bello
+[branch "zwei"]
+ x = 1
+[branch "zwei"]
+ y = 1
+ [branch "1 234 blabl/a"]
+weird
+EOF
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
+test_expect_failure "rename non-existing section" \
+ 'git-repo-config --rename-section branch."world domination" branch.drei'
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
+test_expect_success "rename another section" \
+ 'git-repo-config --rename-section branch."1 234 blabl/a" branch.drei'
+
+cat > expect << EOF
+# Hallo
+ #Bello
+[branch "zwei"]
+ x = 1
+[branch "zwei"]
+ y = 1
+[branch "drei"]
+weird
+EOF
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
+test_expect_success numbers '
+
+ git-repo-config kilo.gram 1k &&
+ git-repo-config mega.ton 1m &&
+ k=$(git-repo-config --int --get kilo.gram) &&
+ test z1024 = "z$k" &&
+ m=$(git-repo-config --int --get mega.ton) &&
+ test z1048576 = "z$m"
+'
+
+rm .git/config
+
+git-repo-config quote.leading " test"
+git-repo-config quote.ending "test "
+git-repo-config quote.semicolon "test;test"
+git-repo-config quote.hash "test#test"
+
+cat > expect << EOF
+[quote]
+ leading = " test"
+ ending = "test "
+ semicolon = "test;test"
+ hash = "test#test"
+EOF
+
+test_expect_success 'quoting' 'cmp .git/config expect'
+
test_done
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index ddc80bbeae..5637cb5eac 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -19,70 +19,67 @@ n=$n_dir/fixes
test_expect_success \
"create $m" \
- 'git-update-ref $m $A &&
- test $A = $(cat .git/$m)'
+ "git-update-ref $m $A &&
+ test $A"' = $(cat .git/'"$m"')'
test_expect_success \
"create $m" \
- 'git-update-ref $m $B $A &&
- test $B = $(cat .git/$m)'
+ "git-update-ref $m $B $A &&
+ test $B"' = $(cat .git/'"$m"')'
rm -f .git/$m
test_expect_success \
"fail to create $n" \
- 'touch .git/$n_dir
- git-update-ref $n $A >out 2>err
- test $? = 1 &&
- test "" = "$(cat out)" &&
- grep "error: unable to resolve reference" err &&
- grep $n err'
+ "touch .git/$n_dir
+ git-update-ref $n $A >out 2>err"'
+ test $? != 0'
rm -f .git/$n_dir out err
test_expect_success \
"create $m (by HEAD)" \
- 'git-update-ref HEAD $A &&
- test $A = $(cat .git/$m)'
+ "git-update-ref HEAD $A &&
+ test $A"' = $(cat .git/'"$m"')'
test_expect_success \
"create $m (by HEAD)" \
- 'git-update-ref HEAD $B $A &&
- test $B = $(cat .git/$m)'
+ "git-update-ref HEAD $B $A &&
+ test $B"' = $(cat .git/'"$m"')'
rm -f .git/$m
test_expect_failure \
'(not) create HEAD with old sha1' \
- 'git-update-ref HEAD $A $B'
+ "git-update-ref HEAD $A $B"
test_expect_failure \
"(not) prior created .git/$m" \
- 'test -f .git/$m'
+ "test -f .git/$m"
rm -f .git/$m
test_expect_success \
"create HEAD" \
- 'git-update-ref HEAD $A'
+ "git-update-ref HEAD $A"
test_expect_failure \
'(not) change HEAD with wrong SHA1' \
- 'git-update-ref HEAD $B $Z'
+ "git-update-ref HEAD $B $Z"
test_expect_failure \
"(not) changed .git/$m" \
- 'test $B = $(cat .git/$m)'
+ "test $B"' = $(cat .git/'"$m"')'
rm -f .git/$m
-mkdir -p .git/logs/refs/heads
-touch .git/logs/refs/heads/master
+: a repository with working tree always has reflog these days...
+: >.git/logs/refs/heads/master
test_expect_success \
"create $m (logged by touch)" \
'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git-update-ref HEAD $A -m "Initial Creation" &&
- test $A = $(cat .git/$m)'
+ git-update-ref HEAD '"$A"' -m "Initial Creation" &&
+ test '"$A"' = $(cat .git/'"$m"')'
test_expect_success \
"update $m (logged by touch)" \
'GIT_COMMITTER_DATE="2005-05-26 23:31" \
- git-update-ref HEAD $B $A -m "Switch" &&
- test $B = $(cat .git/$m)'
+ git-update-ref HEAD'" $B $A "'-m "Switch" &&
+ test '"$B"' = $(cat .git/'"$m"')'
test_expect_success \
"set $m (logged by touch)" \
'GIT_COMMITTER_DATE="2005-05-26 23:41" \
- git-update-ref HEAD $A &&
- test $A = $(cat .git/$m)'
+ git-update-ref HEAD'" $A &&
+ test $A"' = $(cat .git/'"$m"')'
cat >expect <<EOF
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation
@@ -91,7 +88,7 @@ $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000
EOF
test_expect_success \
"verifying $m's log" \
- 'diff expect .git/logs/$m'
+ "diff expect .git/logs/$m"
rm -rf .git/$m .git/logs expect
test_expect_success \
@@ -102,18 +99,18 @@ test_expect_success \
test_expect_success \
"create $m (logged by config)" \
'GIT_COMMITTER_DATE="2005-05-26 23:32" \
- git-update-ref HEAD $A -m "Initial Creation" &&
- test $A = $(cat .git/$m)'
+ git-update-ref HEAD'" $A "'-m "Initial Creation" &&
+ test '"$A"' = $(cat .git/'"$m"')'
test_expect_success \
"update $m (logged by config)" \
'GIT_COMMITTER_DATE="2005-05-26 23:33" \
- git-update-ref HEAD $B $A -m "Switch" &&
- test $B = $(cat .git/$m)'
+ git-update-ref HEAD'" $B $A "'-m "Switch" &&
+ test '"$B"' = $(cat .git/'"$m"')'
test_expect_success \
"set $m (logged by config)" \
'GIT_COMMITTER_DATE="2005-05-26 23:43" \
- git-update-ref HEAD $A &&
- test $A = $(cat .git/$m)'
+ git-update-ref HEAD '"$A &&
+ test $A"' = $(cat .git/'"$m"')'
cat >expect <<EOF
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 +0000 Initial Creation
@@ -140,50 +137,50 @@ test_expect_success \
'Query "master@{May 25 2005}" (before history)' \
'rm -f o e
git-rev-parse --verify "master@{May 25 2005}" >o 2>e &&
- test $C = $(cat o) &&
- test "warning: Log .git/logs/$m only goes back to $ed." = "$(cat e)"'
+ test '"$C"' = $(cat o) &&
+ test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"'
test_expect_success \
"Query master@{2005-05-25} (before history)" \
'rm -f o e
git-rev-parse --verify master@{2005-05-25} >o 2>e &&
- test $C = $(cat o) &&
- echo test "warning: Log .git/logs/$m only goes back to $ed." = "$(cat e)"'
+ test '"$C"' = $(cat o) &&
+ echo test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"'
test_expect_success \
'Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
'rm -f o e
git-rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
- test $C = $(cat o) &&
- test "warning: Log .git/logs/$m only goes back to $ed." = "$(cat e)"'
+ test '"$C"' = $(cat o) &&
+ test "warning: Log .git/logs/'"$m only goes back to $ed"'." = "$(cat e)"'
test_expect_success \
'Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
'rm -f o e
git-rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
- test $A = $(cat o) &&
+ test '"$A"' = $(cat o) &&
test "" = "$(cat e)"'
test_expect_success \
'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
'rm -f o e
git-rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
- test $B = $(cat o) &&
- test "warning: Log .git/logs/$m has gap after $gd." = "$(cat e)"'
+ test '"$B"' = $(cat o) &&
+ test "warning: Log .git/logs/'"$m has gap after $gd"'." = "$(cat e)"'
test_expect_success \
'Query "master@{2005-05-26 23:38:00}" (middle of history)' \
'rm -f o e
git-rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
- test $Z = $(cat o) &&
+ test '"$Z"' = $(cat o) &&
test "" = "$(cat e)"'
test_expect_success \
'Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
'rm -f o e
git-rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
- test $E = $(cat o) &&
+ test '"$E"' = $(cat o) &&
test "" = "$(cat e)"'
test_expect_success \
'Query "master@{2005-05-28}" (past end of history)' \
'rm -f o e
git-rev-parse --verify "master@{2005-05-28}" >o 2>e &&
- test $D = $(cat o) &&
- test "warning: Log .git/logs/$m unexpectedly ended on $ld." = "$(cat e)"'
+ test '"$D"' = $(cat o) &&
+ test "warning: Log .git/logs/'"$m unexpectedly ended on $ld"'." = "$(cat e)"'
rm -f .git/$m .git/logs/$m expect
@@ -221,7 +218,7 @@ $h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 c
EOF
test_expect_success \
'git-commit logged updates' \
- 'diff expect .git/logs/$m'
+ "diff expect .git/logs/$m"
unset h_TEST h_OTHER h_FIXED h_MERGED
test_expect_success \
diff --git a/t/t1410-reflog.sh b/t/t1410-reflog.sh
new file mode 100755
index 0000000000..8e8d526ef2
--- /dev/null
+++ b/t/t1410-reflog.sh
@@ -0,0 +1,178 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Junio C Hamano
+#
+
+test_description='Test prune and reflog expiration'
+. ./test-lib.sh
+
+check_have () {
+ gaah= &&
+ for N in "$@"
+ do
+ eval "o=\$$N" && git cat-file -t $o || {
+ echo Gaah $N
+ gaah=$N
+ break
+ }
+ done &&
+ test -z "$gaah"
+}
+
+check_fsck () {
+ output=$(git fsck-objects --full)
+ case "$1" in
+ '')
+ test -z "$output" ;;
+ *)
+ echo "$output" | grep "$1" ;;
+ esac
+}
+
+corrupt () {
+ aa=${1%??????????????????????????????????????} zz=${1#??}
+ mv .git/objects/$aa/$zz .git/$aa$zz
+}
+
+recover () {
+ aa=${1%??????????????????????????????????????} zz=${1#??}
+ mkdir -p .git/objects/$aa
+ mv .git/$aa$zz .git/objects/$aa/$zz
+}
+
+check_dont_have () {
+ gaah= &&
+ for N in "$@"
+ do
+ eval "o=\$$N"
+ git cat-file -t $o && {
+ echo Gaah $N
+ gaah=$N
+ break
+ }
+ done
+ test -z "$gaah"
+}
+
+test_expect_success setup '
+ mkdir -p A/B &&
+ echo rat >C &&
+ echo ox >A/D &&
+ echo tiger >A/B/E &&
+ git add . &&
+
+ test_tick && git commit -m rabbit &&
+ H=`git rev-parse --verify HEAD` &&
+ A=`git rev-parse --verify HEAD:A` &&
+ B=`git rev-parse --verify HEAD:A/B` &&
+ C=`git rev-parse --verify HEAD:C` &&
+ D=`git rev-parse --verify HEAD:A/D` &&
+ E=`git rev-parse --verify HEAD:A/B/E` &&
+ check_fsck &&
+
+ chmod +x C &&
+ ( test "`git repo-config --bool core.filemode`" != false ||
+ echo executable >>C ) &&
+ git add C &&
+ test_tick && git commit -m dragon &&
+ L=`git rev-parse --verify HEAD` &&
+ check_fsck &&
+
+ rm -f C A/B/E &&
+ echo snake >F &&
+ echo horse >A/G &&
+ git add F A/G &&
+ test_tick && git commit -a -m sheep &&
+ F=`git rev-parse --verify HEAD:F` &&
+ G=`git rev-parse --verify HEAD:A/G` &&
+ I=`git rev-parse --verify HEAD:A` &&
+ J=`git rev-parse --verify HEAD` &&
+ check_fsck &&
+
+ rm -f A/G &&
+ test_tick && git commit -a -m monkey &&
+ K=`git rev-parse --verify HEAD` &&
+ check_fsck &&
+
+ check_have A B C D E F G H I J K L &&
+
+ git prune &&
+
+ check_have A B C D E F G H I J K L &&
+
+ check_fsck &&
+
+ loglen=$(wc -l <.git/logs/refs/heads/master) &&
+ test $loglen = 4
+'
+
+test_expect_success rewind '
+ test_tick && git reset --hard HEAD~2 &&
+ test -f C &&
+ test -f A/B/E &&
+ ! test -f F &&
+ ! test -f A/G &&
+
+ check_have A B C D E F G H I J K L &&
+
+ git prune &&
+
+ check_have A B C D E F G H I J K L &&
+
+ loglen=$(wc -l <.git/logs/refs/heads/master) &&
+ test $loglen = 5
+'
+
+test_expect_success 'corrupt and check' '
+
+ corrupt $F &&
+ check_fsck "missing blob $F"
+
+'
+
+test_expect_success 'reflog expire --dry-run should not touch reflog' '
+
+ git reflog expire --dry-run \
+ --expire=$(($test_tick - 10000)) \
+ --expire-unreachable=$(($test_tick - 10000)) \
+ --stale-fix \
+ --all &&
+
+ loglen=$(wc -l <.git/logs/refs/heads/master) &&
+ test $loglen = 5 &&
+
+ check_fsck "missing blob $F"
+'
+
+test_expect_success 'reflog expire' '
+
+ git reflog expire --verbose \
+ --expire=$(($test_tick - 10000)) \
+ --expire-unreachable=$(($test_tick - 10000)) \
+ --stale-fix \
+ --all &&
+
+ loglen=$(wc -l <.git/logs/refs/heads/master) &&
+ test $loglen = 2 &&
+
+ check_fsck "dangling commit $K"
+'
+
+test_expect_success 'prune and fsck' '
+
+ git prune &&
+ check_fsck &&
+
+ check_have A B C D E H L &&
+ check_dont_have F G I J K
+
+'
+
+test_expect_success 'recover and check' '
+
+ recover $F &&
+ check_fsck "dangling blob $F"
+
+'
+
+test_done
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 5b04efc89d..bb80e4286a 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -17,13 +17,10 @@ test_expect_success \
git-commit -m "Initial commit." &&
HEAD=$(git-rev-parse --verify HEAD)'
-test_expect_success \
- 'git branch --help should return success now.' \
- 'git-branch --help'
-
test_expect_failure \
'git branch --help should not have created a bogus branch' \
- 'test -f .git/refs/heads/--help'
+ 'git-branch --help </dev/null >/dev/null 2>/dev/null || :
+ test -f .git/refs/heads/--help'
test_expect_success \
'git branch abc should create a branch' \
@@ -34,7 +31,7 @@ test_expect_success \
'git-branch a/b/c && test -f .git/refs/heads/a/b/c'
cat >expect <<EOF
-0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from HEAD
+0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
EOF
test_expect_success \
'git branch -l d/e/f should create a branch and a log' \
@@ -51,7 +48,7 @@ test_expect_success \
test ! -f .git/logs/refs/heads/d/e/f'
cat >expect <<EOF
-0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 checkout: Created from master^0
+0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 checkout: Created from master
EOF
test_expect_success \
'git checkout -b g/h/i -l should create a branch and a log' \
@@ -61,4 +58,63 @@ 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_expect_success \
+ 'git branch -m m m/m should work' \
+ 'git-branch -l m &&
+ git-branch -m m m/m &&
+ test -f .git/logs/refs/heads/m/m'
+
+test_expect_success \
+ 'git branch -m n/n n should work' \
+ 'git-branch -l n/n &&
+ git-branch -m n/n n
+ test -f .git/logs/refs/heads/n'
+
+test_expect_failure \
+ 'git branch -m o/o o should fail when o/p exists' \
+ 'git-branch o/o &&
+ git-branch o/p &&
+ git-branch -m o/o o'
+
+test_expect_failure \
+ 'git branch -m q r/q should fail when r exists' \
+ 'git-branch q &&
+ git-branch r &&
+ git-branch -m q r/q'
+
+git-repo-config branch.s/s.dummy Hello
+
+test_expect_success \
+ 'git branch -m s/s s should work when s/t is deleted' \
+ 'git-branch -l s/s &&
+ test -f .git/logs/refs/heads/s/s &&
+ git-branch -l s/t &&
+ test -f .git/logs/refs/heads/s/t &&
+ git-branch -d s/t &&
+ git-branch -m s/s s &&
+ test -f .git/logs/refs/heads/s'
+
+test_expect_success 'config information was renamed, too' \
+ "test $(git-repo-config branch.s.dummy) = Hello &&
+ ! git-repo-config branch.s/s/dummy"
+
+test_expect_failure \
+ 'git-branch -m u v should fail when the reflog for u is a symlink' \
+ 'git-branch -l u &&
+ mv .git/logs/refs/heads/u real-u &&
+ ln -s real-u .git/logs/refs/heads/u &&
+ git-branch -m u v'
+
test_done
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
new file mode 100755
index 0000000000..16bdae4f23
--- /dev/null
+++ b/t/t3210-pack-refs.sh
@@ -0,0 +1,99 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Amos Waterland
+# Copyright (c) 2006 Christian Couder
+#
+
+test_description='git pack-refs should not change the branch semantic
+
+This test runs git pack-refs and git show-ref and checks that the branch
+semantic is still the same.
+'
+. ./test-lib.sh
+
+echo '[core] logallrefupdates = true' >>.git/config
+
+test_expect_success \
+ 'prepare a trivial repository' \
+ 'echo Hello > A &&
+ git-update-index --add A &&
+ git-commit -m "Initial commit." &&
+ HEAD=$(git-rev-parse --verify HEAD)'
+
+SHA1=
+
+test_expect_success \
+ 'see if git show-ref works as expected' \
+ 'git-branch a &&
+ SHA1=`cat .git/refs/heads/a` &&
+ echo "$SHA1 refs/heads/a" >expect &&
+ git-show-ref a >result &&
+ diff expect result'
+
+test_expect_success \
+ 'see if a branch still exists when packed' \
+ 'git-branch b &&
+ git-pack-refs --all &&
+ rm -f .git/refs/heads/b &&
+ echo "$SHA1 refs/heads/b" >expect &&
+ git-show-ref b >result &&
+ diff expect result'
+
+test_expect_failure \
+ 'git branch c/d should barf if branch c exists' \
+ 'git-branch c &&
+ git-pack-refs --all &&
+ rm .git/refs/heads/c &&
+ git-branch c/d'
+
+test_expect_success \
+ 'see if a branch still exists after git pack-refs --prune' \
+ 'git-branch e &&
+ git-pack-refs --all --prune &&
+ echo "$SHA1 refs/heads/e" >expect &&
+ git-show-ref e >result &&
+ diff expect result'
+
+test_expect_failure \
+ 'see if git pack-refs --prune remove ref files' \
+ 'git-branch f &&
+ git-pack-refs --all --prune &&
+ ls .git/refs/heads/f'
+
+test_expect_success \
+ 'git branch g should work when git branch g/h has been deleted' \
+ 'git-branch g/h &&
+ git-pack-refs --all --prune &&
+ git-branch -d g/h &&
+ git-branch g &&
+ git-pack-refs --all &&
+ git-branch -d g'
+
+test_expect_failure \
+ 'git branch i/j/k should barf if branch i exists' \
+ 'git-branch i &&
+ git-pack-refs --all --prune &&
+ git-branch i/j/k'
+
+test_expect_success \
+ 'test git branch k after branch k/l/m and k/lm have been deleted' \
+ 'git-branch k/l &&
+ git-branch k/lm &&
+ git-branch -d k/l &&
+ git-branch k/l/m &&
+ git-branch -d k/l/m &&
+ git-branch -d k/lm &&
+ git-branch k'
+
+test_expect_success \
+ 'test git branch n after some branch deletion and pruning' \
+ 'git-branch n/o &&
+ git-branch n/op &&
+ git-branch -d n/o &&
+ git-branch n/o/p &&
+ git-branch -d n/op &&
+ git-pack-refs --all --prune &&
+ git-branch -d n/o/p &&
+ git-branch n'
+
+test_done
diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh
index 360a67060e..8b19d3ccea 100755
--- a/t/t3401-rebase-partial.sh
+++ b/t/t3401-rebase-partial.sh
@@ -52,13 +52,10 @@ test_expect_success \
'rebase topic branch against new master and check git-am did not get halted' \
'git-rebase master && test ! -d .dotest'
-if test -z "$no_python"
-then
- test_expect_success \
+test_expect_success \
'rebase --merge topic branch that was partially merged upstream' \
'git-checkout -f my-topic-branch-merge &&
git-rebase --merge master-merge &&
test ! -d .git/.dotest-merge'
-fi
test_done
diff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh
index d34c6cf6f3..0779aaa9ab 100755
--- a/t/t3402-rebase-merge.sh
+++ b/t/t3402-rebase-merge.sh
@@ -7,12 +7,6 @@ test_description='git rebase --merge test'
. ./test-lib.sh
-if test "$no_python"; then
- echo "Skipping: no python => no recursive merge"
- test_done
- exit 0
-fi
-
T="A quick brown fox
jumps over the lazy dog."
for i in 1 2 3 4 5 6 7 8 9 10
diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh
index 8ab63c5276..977c498f00 100755
--- a/t/t3403-rebase-skip.sh
+++ b/t/t3403-rebase-skip.sh
@@ -10,12 +10,6 @@ test_description='git rebase --merge --skip tests'
# we assume the default git-am -3 --skip strategy is tested independently
# and always works :)
-if test "$no_python"; then
- echo "Skipping: no python => no recursive merge"
- test_done
- exit 0
-fi
-
test_expect_success setup '
echo hello > hello &&
git add hello &&
@@ -37,7 +31,9 @@ test_expect_success setup '
git branch skip-merge skip-reference
'
-test_expect_failure 'rebase with git am -3 (default)' 'git rebase master'
+test_expect_failure 'rebase with git am -3 (default)' '
+ git rebase master
+'
test_expect_success 'rebase --skip with am -3' '
git reset --hard HEAD &&
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 201d1642da..e31cf93a00 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -43,19 +43,19 @@ test_expect_success \
test_expect_success \
'Test that git-rm foo succeeds' \
- 'git-rm foo'
+ 'git-rm --cached foo'
test_expect_success \
'Post-check that foo exists but is not in index after git-rm foo' \
'[ -f foo ] && ! git-ls-files --error-unmatch foo'
test_expect_success \
- 'Pre-check that bar exists and is in index before "git-rm -f bar"' \
+ 'Pre-check that bar exists and is in index before "git-rm bar"' \
'[ -f bar ] && git-ls-files --error-unmatch bar'
test_expect_success \
- 'Test that "git-rm -f bar" succeeds' \
- 'git-rm -f bar'
+ 'Test that "git-rm bar" succeeds' \
+ 'git-rm bar'
test_expect_success \
'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \
@@ -84,4 +84,74 @@ test_expect_success \
'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
'git-ls-files --error-unmatch baz'
+# Now, failure cases.
+test_expect_success 'Re-add foo and baz' '
+ git add foo baz &&
+ git ls-files --error-unmatch foo baz
+'
+
+test_expect_success 'Modify foo -- rm should refuse' '
+ echo >>foo &&
+ ! git rm foo baz &&
+ test -f foo &&
+ test -f baz &&
+ git ls-files --error-unmatch foo baz
+'
+
+test_expect_success 'Modified foo -- rm -f should work' '
+ git rm -f foo baz &&
+ test ! -f foo &&
+ test ! -f baz &&
+ ! git ls-files --error-unmatch foo &&
+ ! git ls-files --error-unmatch bar
+'
+
+test_expect_success 'Re-add foo and baz for HEAD tests' '
+ echo frotz >foo &&
+ git checkout HEAD -- baz &&
+ git add foo baz &&
+ git ls-files --error-unmatch foo baz
+'
+
+test_expect_success 'foo is different in index from HEAD -- rm should refuse' '
+ ! git rm foo baz &&
+ test -f foo &&
+ test -f baz &&
+ git ls-files --error-unmatch foo baz
+'
+
+test_expect_success 'but with -f it should work.' '
+ git rm -f foo baz &&
+ test ! -f foo &&
+ test ! -f baz &&
+ ! git ls-files --error-unmatch foo
+ ! git ls-files --error-unmatch baz
+'
+
+test_expect_success 'Recursive test setup' '
+ mkdir -p frotz &&
+ echo qfwfq >frotz/nitfol &&
+ git add frotz &&
+ git commit -m "subdir test"
+'
+
+test_expect_success 'Recursive without -r fails' '
+ ! git rm frotz &&
+ test -d frotz &&
+ test -f frotz/nitfol
+'
+
+test_expect_success 'Recursive with -r but dirty' '
+ echo qfwfq >>frotz/nitfol
+ ! git rm -r frotz &&
+ test -d frotz &&
+ test -f frotz/nitfol
+'
+
+test_expect_success 'Recursive with -r -f' '
+ git rm -f -r frotz &&
+ ! test -f frotz/nitfol &&
+ ! test -d frotz
+'
+
test_done
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 6cd05c3d90..e98786de32 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -19,4 +19,69 @@ test_expect_success \
'Test that "git-add -- -q" works' \
'touch -- -q && git-add -- -q'
+test_expect_success \
+ 'git-add: Test that executable bit is not used if core.filemode=0' \
+ 'git repo-config core.filemode 0 &&
+ echo foo >xfoo1 &&
+ chmod 755 xfoo1 &&
+ git-add xfoo1 &&
+ case "`git-ls-files --stage xfoo1`" in
+ 100644" "*xfoo1) echo ok;;
+ *) echo fail; git-ls-files --stage xfoo1; (exit 1);;
+ esac'
+
+test_expect_success \
+ 'git-update-index --add: Test that executable bit is not used...' \
+ 'git repo-config core.filemode 0 &&
+ echo foo >xfoo2 &&
+ chmod 755 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);;
+ esac'
+
+test_expect_success \
+ 'git-update-index --add: Test that executable bit is not used...' \
+ 'git repo-config core.filemode 0 &&
+ ln -s xfoo2 xfoo3 &&
+ git-update-index --add xfoo3 &&
+ case "`git-ls-files --stage xfoo3`" in
+ 120000" "*xfoo3) echo ok;;
+ *) echo fail; git-ls-files --stage xfoo3; (exit 1);;
+ esac'
+
+test_expect_success '.gitignore test setup' '
+ echo "*.ig" >.gitignore &&
+ mkdir c.if d.ig &&
+ >a.ig && >b.if &&
+ >c.if/c.if && >c.if/c.ig &&
+ >d.ig/d.if && >d.ig/d.ig
+'
+
+test_expect_success '.gitignore is honored' '
+ git-add . &&
+ ! git-ls-files | grep "\\.ig"
+'
+
+test_expect_success 'error out when attempting to add ignored ones without -f' '
+ ! git-add a.?? &&
+ ! git-ls-files | grep "\\.ig"
+'
+
+test_expect_success 'error out when attempting to add ignored ones without -f' '
+ ! git-add d.?? &&
+ ! git-ls-files | grep "\\.ig"
+'
+
+test_expect_success 'add ignored ones with -f' '
+ git-add -f a.?? &&
+ git-ls-files --error-unmatch a.ig
+'
+
+test_expect_success 'add ignored ones with -f' '
+ git-add -f d.??/* &&
+ git-ls-files --error-unmatch d.ig/d.if d.ig/d.ig
+'
+
test_done
diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh
new file mode 100755
index 0000000000..6714b0dd6e
--- /dev/null
+++ b/t/t3900-i18n-commit.sh
@@ -0,0 +1,122 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Junio C Hamano
+#
+
+test_description='commit and log output encodings'
+
+. ./test-lib.sh
+
+compare_with () {
+ git-show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current &&
+ diff -u current "$2"
+}
+
+test_expect_success setup '
+ : >F &&
+ git-add F &&
+ T=$(git-write-tree) &&
+ C=$(git-commit-tree $T <../t3900/1-UTF-8.txt) &&
+ git-update-ref HEAD $C &&
+ git-tag C0
+'
+
+test_expect_success 'no encoding header for base case' '
+ E=$(git-cat-file commit C0 | sed -ne "s/^encoding //p") &&
+ test z = "z$E"
+'
+
+for H in ISO-8859-1 EUCJP ISO-2022-JP
+do
+ test_expect_success "$H setup" '
+ git-repo-config i18n.commitencoding $H &&
+ git-checkout -b $H C0 &&
+ echo $H >F &&
+ git-commit -a -F ../t3900/$H.txt
+ '
+done
+
+for H in ISO-8859-1 EUCJP ISO-2022-JP
+do
+ test_expect_success "check encoding header for $H" '
+ E=$(git-cat-file commit '$H' | sed -ne "s/^encoding //p") &&
+ test "z$E" = "z'$H'"
+ '
+done
+
+test_expect_success 'repo-config to remove customization' '
+ git-repo-config --unset-all i18n.commitencoding &&
+ if Z=$(git-repo-config --get-all i18n.commitencoding)
+ then
+ echo Oops, should have failed.
+ false
+ else
+ test z = "z$Z"
+ fi &&
+ git-repo-config i18n.commitencoding utf-8
+'
+
+test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
+ compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
+'
+
+for H in EUCJP ISO-2022-JP
+do
+ test_expect_success "$H should be shown in UTF-8 now" '
+ compare_with '$H' ../t3900/2-UTF-8.txt
+ '
+done
+
+test_expect_success 'repo-config to add customization' '
+ git-repo-config --unset-all i18n.commitencoding &&
+ if Z=$(git-repo-config --get-all i18n.commitencoding)
+ then
+ echo Oops, should have failed.
+ false
+ else
+ test z = "z$Z"
+ fi
+'
+
+for H in ISO-8859-1 EUCJP ISO-2022-JP
+do
+ test_expect_success "$H should be shown in itself now" '
+ git-repo-config i18n.commitencoding '$H' &&
+ compare_with '$H' ../t3900/'$H'.txt
+ '
+done
+
+test_expect_success 'repo-config to tweak customization' '
+ git-repo-config i18n.logoutputencoding utf-8
+'
+
+test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
+ compare_with ISO-8859-1 ../t3900/1-UTF-8.txt
+'
+
+for H in EUCJP ISO-2022-JP
+do
+ test_expect_success "$H should be shown in UTF-8 now" '
+ compare_with '$H' ../t3900/2-UTF-8.txt
+ '
+done
+
+for J in EUCJP ISO-2022-JP
+do
+ git-repo-config i18n.logoutputencoding $J
+ for H in EUCJP ISO-2022-JP
+ do
+ test_expect_success "$H should be shown in $J now" '
+ compare_with '$H' ../t3900/'$J'.txt
+ '
+ done
+done
+
+for H in ISO-8859-1 EUCJP ISO-2022-JP
+do
+ test_expect_success "No conversion with $H" '
+ compare_with "--encoding=none '$H'" ../t3900/'$H'.txt
+ '
+done
+
+test_done
diff --git a/t/t3900/1-UTF-8.txt b/t/t3900/1-UTF-8.txt
new file mode 100644
index 0000000000..ee31e19738
--- /dev/null
+++ b/t/t3900/1-UTF-8.txt
@@ -0,0 +1,3 @@
+ÄËÑÏÖ
+
+Ábçdèfg
diff --git a/t/t3900/2-UTF-8.txt b/t/t3900/2-UTF-8.txt
new file mode 100644
index 0000000000..63f4f8f121
--- /dev/null
+++ b/t/t3900/2-UTF-8.txt
@@ -0,0 +1,4 @@
+はれひほふ
+
+しているのが、いるので。
+濱浜ほれぷりぽれまびぐりろへ。
diff --git a/t/t3900/EUCJP.txt b/t/t3900/EUCJP.txt
new file mode 100644
index 0000000000..546f2aac01
--- /dev/null
+++ b/t/t3900/EUCJP.txt
@@ -0,0 +1,4 @@
+ϤҤۤ
+
+ƤΤΤǡ
+ͤۤפݤޤӤء
diff --git a/t/t3900/ISO-2022-JP.txt b/t/t3900/ISO-2022-JP.txt
new file mode 100644
index 0000000000..74b533042f
--- /dev/null
+++ b/t/t3900/ISO-2022-JP.txt
@@ -0,0 +1,4 @@
+$B$O$l$R$[$U(B
+
+$B$7$F$$$k$N$,!"$$$k$N$G!#(B
+$B_@IM$[$l$W$j$]$l$^$S$0$j$m$X!#(B
diff --git a/t/t3900/ISO-8859-1.txt b/t/t3900/ISO-8859-1.txt
new file mode 100644
index 0000000000..7cbef0ee6f
--- /dev/null
+++ b/t/t3900/ISO-8859-1.txt
@@ -0,0 +1,3 @@
+
+
+bdfg
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 71c454356f..ed37141b6e 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -73,6 +73,7 @@ test_expect_success setup '
for i in 1 2; do echo $i; done >>dir/sub &&
git update-index file0 dir/sub &&
+ git repo-config log.showroot false &&
git commit --amend &&
git show-branch
'
diff --git a/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial b/t/t4013/diff.diff-tree_--pretty_--root_--summary_initial
index ea48205537..58e5f74aea 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 0000000000..adf4993bac
--- /dev/null
+++ b/t/t4015-diff-whitespace.sh
@@ -0,0 +1,120 @@
+#!/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
++white space in the middle
+ whitespace at end
+ unchanged line
+ CR at endQ
+EOF
+git-diff -b > out
+test_expect_success 'another test, with -b' 'diff -u expect out'
+
+test_done
diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh
index ff052699a2..e2b1124c78 100755
--- a/t/t4103-apply-binary.sh
+++ b/t/t4103-apply-binary.sh
@@ -94,11 +94,11 @@ test_expect_failure 'apply binary diff (copy) -- should fail.' \
'do_reset
git-apply --index C.diff'
-test_expect_failure 'apply binary diff without replacement -- should fail.' \
+test_expect_success 'apply binary diff without replacement.' \
'do_reset
git-apply BF.diff'
-test_expect_failure 'apply binary diff without replacement (copy) -- should fail.' \
+test_expect_success 'apply binary diff without replacement (copy).' \
'do_reset
git-apply CF.diff'
diff --git a/t/t4104-apply-boundary.sh b/t/t4104-apply-boundary.sh
new file mode 100755
index 0000000000..2ff800c23f
--- /dev/null
+++ b/t/t4104-apply-boundary.sh
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='git-apply boundary tests
+
+'
+. ./test-lib.sh
+
+L="c d e f g h i j k l m n o p q r s t u v w x"
+
+test_expect_success setup '
+ for i in b '"$L"' y
+ do
+ echo $i
+ done >victim &&
+ cat victim >original &&
+ git update-index --add victim &&
+
+ : add to the head
+ for i in a b '"$L"' y
+ do
+ echo $i
+ done >victim &&
+ cat victim >add-a-expect &&
+ git diff victim >add-a-patch.with &&
+ git diff --unified=0 >add-a-patch.without &&
+
+ : modify at the head
+ for i in a '"$L"' y
+ do
+ echo $i
+ done >victim &&
+ cat victim >mod-a-expect &&
+ git diff victim >mod-a-patch.with &&
+ git diff --unified=0 >mod-a-patch.without &&
+
+ : remove from the head
+ for i in '"$L"' y
+ do
+ echo $i
+ done >victim &&
+ cat victim >del-a-expect &&
+ git diff victim >del-a-patch.with
+ git diff --unified=0 >del-a-patch.without &&
+
+ : add to the tail
+ for i in b '"$L"' y z
+ do
+ echo $i
+ done >victim &&
+ cat victim >add-z-expect &&
+ git diff victim >add-z-patch.with &&
+ git diff --unified=0 >add-z-patch.without &&
+
+ : modify at the tail
+ for i in a '"$L"' y
+ do
+ echo $i
+ done >victim &&
+ cat victim >mod-z-expect &&
+ git diff victim >mod-z-patch.with &&
+ git diff --unified=0 >mod-z-patch.without &&
+
+ : remove from the tail
+ for i in b '"$L"'
+ do
+ echo $i
+ done >victim &&
+ cat victim >del-z-expect &&
+ git diff victim >del-z-patch.with
+ git diff --unified=0 >del-z-patch.without &&
+
+ : done
+'
+
+for with in with without
+do
+ case "$with" in
+ with) u= ;;
+ without) u='--unidiff-zero ' ;;
+ esac
+ for kind in add-a add-z mod-a mod-z del-a del-z
+ do
+ test_expect_success "apply $kind-patch $with context" '
+ cat original >victim &&
+ git update-index victim &&
+ git apply --index '"$u$kind-patch.$with"' || {
+ cat '"$kind-patch.$with"'
+ (exit 1)
+ } &&
+ diff -u '"$kind"'-expect victim
+ '
+ done
+done
+
+for kind in add-a add-z mod-a mod-z del-a del-z
+do
+ rm -f $kind-ng.without
+ sed -e "s/^diff --git /diff /" \
+ -e '/^index /d' \
+ <$kind-patch.without >$kind-ng.without
+ test_expect_success "apply non-git $kind-patch without context" '
+ cat original >victim &&
+ git update-index victim &&
+ git apply --unidiff-zero --index '"$kind-ng.without"' || {
+ cat '"$kind-ng.without"'
+ (exit 1)
+ } &&
+ diff -u '"$kind"'-expect victim
+ '
+done
+
+test_done
diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index 69aebe6005..aa2c869e0e 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -22,25 +22,64 @@ test_expect_success setup '
tr "[mon]" '\''[\0\1\2]'\'' <file1 >file2 &&
git commit -a -m second &&
+ git tag second &&
- git diff --binary -R initial >patch
+ git diff --binary initial second >patch
'
test_expect_success 'apply in forward' '
+ T0=`git rev-parse "second^{tree}"` &&
+ git reset --hard initial &&
git apply --index --binary patch &&
- git diff initial >diff &&
- diff -u /dev/null diff
-
+ T1=`git write-tree` &&
+ test "$T0" = "$T1"
'
test_expect_success 'apply in reverse' '
+ git reset --hard second &&
git apply --reverse --binary --index patch &&
git diff >diff &&
diff -u /dev/null diff
'
+test_expect_success 'setup separate repository lacking postimage' '
+
+ git tar-tree initial initial | tar xf - &&
+ (
+ cd initial && git init && git add .
+ ) &&
+
+ git tar-tree second second | tar xf - &&
+ (
+ cd second && git init && git add .
+ )
+
+'
+
+test_expect_success 'apply in forward without postimage' '
+
+ T0=`git rev-parse "second^{tree}"` &&
+ (
+ cd initial &&
+ git apply --index --binary ../patch &&
+ T1=`git write-tree` &&
+ test "$T0" = "$T1"
+ )
+'
+
+test_expect_success 'apply in reverse without postimage' '
+
+ T0=`git rev-parse "initial^{tree}"` &&
+ (
+ cd second &&
+ git apply --index --binary --reverse ../patch &&
+ T1=`git write-tree` &&
+ test "$T0" = "$T1"
+ )
+'
+
test_done
diff --git a/t/t4117-apply-reject.sh b/t/t4117-apply-reject.sh
new file mode 100755
index 0000000000..b4de075a3e
--- /dev/null
+++ b/t/t4117-apply-reject.sh
@@ -0,0 +1,157 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='git-apply with rejects
+
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
+ do
+ echo $i
+ done >file1 &&
+ cat file1 >saved.file1 &&
+ git update-index --add file1 &&
+ git commit -m initial &&
+
+ for i in 1 2 A B 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 D 21
+ do
+ echo $i
+ done >file1 &&
+ git diff >patch.1 &&
+ cat file1 >clean &&
+
+ for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21
+ do
+ echo $i
+ done >expected &&
+
+ mv file1 file2 &&
+ git update-index --add --remove file1 file2 &&
+ git diff -M HEAD >patch.2 &&
+
+ rm -f file1 file2 &&
+ mv saved.file1 file1 &&
+ git update-index --add --remove file1 file2 &&
+
+ for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F 21
+ do
+ echo $i
+ done >file1 &&
+
+ cat file1 >saved.file1
+'
+
+test_expect_success 'apply without --reject should fail' '
+
+ if git apply patch.1
+ then
+ echo "Eh? Why?"
+ exit 1
+ fi
+
+ diff -u file1 saved.file1
+'
+
+test_expect_success 'apply without --reject should fail' '
+
+ if git apply --verbose patch.1
+ then
+ echo "Eh? Why?"
+ exit 1
+ fi
+
+ diff -u file1 saved.file1
+'
+
+test_expect_success 'apply with --reject should fail but update the file' '
+
+ cat saved.file1 >file1 &&
+ rm -f file1.rej file2.rej &&
+
+ if git apply --reject patch.1
+ then
+ echo "succeeds with --reject?"
+ exit 1
+ fi
+
+ diff -u file1 expected &&
+
+ cat file1.rej &&
+
+ if test -f file2.rej
+ then
+ echo "file2 should not have been touched"
+ exit 1
+ fi
+'
+
+test_expect_success 'apply with --reject should fail but update the file' '
+
+ cat saved.file1 >file1 &&
+ rm -f file1.rej file2.rej file2 &&
+
+ if git apply --reject patch.2 >rejects
+ then
+ echo "succeeds with --reject?"
+ exit 1
+ fi
+
+ test -f file1 && {
+ echo "file1 still exists?"
+ exit 1
+ }
+ diff -u file2 expected &&
+
+ cat file2.rej &&
+
+ if test -f file1.rej
+ then
+ echo "file2 should not have been touched"
+ exit 1
+ fi
+
+'
+
+test_expect_success 'the same test with --verbose' '
+
+ cat saved.file1 >file1 &&
+ rm -f file1.rej file2.rej file2 &&
+
+ if git apply --reject --verbose patch.2 >rejects
+ then
+ echo "succeeds with --reject?"
+ exit 1
+ fi
+
+ test -f file1 && {
+ echo "file1 still exists?"
+ exit 1
+ }
+ diff -u file2 expected &&
+
+ cat file2.rej &&
+
+ if test -f file1.rej
+ then
+ echo "file2 should not have been touched"
+ exit 1
+ fi
+
+'
+
+test_expect_success 'apply cleanly with --verbose' '
+
+ git cat-file -p HEAD:file1 >file1 &&
+ rm -f file?.rej file2 &&
+
+ git apply --verbose patch.1 &&
+
+ diff -u file1 clean
+'
+
+test_done
diff --git a/t/t4118-apply-empty-context.sh b/t/t4118-apply-empty-context.sh
new file mode 100755
index 0000000000..7309422fe5
--- /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/t4200-rerere.sh b/t/t4200-rerere.sh
new file mode 100755
index 0000000000..5ee5b23095
--- /dev/null
+++ b/t/t4200-rerere.sh
@@ -0,0 +1,154 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Johannes E. Schindelin
+#
+
+test_description='git-rerere
+'
+
+. ./test-lib.sh
+
+cat > a1 << EOF
+Whether 'tis nobler in the mind to suffer
+The slings and arrows of outrageous fortune,
+Or to take arms against a sea of troubles,
+And by opposing end them? To die: to sleep;
+No more; and by a sleep to say we end
+The heart-ache and the thousand natural shocks
+That flesh is heir to, 'tis a consummation
+Devoutly to be wish'd.
+EOF
+
+git add a1
+git commit -q -a -m initial
+
+git checkout -b first
+cat >> a1 << EOF
+To die, to sleep;
+To sleep: perchance to dream: ay, there's the rub;
+For in that sleep of death what dreams may come
+When we have shuffled off this mortal coil,
+Must give us pause: there's the respect
+That makes calamity of so long life;
+EOF
+git commit -q -a -m first
+
+git checkout -b second master
+git show first:a1 | sed 's/To die, t/To die! T/' > a1
+git commit -q -a -m second
+
+# activate rerere
+mkdir .git/rr-cache
+
+test_expect_failure 'conflicting merge' 'git pull . first'
+
+sha1=4f58849a60b4f969a2848966b6d02893b783e8fb
+rr=.git/rr-cache/$sha1
+test_expect_success 'recorded preimage' "grep ======= $rr/preimage"
+
+test_expect_success 'no postimage or thisimage yet' \
+ "test ! -f $rr/postimage -a ! -f $rr/thisimage"
+
+git show first:a1 > a1
+
+cat > expect << EOF
+--- a/a1
++++ b/a1
+@@ -6,11 +6,7 @@
+ The heart-ache and the thousand natural shocks
+ That flesh is heir to, 'tis a consummation
+ Devoutly to be wish'd.
+-<<<<<<<
+-To die! To sleep;
+-=======
+ To die, to sleep;
+->>>>>>>
+ To sleep: perchance to dream: ay, there's the rub;
+ For in that sleep of death what dreams may come
+ When we have shuffled off this mortal coil,
+EOF
+
+git rerere diff > out
+
+test_expect_success 'rerere diff' 'diff -u expect out'
+
+cat > expect << EOF
+a1
+EOF
+
+git rerere status > out
+
+test_expect_success 'rerere status' 'diff -u expect out'
+
+test_expect_success 'commit succeeds' \
+ "git commit -q -a -m 'prefer first over second'"
+
+test_expect_success 'recorded postimage' "test -f $rr/postimage"
+
+git checkout -b third master
+git show second^:a1 | sed 's/To die: t/To die! T/' > a1
+git commit -q -a -m third
+
+test_expect_failure 'another conflicting merge' 'git pull . first'
+
+git show first:a1 | sed 's/To die: t/To die! T/' > expect
+test_expect_success 'rerere kicked in' "! grep ======= a1"
+
+test_expect_success 'rerere prefers first change' 'diff -u a1 expect'
+
+rm $rr/postimage
+echo "$sha1 a1" | tr '\012' '\0' > .git/rr-cache/MERGE_RR
+
+test_expect_success 'rerere clear' 'git rerere clear'
+
+test_expect_success 'clear removed the directory' "test ! -d $rr"
+
+mkdir $rr
+echo Hello > $rr/preimage
+echo World > $rr/postimage
+
+sha2=4000000000000000000000000000000000000000
+rr2=.git/rr-cache/$sha2
+mkdir $rr2
+echo Hello > $rr2/preimage
+
+case "$(date -d @11111111 +%s 2>/dev/null)" in
+[1-9]*)
+ # it is a recent GNU date. good.
+ now=$(date +%s)
+ almost_15_days_ago=$(($now+60-15*86400))
+ just_over_15_days_ago=$(($now-1-15*86400))
+ almost_60_days_ago=$(($now+60-60*86400))
+ just_over_60_days_ago=$(($now-1-60*86400))
+ predate1="$(date -d "@$almost_60_days_ago" +%c)"
+ predate2="$(date -d "@$almost_15_days_ago" +%c)"
+ postdate1="$(date -d "@$just_over_60_days_ago" +%c)"
+ postdate2="$(date -d "@$just_over_15_days_ago" +%c)"
+ ;;
+*)
+ # it is not GNU date. oh, well.
+ predate1="$(date)"
+ predate2="$(date)"
+ postdate1='1 Oct 2006 00:00:00'
+ postdate2='1 Dec 2006 00:00:00'
+esac
+
+touch -m -d "$predate1" $rr/preimage
+touch -m -d "$predate2" $rr2/preimage
+
+test_expect_success 'garbage collection (part1)' 'git rerere gc'
+
+test_expect_success 'young records still live' \
+ "test -f $rr/preimage -a -f $rr2/preimage"
+
+touch -m -d "$postdate1" $rr/preimage
+touch -m -d "$postdate2" $rr2/preimage
+
+test_expect_success 'garbage collection (part2)' 'git rerere gc'
+
+test_expect_success 'old records rest in peace' \
+ "test ! -f $rr/preimage -a ! -f $rr2/preimage"
+
+test_done
+
+
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 278eb66701..cf08e9279c 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/t5300-pack-object.sh b/t/t5300-pack-object.sh
index de45ac4e0f..f511547455 100755
--- a/t/t5300-pack-object.sh
+++ b/t/t5300-pack-object.sh
@@ -44,7 +44,7 @@ test_expect_success \
'unpack without delta' \
"GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
- git-init-db &&
+ git-init &&
git-unpack-objects -n <test-1-${packname_1}.pack &&
git-unpack-objects <test-1-${packname_1}.pack"
@@ -75,7 +75,7 @@ test_expect_success \
'unpack with delta' \
'GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
- git-init-db &&
+ git-init &&
git-unpack-objects -n <test-2-${packname_2}.pack &&
git-unpack-objects <test-2-${packname_2}.pack'
@@ -100,7 +100,7 @@ test_expect_success \
'use packed objects' \
'GIT_OBJECT_DIRECTORY=.git2/objects &&
export GIT_OBJECT_DIRECTORY &&
- git-init-db &&
+ git-init &&
cp test-1-${packname_1}.pack test-1-${packname_1}.idx .git2/objects/pack && {
git-diff-tree --root -p $commit &&
while read object
diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh
new file mode 100755
index 0000000000..5a7232a577
--- /dev/null
+++ b/t/t5301-sliding-window.sh
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Shawn Pearce
+#
+
+test_description='mmap sliding window tests'
+. ./test-lib.sh
+
+test_expect_success \
+ 'setup' \
+ 'rm -f .git/index*
+ for i in a b c
+ do
+ echo $i >$i &&
+ dd if=/dev/urandom bs=32k count=1 >>$i &&
+ git-update-index --add $i || return 1
+ done &&
+ echo d >d && cat c >>d && git-update-index --add d &&
+ tree=`git-write-tree` &&
+ commit1=`git-commit-tree $tree </dev/null` &&
+ git-update-ref HEAD $commit1 &&
+ git-repack -a -d &&
+ test "`git-count-objects`" = "0 objects, 0 kilobytes" &&
+ pack1=`ls .git/objects/pack/*.pack` &&
+ test -f "$pack1"'
+
+test_expect_success \
+ 'verify-pack -v, defaults' \
+ 'git-verify-pack -v "$pack1"'
+
+test_expect_success \
+ 'verify-pack -v, packedGitWindowSize == 1 page' \
+ 'git-repo-config core.packedGitWindowSize 512 &&
+ git-verify-pack -v "$pack1"'
+
+test_expect_success \
+ 'verify-pack -v, packedGit{WindowSize,Limit} == 1 page' \
+ 'git-repo-config core.packedGitWindowSize 512 &&
+ git-repo-config core.packedGitLimit 512 &&
+ git-verify-pack -v "$pack1"'
+
+test_expect_success \
+ 'repack -a -d, packedGit{WindowSize,Limit} == 1 page' \
+ 'git-repo-config core.packedGitWindowSize 512 &&
+ git-repo-config core.packedGitLimit 512 &&
+ commit2=`git-commit-tree $tree -p $commit1 </dev/null` &&
+ git-update-ref HEAD $commit2 &&
+ git-repack -a -d &&
+ test "`git-count-objects`" = "0 objects, 0 kilobytes" &&
+ pack2=`ls .git/objects/pack/*.pack` &&
+ test -f "$pack2"
+ test "$pack1" \!= "$pack2"'
+
+test_expect_success \
+ 'verify-pack -v, defaults' \
+ 'git-repo-config --unset core.packedGitWindowSize &&
+ git-repo-config --unset core.packedGitLimit &&
+ git-verify-pack -v "$pack2"'
+
+test_done
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index f3694ac3c7..2c151912a3 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -8,38 +8,63 @@ test_description='See why rewinding head breaks send-pack
'
. ./test-lib.sh
-touch cpio-test
-test_expect_success 'working cpio' 'echo cpio-test | cpio -o > /dev/null'
-
-cnt='1'
+cnt=64
test_expect_success setup '
+ test_tick &&
+ mkdir mozart mozart/is &&
+ echo "Commit #0" >mozart/is/pink &&
+ git-update-index --add mozart/is/pink &&
tree=$(git-write-tree) &&
commit=$(echo "Commit #0" | git-commit-tree $tree) &&
zero=$commit &&
parent=$zero &&
- for i in $cnt
+ i=0 &&
+ while test $i -le $cnt
do
- sleep 1 &&
+ i=$(($i+1)) &&
+ test_tick &&
+ echo "Commit #$i" >mozart/is/pink &&
+ git-update-index --add mozart/is/pink &&
+ tree=$(git-write-tree) &&
commit=$(echo "Commit #$i" | git-commit-tree $tree -p $parent) &&
+ git-update-ref refs/tags/commit$i $commit &&
parent=$commit || return 1
done &&
git-update-ref HEAD "$commit" &&
- git-clone -l ./. victim &&
+ git-clone ./. victim &&
cd victim &&
git-log &&
cd .. &&
git-update-ref HEAD "$zero" &&
parent=$zero &&
- for i in $cnt
+ i=0 &&
+ while test $i -le $cnt
do
- sleep 1 &&
+ i=$(($i+1)) &&
+ test_tick &&
+ echo "Rebase #$i" >mozart/is/pink &&
+ git-update-index --add mozart/is/pink &&
+ tree=$(git-write-tree) &&
commit=$(echo "Rebase #$i" | git-commit-tree $tree -p $parent) &&
+ git-update-ref refs/tags/rebase$i $commit &&
parent=$commit || return 1
done &&
git-update-ref HEAD "$commit" &&
echo Rebase &&
git-log'
+test_expect_success 'pack the source repository' '
+ git repack -a -d &&
+ git prune
+'
+
+test_expect_success 'pack the destination repository' '
+ cd victim &&
+ git repack -a -d &&
+ git prune &&
+ cd ..
+'
+
test_expect_success \
'pushing rewound head should not barf but require --force' '
# should not fail but refuse to update.
@@ -64,4 +89,28 @@ test_expect_success \
cmp victim/.git/refs/heads/master .git/refs/heads/master
'
+test_expect_success \
+ 'push can be used to delete a ref' '
+ cd victim &&
+ git branch extra master &&
+ cd .. &&
+ test -f victim/.git/refs/heads/extra &&
+ git-send-pack ./victim/.git/ :extra master &&
+ ! test -f victim/.git/refs/heads/extra
+'
+
+unset GIT_CONFIG GIT_CONFIG_LOCAL
+HOME=`pwd`/no-such-directory
+export HOME ;# this way we force the victim/.git/config to be used.
+
+test_expect_success \
+ 'pushing with --force should be denied with denyNonFastforwards' '
+ cd victim &&
+ git-repo-config receive.denyNonFastforwards true &&
+ cd .. &&
+ git-update-ref refs/heads/master master^ &&
+ git-send-pack --force ./victim/.git/ master &&
+ ! diff -u .git/refs/heads/master victim/.git/refs/heads/master
+'
+
test_done
diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
new file mode 100755
index 0000000000..cd8cee6ae8
--- /dev/null
+++ b/t/t5401-update-hooks.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Shawn O. Pearce
+#
+
+test_description='Test the update hook infrastructure.'
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo This is a test. >a &&
+ git-update-index --add a &&
+ tree0=$(git-write-tree) &&
+ commit0=$(echo setup | git-commit-tree $tree0) &&
+ git-update-ref HEAD $commit0 &&
+ git-clone ./. victim &&
+ echo We hope it works. >a &&
+ git-update-index a &&
+ tree1=$(git-write-tree) &&
+ commit1=$(echo modify | git-commit-tree $tree1 -p $commit0) &&
+ git-update-ref HEAD $commit1
+'
+
+cat >victim/.git/hooks/update <<'EOF'
+#!/bin/sh
+echo "$@" >$GIT_DIR/update.args
+read x; echo -n "$x" >$GIT_DIR/update.stdin
+echo STDOUT update
+echo STDERR update >&2
+EOF
+chmod u+x victim/.git/hooks/update
+
+cat >victim/.git/hooks/post-update <<'EOF'
+#!/bin/sh
+echo "$@" >$GIT_DIR/post-update.args
+read x; echo -n "$x" >$GIT_DIR/post-update.stdin
+echo STDOUT post-update
+echo STDERR post-update >&2
+EOF
+chmod u+x victim/.git/hooks/post-update
+
+test_expect_success push '
+ git-send-pack ./victim/.git/ master >send.out 2>send.err
+'
+
+test_expect_success 'hooks ran' '
+ test -f victim/.git/update.args &&
+ test -f victim/.git/update.stdin &&
+ test -f victim/.git/post-update.args &&
+ test -f victim/.git/post-update.stdin
+'
+
+test_expect_success 'update hook arguments' '
+ echo refs/heads/master $commit0 $commit1 |
+ diff -u - victim/.git/update.args
+'
+
+test_expect_success 'post-update hook arguments' '
+ echo refs/heads/master |
+ diff -u - victim/.git/post-update.args
+'
+
+test_expect_failure 'update hook stdin is /dev/null' '
+ test -s victim/.git/update.stdin
+'
+
+test_expect_failure 'post-update hook stdin is /dev/null' '
+ test -s victim/.git/post-update.stdin
+'
+
+test_expect_failure 'send-pack produced no output' '
+ test -s send.out
+'
+
+test_expect_success 'send-pack stderr contains hook messages' '
+ grep "STDOUT update" send.err &&
+ grep "STDERR update" send.err &&
+ grep "STDOUT post-update" send.err &&
+ grep "STDERR post-update" send.err
+'
+
+test_done
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index f7625a6f46..ef78df67ea 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -97,7 +97,7 @@ pull_to_client () {
(
mkdir client &&
cd client &&
- git-init-db 2>> log2.txt
+ git-init 2>> log2.txt
)
add A1
@@ -128,4 +128,54 @@ pull_to_client 2nd "B" $((64*3))
pull_to_client 3rd "A" $((1*3)) # old fails
+test_expect_success "clone shallow" "git-clone --depth 2 . shallow"
+
+(cd shallow; git-count-objects -v) > count.shallow
+
+test_expect_success "clone shallow object count" \
+ "test \"in-pack: 18\" = \"$(grep in-pack count.shallow)\""
+
+count_output () {
+ sed -e '/^in-pack:/d' -e '/^packs:/d' -e '/: 0$/d' "$1"
+}
+
+test_expect_success "clone shallow object count (part 2)" '
+ test -z "$(count_output count.shallow)"
+'
+
+test_expect_success "fsck in shallow repo" \
+ "(cd shallow; git-fsck-objects --full)"
+
+#test_done; exit
+
+add B66 $B65
+add B67 $B66
+
+test_expect_success "pull in shallow repo" \
+ "(cd shallow; git pull .. B)"
+
+(cd shallow; git-count-objects -v) > count.shallow
+test_expect_success "clone shallow object count" \
+ "test \"count: 6\" = \"$(grep count count.shallow)\""
+
+add B68 $B67
+add B69 $B68
+
+test_expect_success "deepening pull in shallow repo" \
+ "(cd shallow; git pull --depth 4 .. B)"
+
+(cd shallow; git-count-objects -v) > count.shallow
+test_expect_success "clone shallow object count" \
+ "test \"count: 12\" = \"$(grep count count.shallow)\""
+
+test_expect_success "deepening fetch in shallow repo" \
+ "(cd shallow; git fetch --depth 4 .. A:A)"
+
+(cd shallow; git-count-objects -v) > count.shallow
+test_expect_success "clone shallow object count" \
+ "test \"count: 18\" = \"$(grep count count.shallow)\""
+
+test_expect_failure "pull in shallow repo with missing merge base" \
+ "(cd shallow; git pull --depth 4 .. A)"
+
test_done
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
new file mode 100755
index 0000000000..3ce9446210
--- /dev/null
+++ b/t/t5510-fetch.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+# Copyright (c) 2006, Junio C Hamano.
+
+test_description='Per branch config variables affects "git fetch".
+
+'
+
+. ./test-lib.sh
+
+D=`pwd`
+
+test_expect_success setup '
+ echo >file original &&
+ git add file &&
+ git commit -a -m original'
+
+test_expect_success "clone and setup child repos" '
+ git clone . one &&
+ cd one &&
+ echo >file updated by one &&
+ git commit -a -m "updated by one" &&
+ cd .. &&
+ git clone . two &&
+ cd two &&
+ git repo-config branch.master.remote one &&
+ git repo-config remote.one.url ../one/.git/ &&
+ git repo-config remote.one.fetch refs/heads/master:refs/heads/one &&
+ cd .. &&
+ git clone . three &&
+ cd three &&
+ git repo-config branch.master.remote two &&
+ git repo-config branch.master.merge refs/heads/one &&
+ mkdir -p .git/remotes &&
+ {
+ echo "URL: ../two/.git/"
+ echo "Pull: refs/heads/master:refs/heads/two"
+ echo "Pull: refs/heads/one:refs/heads/one"
+ } >.git/remotes/two
+'
+
+test_expect_success "fetch test" '
+ cd "$D" &&
+ echo >file updated by origin &&
+ git commit -a -m "updated by origin" &&
+ cd two &&
+ git fetch &&
+ test -f .git/refs/heads/one &&
+ mine=`git rev-parse refs/heads/one` &&
+ his=`cd ../one && git rev-parse refs/heads/master` &&
+ test "z$mine" = "z$his"
+'
+
+test_expect_success "fetch test for-merge" '
+ cd "$D" &&
+ cd three &&
+ git fetch &&
+ test -f .git/refs/heads/two &&
+ test -f .git/refs/heads/one &&
+ master_in_two=`cd ../two && git rev-parse master` &&
+ one_in_two=`cd ../two && git rev-parse one` &&
+ {
+ echo "$master_in_two not-for-merge"
+ echo "$one_in_two "
+ } >expected &&
+ cut -f -2 .git/FETCH_HEAD >actual &&
+ diff expected actual'
+
+test_expect_success 'fetch following tags' '
+
+ cd "$D" &&
+ git tag -a -m 'annotated' anno HEAD &&
+ git tag light HEAD &&
+
+ mkdir four &&
+ cd four &&
+ git init &&
+
+ git fetch .. :track &&
+ git show-ref --verify refs/tags/anno &&
+ git show-ref --verify refs/tags/light
+
+'
+
+test_done
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
new file mode 100755
index 0000000000..7eb37838bb
--- /dev/null
+++ b/t/t5520-pull.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+test_description='pulling into void'
+
+. ./test-lib.sh
+
+D=`pwd`
+
+test_expect_success setup '
+
+ echo file >file &&
+ git add file &&
+ git commit -a -m original
+
+'
+
+test_expect_success 'pulling into void' '
+ mkdir cloned &&
+ cd cloned &&
+ git init &&
+ git pull ..
+'
+
+cd "$D"
+
+test_expect_success 'checking the results' '
+ test -f file &&
+ test -f cloned/file &&
+ diff file cloned/file
+'
+
+test_done
+
diff --git a/t/t5600-clone-fail-cleanup.sh b/t/t5600-clone-fail-cleanup.sh
index 0c6a363be9..041be04f5c 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/t5710-info-alternate.sh b/t/t5710-info-alternate.sh
index 2e1b48a89b..b9f6d96363 100755
--- a/t/t5710-info-alternate.sh
+++ b/t/t5710-info-alternate.sh
@@ -58,6 +58,8 @@ test_expect_failure 'creating too deep nesting' \
git clone -l -s D E &&
git clone -l -s E F &&
git clone -l -s F G &&
+git clone -l -s G H &&
+cd H &&
test_valid_repo'
cd "$base_dir"
diff --git a/t/t6001-rev-list-graft.sh b/t/t6001-rev-list-graft.sh
new file mode 100755
index 0000000000..b2131cdacd
--- /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/t6005-rev-list-count.sh b/t/t6005-rev-list-count.sh
new file mode 100755
index 0000000000..334fccf58c
--- /dev/null
+++ b/t/t6005-rev-list-count.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+test_description='git-rev-list --max-count and --skip test'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ for n in 1 2 3 4 5 ; do \
+ echo $n > a ; \
+ git add a ; \
+ git commit -m "$n" ; \
+ done
+'
+
+test_expect_success 'no options' '
+ test $(git-rev-list HEAD | wc -l) = 5
+'
+
+test_expect_success '--max-count' '
+ test $(git-rev-list HEAD --max-count=0 | wc -l) = 0 &&
+ test $(git-rev-list HEAD --max-count=3 | wc -l) = 3 &&
+ test $(git-rev-list HEAD --max-count=5 | wc -l) = 5 &&
+ test $(git-rev-list HEAD --max-count=10 | wc -l) = 5
+'
+
+test_expect_success '--max-count all forms' '
+ test $(git-rev-list HEAD --max-count=1 | wc -l) = 1 &&
+ test $(git-rev-list HEAD -1 | wc -l) = 1 &&
+ test $(git-rev-list HEAD -n1 | wc -l) = 1 &&
+ test $(git-rev-list HEAD -n 1 | wc -l) = 1
+'
+
+test_expect_success '--skip' '
+ test $(git-rev-list HEAD --skip=0 | wc -l) = 5 &&
+ test $(git-rev-list HEAD --skip=3 | wc -l) = 2 &&
+ test $(git-rev-list HEAD --skip=5 | wc -l) = 0 &&
+ test $(git-rev-list HEAD --skip=10 | wc -l) = 0
+'
+
+test_expect_success '--skip --max-count' '
+ test $(git-rev-list HEAD --skip=0 --max-count=0 | wc -l) = 0 &&
+ test $(git-rev-list HEAD --skip=0 --max-count=10 | wc -l) = 5 &&
+ test $(git-rev-list HEAD --skip=3 --max-count=0 | wc -l) = 0 &&
+ test $(git-rev-list HEAD --skip=3 --max-count=1 | wc -l) = 1 &&
+ test $(git-rev-list HEAD --skip=3 --max-count=2 | wc -l) = 2 &&
+ test $(git-rev-list HEAD --skip=3 --max-count=10 | wc -l) = 2 &&
+ test $(git-rev-list HEAD --skip=5 --max-count=10 | wc -l) = 0 &&
+ test $(git-rev-list HEAD --skip=10 --max-count=10 | wc -l) = 0
+'
+
+test_done
diff --git a/t/t6021-merge-criss-cross.sh b/t/t6021-merge-criss-cross.sh
index 8f7366da8d..499cafb882 100755
--- a/t/t6021-merge-criss-cross.sh
+++ b/t/t6021-merge-criss-cross.sh
@@ -10,12 +10,6 @@
test_description='Test criss-cross merge'
. ./test-lib.sh
-if test "$no_python"; then
- echo "Skipping: no python => no recursive merge"
- test_done
- exit 0
-fi
-
test_expect_success 'prepare repository' \
'echo "1
2
diff --git a/t/t6022-merge-rename.sh b/t/t6022-merge-rename.sh
index 5ac25647ab..b608e202c1 100755
--- a/t/t6022-merge-rename.sh
+++ b/t/t6022-merge-rename.sh
@@ -3,12 +3,6 @@
test_description='Merge-recursive merging renames'
. ./test-lib.sh
-if test "$no_python"; then
- echo "Skipping: no python => no recursive merge"
- test_done
- exit 0
-fi
-
test_expect_success setup \
'
cat >A <<\EOF &&
@@ -48,15 +42,20 @@ O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
EOF
git add A M &&
-git commit -m initial &&
+git commit -m "initial has A and M" &&
git branch white &&
git branch red &&
git branch blue &&
+git branch yellow &&
sed -e "/^g /s/.*/g : master changes a line/" <A >A+ &&
mv A+ A &&
git commit -a -m "master updates A" &&
+git checkout yellow &&
+rm -f M &&
+git commit -a -m "yellow removes M" &&
+
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 &&
@@ -85,27 +84,27 @@ test_expect_success 'pull renaming branch into unrenaming one' \
git show-branch
git pull . white && {
echo "BAD: should have conflicted"
- exit 1
+ return 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
+ return 1
}
test "$(git ls-files -s N | wc -l)" -eq 1 || {
echo "BAD: should have merged N"
- exit 1
+ return 1
}
sed -ne "/^g/{
p
q
}" B | grep master || {
echo "BAD: should have listed our change first"
- exit 1
+ return 1
}
test "$(git diff white N | wc -l)" -eq 0 || {
echo "BAD: should have taken colored branch"
- exit 1
+ return 1
}
'
@@ -116,26 +115,26 @@ test_expect_success 'pull renaming branch into another renaming one' \
git checkout red
git pull . white && {
echo "BAD: should have conflicted"
- exit 1
+ return 1
}
test "$(git ls-files -u B | wc -l)" -eq 3 || {
echo "BAD: should have left stages"
- exit 1
+ return 1
}
test "$(git ls-files -s N | wc -l)" -eq 1 || {
echo "BAD: should have merged N"
- exit 1
+ return 1
}
sed -ne "/^g/{
p
q
}" B | grep red || {
echo "BAD: should have listed our change first"
- exit 1
+ return 1
}
test "$(git diff white N | wc -l)" -eq 0 || {
echo "BAD: should have taken colored branch"
- exit 1
+ return 1
}
'
@@ -145,26 +144,26 @@ test_expect_success 'pull unrenaming branch into renaming one' \
git show-branch
git pull . master && {
echo "BAD: should have conflicted"
- exit 1
+ return 1
}
test "$(git ls-files -u B | wc -l)" -eq 3 || {
echo "BAD: should have left stages"
- exit 1
+ return 1
}
test "$(git ls-files -s N | wc -l)" -eq 1 || {
echo "BAD: should have merged N"
- exit 1
+ return 1
}
sed -ne "/^g/{
p
q
}" B | grep red || {
echo "BAD: should have listed our change first"
- exit 1
+ return 1
}
test "$(git diff white N | wc -l)" -eq 0 || {
echo "BAD: should have taken colored branch"
- exit 1
+ return 1
}
'
@@ -174,35 +173,149 @@ test_expect_success 'pull conflicting renames' \
git show-branch
git pull . blue && {
echo "BAD: should have conflicted"
- exit 1
+ return 1
}
test "$(git ls-files -u A | wc -l)" -eq 1 || {
echo "BAD: should have left a stage"
- exit 1
+ return 1
}
test "$(git ls-files -u B | wc -l)" -eq 1 || {
echo "BAD: should have left a stage"
- exit 1
+ return 1
}
test "$(git ls-files -u C | wc -l)" -eq 1 || {
echo "BAD: should have left a stage"
- exit 1
+ return 1
}
test "$(git ls-files -s N | wc -l)" -eq 1 || {
echo "BAD: should have merged N"
- exit 1
+ return 1
}
sed -ne "/^g/{
p
q
}" B | grep red || {
echo "BAD: should have listed our change first"
- exit 1
+ return 1
}
test "$(git diff white N | wc -l)" -eq 0 || {
echo "BAD: should have taken colored branch"
- exit 1
+ return 1
+ }
+'
+
+test_expect_success 'interference with untracked working tree file' '
+
+ git reset --hard
+ git show-branch
+ echo >A this file should not matter
+ git pull . white && {
+ echo "BAD: should have conflicted"
+ return 1
+ }
+ test -f A || {
+ echo "BAD: should have left A intact"
+ return 1
+ }
+'
+
+test_expect_success 'interference with untracked working tree file' '
+
+ git reset --hard
+ git checkout white
+ git show-branch
+ rm -f A
+ echo >A this file should not matter
+ git pull . red && {
+ echo "BAD: should have conflicted"
+ return 1
+ }
+ test -f A || {
+ echo "BAD: should have left A intact"
+ return 1
+ }
+'
+
+test_expect_success 'interference with untracked working tree file' '
+
+ git reset --hard
+ rm -f A M
+ git checkout -f master
+ git tag -f anchor
+ git show-branch
+ git pull . yellow || {
+ echo "BAD: should have cleanly merged"
+ return 1
+ }
+ test -f M && {
+ echo "BAD: should have removed M"
+ return 1
+ }
+ git reset --hard anchor
+'
+
+test_expect_success 'updated working tree file should prevent the merge' '
+
+ git reset --hard
+ rm -f A M
+ git checkout -f master
+ git tag -f anchor
+ git show-branch
+ echo >>M one line addition
+ cat M >M.saved
+ git pull . yellow && {
+ echo "BAD: should have complained"
+ return 1
+ }
+ diff M M.saved || {
+ echo "BAD: should have left M intact"
+ return 1
+ }
+ rm -f M.saved
+'
+
+test_expect_success 'updated working tree file should prevent the merge' '
+
+ git reset --hard
+ rm -f A M
+ git checkout -f master
+ git tag -f anchor
+ git show-branch
+ echo >>M one line addition
+ cat M >M.saved
+ git update-index M
+ git pull . yellow && {
+ echo "BAD: should have complained"
+ return 1
+ }
+ diff M M.saved || {
+ echo "BAD: should have left M intact"
+ return 1
+ }
+ rm -f M.saved
+'
+
+test_expect_success 'interference with untracked working tree file' '
+
+ git reset --hard
+ rm -f A M
+ git checkout -f yellow
+ git tag -f anchor
+ git show-branch
+ echo >M this file should not matter
+ git pull . master || {
+ echo "BAD: should have cleanly merged"
+ return 1
+ }
+ test -f M || {
+ echo "BAD: should have left M intact"
+ return 1
+ }
+ git ls-files -s | grep M && {
+ echo "BAD: M must be untracked in the result"
+ return 1
}
+ git reset --hard anchor
'
test_done
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
new file mode 100644
index 0000000000..1c21d8c986
--- /dev/null
+++ b/t/t6023-merge-file.sh
@@ -0,0 +1,138 @@
+#!/bin/sh
+
+test_description='RCS merge replacement: merge-file'
+. ./test-lib.sh
+
+cat > orig.txt << EOF
+Dominus regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+EOF
+
+cat > new1.txt << EOF
+Dominus regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+Nam et si ambulavero in medio umbrae mortis,
+non timebo mala, quoniam tu mecum es:
+virga tua et baculus tuus ipsa me consolata sunt.
+EOF
+
+cat > new2.txt << EOF
+Dominus regit me, et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+EOF
+
+cat > new3.txt << EOF
+DOMINUS regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+EOF
+
+cat > new4.txt << EOF
+Dominus regit me, et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+EOF
+echo -n "propter nomen suum." >> new4.txt
+
+cp new1.txt test.txt
+test_expect_success "merge without conflict" \
+ "git-merge-file test.txt orig.txt new2.txt"
+
+cp new1.txt test2.txt
+test_expect_success "merge without conflict (missing LF at EOF)" \
+ "git-merge-file test2.txt orig.txt new2.txt"
+
+test_expect_success "merge result added missing LF" \
+ "diff -u test.txt test2.txt"
+
+cp test.txt backup.txt
+test_expect_failure "merge with conflicts" \
+ "git-merge-file test.txt orig.txt new3.txt"
+
+cat > expect.txt << EOF
+<<<<<<< test.txt
+Dominus regit me, et nihil mihi deerit.
+=======
+DOMINUS regit me,
+et nihil mihi deerit.
+>>>>>>> new3.txt
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+Nam et si ambulavero in medio umbrae mortis,
+non timebo mala, quoniam tu mecum es:
+virga tua et baculus tuus ipsa me consolata sunt.
+EOF
+
+test_expect_success "expected conflict markers" "diff -u test.txt expect.txt"
+
+cp backup.txt test.txt
+test_expect_failure "merge with conflicts, using -L" \
+ "git-merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
+
+cat > expect.txt << EOF
+<<<<<<< 1
+Dominus regit me, et nihil mihi deerit.
+=======
+DOMINUS regit me,
+et nihil mihi deerit.
+>>>>>>> new3.txt
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+Nam et si ambulavero in medio umbrae mortis,
+non timebo mala, quoniam tu mecum es:
+virga tua et baculus tuus ipsa me consolata sunt.
+EOF
+
+test_expect_success "expected conflict markers, with -L" \
+ "diff -u test.txt expect.txt"
+
+sed "s/ tu / TU /" < new1.txt > new5.txt
+test_expect_failure "conflict in removed tail" \
+ "git-merge-file -p orig.txt new1.txt new5.txt > out"
+
+cat > expect << EOF
+Dominus regit me,
+et nihil mihi deerit.
+In loco pascuae ibi me collocavit,
+super aquam refectionis educavit me;
+animam meam convertit,
+deduxit me super semitas jusitiae,
+propter nomen suum.
+<<<<<<< orig.txt
+=======
+Nam et si ambulavero in medio umbrae mortis,
+non timebo mala, quoniam TU mecum es:
+virga tua et baculus tuus ipsa me consolata sunt.
+>>>>>>> new5.txt
+EOF
+
+test_expect_success "expected conflict markers" "diff -u expect out"
+
+test_done
+
diff --git a/t/t6023-merge-rename-nocruft.sh b/t/t6023-merge-rename-nocruft.sh
new file mode 100755
index 0000000000..69c66cf6fa
--- /dev/null
+++ b/t/t6023-merge-rename-nocruft.sh
@@ -0,0 +1,97 @@
+#!/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 has A and M" &&
+git branch white &&
+git branch red &&
+
+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 &&
+echo created by red >R &&
+git update-index --add R &&
+git commit -m "red creates R" &&
+
+git checkout master'
+
+# This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae
+test_expect_success 'merge white into red (A->B,M->N)' \
+'
+ git checkout -b red-white red &&
+ git merge white &&
+ git write-tree >/dev/null || {
+ echo "BAD: merge did not complete"
+ return 1
+ }
+
+ test -f B || {
+ echo "BAD: B does not exist in working directory"
+ return 1
+ }
+ test -f N || {
+ echo "BAD: N does not exist in working directory"
+ return 1
+ }
+ test -f R || {
+ echo "BAD: R does not exist in working directory"
+ return 1
+ }
+
+ test -f A && {
+ echo "BAD: A still exists in working directory"
+ return 1
+ }
+ test -f M && {
+ echo "BAD: M still exists in working directory"
+ return 1
+ }
+ return 0
+'
+
+test_done
diff --git a/t/t6024-recursive-merge.sh b/t/t6024-recursive-merge.sh
new file mode 100644
index 0000000000..31b96257b4
--- /dev/null
+++ b/t/t6024-recursive-merge.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+test_description='Test merge without common ancestors'
+. ./test-lib.sh
+
+# This scenario is based on a real-world repository of Shawn Pearce.
+
+# 1 - A - D - F
+# \ X /
+# B X
+# X \
+# 2 - C - E - G
+
+GIT_COMMITTER_DATE="2006-12-12 23:28:00 +0100"
+export GIT_COMMITTER_DATE
+
+test_expect_success "setup tests" '
+echo 1 > a1 &&
+git add a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:00" git commit -m 1 a1 &&
+
+git checkout -b A master &&
+echo A > a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:01" git commit -m A a1 &&
+
+git checkout -b B master &&
+echo B > a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:02" git commit -m B a1 &&
+
+git checkout -b D A &&
+git-rev-parse B > .git/MERGE_HEAD &&
+echo D > a1 &&
+git update-index a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:03" git commit -m D &&
+
+git symbolic-ref HEAD refs/heads/other &&
+echo 2 > a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:04" git commit -m 2 a1 &&
+
+git checkout -b C &&
+echo C > a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:05" git commit -m C a1 &&
+
+git checkout -b E C &&
+git-rev-parse B > .git/MERGE_HEAD &&
+echo E > a1 &&
+git update-index a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:06" git commit -m E &&
+
+git checkout -b G E &&
+git-rev-parse A > .git/MERGE_HEAD &&
+echo G > a1 &&
+git update-index a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:07" git commit -m G &&
+
+git checkout -b F D &&
+git-rev-parse C > .git/MERGE_HEAD &&
+echo F > a1 &&
+git update-index a1 &&
+GIT_AUTHOR_DATE="2006-12-12 23:00:08" git commit -m F
+'
+
+test_expect_failure "combined merge conflicts" "git merge -m final G"
+
+cat > expect << EOF
+<<<<<<< HEAD:a1
+F
+=======
+G
+>>>>>>> G:a1
+EOF
+
+test_expect_success "result contains a conflict" "diff -u expect a1"
+
+git ls-files --stage > out
+cat > expect << EOF
+100644 da056ce14a2241509897fa68bb2b3b6e6194ef9e 1 a1
+100644 cf84443e49e1b366fac938711ddf4be2d4d1d9e9 2 a1
+100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
+EOF
+
+test_expect_success "virtual trees were processed" "diff -u expect out"
+
+test_done
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index b7fcdb390c..344033249c 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -86,4 +86,36 @@ test_expect_success \
'move into "."' \
'git-mv path1/path2/ .'
+test_expect_success "Michael Cassar's test case" '
+ rm -fr .git papers partA &&
+ git init &&
+ 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)
+ }
+'
+
+rm -fr papers partA path?
+
+test_expect_success "Sergey Vlasov's test case" '
+ rm -fr .git &&
+ git init &&
+ mkdir ab &&
+ date >ab.c &&
+ date >ab/d &&
+ git add ab.c ab &&
+ git commit -m 'initial' &&
+ git mv ab a
+'
+
test_done
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index b64e8b7d77..085d4a096b 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/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 34a3ccd31c..040da92756 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -19,180 +19,168 @@ esac
echo 'define NO_SVN_TESTS to skip git-svn tests'
-mkdir import
-cd import
-
-echo foo > foo
-if test -z "$NO_SYMLINK"
-then
- ln -s foo foo.link
-fi
-mkdir -p dir/a/b/c/d/e
-echo 'deep dir' > dir/a/b/c/d/e/file
-mkdir -p bar
-echo 'zzz' > bar/zzz
-echo '#!/bin/sh' > exec.sh
-chmod +x exec.sh
-svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
-
-cd ..
-rm -rf import
-
test_expect_success \
- 'initialize git-svn' \
- "git-svn init $svnrepo"
+ 'initialize git-svn' "
+ mkdir import &&
+ cd import &&
+ echo foo > foo &&
+ ln -s foo foo.link
+ mkdir -p dir/a/b/c/d/e &&
+ echo 'deep dir' > dir/a/b/c/d/e/file &&
+ mkdir bar &&
+ echo 'zzz' > bar/zzz &&
+ echo '#!/bin/sh' > exec.sh &&
+ chmod +x exec.sh &&
+ svn import -m 'import for git-svn' . $svnrepo >/dev/null &&
+ cd .. &&
+ rm -rf import &&
+ git-svn init $svnrepo"
test_expect_success \
'import an SVN revision into git' \
'git-svn fetch'
-test_expect_success "checkout from svn" "svn co $svnrepo $SVN_TREE"
+test_expect_success "checkout from svn" "svn co $svnrepo '$SVN_TREE'"
name='try a deep --rmdir with a commit'
-git checkout -f -b mybranch remotes/git-svn
-mv dir/a/b/c/d/e/file dir/file
-cp dir/file file
-git update-index --add --remove dir/a/b/c/d/e/file dir/file file
-git commit -m "$name"
-
-test_expect_success "$name" \
- "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch &&
- svn up $SVN_TREE &&
- test -d $SVN_TREE/dir && test ! -d $SVN_TREE/dir/a"
+test_expect_success "$name" "
+ git checkout -f -b mybranch remotes/git-svn &&
+ mv dir/a/b/c/d/e/file dir/file &&
+ cp dir/file file &&
+ git update-index --add --remove dir/a/b/c/d/e/file dir/file file &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch &&
+ svn up '$SVN_TREE' &&
+ test -d '$SVN_TREE'/dir && test ! -d '$SVN_TREE'/dir/a"
name='detect node change from file to directory #1'
-mkdir dir/new_file
-mv dir/file dir/new_file/file
-mv dir/new_file dir/file
-git update-index --remove dir/file
-git update-index --add dir/file/file
-git commit -m "$name"
-
-test_expect_failure "$name" \
- 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch' \
- || true
+test_expect_failure "$name" "
+ mkdir dir/new_file &&
+ mv dir/file dir/new_file/file &&
+ mv dir/new_file dir/file &&
+ git update-index --remove dir/file &&
+ git update-index --add dir/file/file &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch" || true
name='detect node change from directory to file #1'
-rm -rf dir $GIT_DIR/index
-git checkout -f -b mybranch2 remotes/git-svn
-mv bar/zzz zzz
-rm -rf bar
-mv zzz bar
-git update-index --remove -- bar/zzz
-git update-index --add -- bar
-git commit -m "$name"
-
-test_expect_failure "$name" \
- 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch2' \
- || true
+test_expect_failure "$name" "
+ rm -rf dir '$GIT_DIR'/index &&
+ git checkout -f -b mybranch2 remotes/git-svn &&
+ mv bar/zzz zzz &&
+ rm -rf bar &&
+ mv zzz bar &&
+ git update-index --remove -- bar/zzz &&
+ git update-index --add -- bar &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch2" || true
name='detect node change from file to directory #2'
-rm -f $GIT_DIR/index
-git checkout -f -b mybranch3 remotes/git-svn
-rm bar/zzz
-git-update-index --remove bar/zzz
-mkdir bar/zzz
-echo yyy > bar/zzz/yyy
-git-update-index --add bar/zzz/yyy
-git commit -m "$name"
-
-test_expect_failure "$name" \
- 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch3' \
- || true
+test_expect_failure "$name" "
+ rm -f '$GIT_DIR'/index &&
+ git checkout -f -b mybranch3 remotes/git-svn &&
+ rm bar/zzz &&
+ git-update-index --remove bar/zzz &&
+ mkdir bar/zzz &&
+ echo yyy > bar/zzz/yyy &&
+ git-update-index --add bar/zzz/yyy &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch3" || true
name='detect node change from directory to file #2'
-rm -f $GIT_DIR/index
-git checkout -f -b mybranch4 remotes/git-svn
-rm -rf dir
-git update-index --remove -- dir/file
-touch dir
-echo asdf > dir
-git update-index --add -- dir
-git commit -m "$name"
-
-test_expect_failure "$name" \
- 'git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch4' \
- || true
+test_expect_failure "$name" "
+ rm -f '$GIT_DIR'/index &&
+ git checkout -f -b mybranch4 remotes/git-svn &&
+ rm -rf dir &&
+ git update-index --remove -- dir/file &&
+ touch dir &&
+ echo asdf > dir &&
+ git update-index --add -- dir &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch4" || true
name='remove executable bit from a file'
-rm -f $GIT_DIR/index
-git checkout -f -b mybranch5 remotes/git-svn
-chmod -x exec.sh
-git update-index exec.sh
-git commit -m "$name"
-
-test_expect_success "$name" \
- "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
- svn up $SVN_TREE &&
- test ! -x $SVN_TREE/exec.sh"
+test_expect_success "$name" "
+ rm -f '$GIT_DIR'/index &&
+ git checkout -f -b mybranch5 remotes/git-svn &&
+ chmod -x exec.sh &&
+ git update-index exec.sh &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch5 &&
+ svn up '$SVN_TREE' &&
+ test ! -x '$SVN_TREE'/exec.sh"
name='add executable bit back file'
-chmod +x exec.sh
-git update-index exec.sh
-git commit -m "$name"
-
-test_expect_success "$name" \
- "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
- svn up $SVN_TREE &&
- test -x $SVN_TREE/exec.sh"
-
-
-
-if test -z "$NO_SYMLINK"
-then
- name='executable file becomes a symlink to bar/zzz (file)'
- rm exec.sh
- ln -s bar/zzz exec.sh
- git update-index exec.sh
- git commit -m "$name"
-
- test_expect_success "$name" \
- "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
- svn up $SVN_TREE &&
- test -L $SVN_TREE/exec.sh"
-
- name='new symlink is added to a file that was also just made executable'
- chmod +x bar/zzz
- ln -s bar/zzz exec-2.sh
- git update-index --add bar/zzz exec-2.sh
- git commit -m "$name"
-
- test_expect_success "$name" \
- "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
- svn up $SVN_TREE &&
- test -x $SVN_TREE/bar/zzz &&
- test -L $SVN_TREE/exec-2.sh"
-
- name='modify a symlink to become a file'
- echo git help > help || true
- rm exec-2.sh
- cp help exec-2.sh
- git update-index exec-2.sh
- git commit -m "$name"
-
- test_expect_success "$name" \
- "git-svn commit --find-copies-harder --rmdir remotes/git-svn..mybranch5 &&
- svn up $SVN_TREE &&
- test -f $SVN_TREE/exec-2.sh &&
- test ! -L $SVN_TREE/exec-2.sh &&
- diff -u help $SVN_TREE/exec-2.sh"
-fi
-
+test_expect_success "$name" "
+ chmod +x exec.sh &&
+ git update-index exec.sh &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch5 &&
+ svn up '$SVN_TREE' &&
+ test -x '$SVN_TREE'/exec.sh"
+
+
+name='executable file becomes a symlink to bar/zzz (file)'
+test_expect_success "$name" "
+ rm exec.sh &&
+ ln -s bar/zzz exec.sh &&
+ git update-index exec.sh &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch5 &&
+ svn up '$SVN_TREE' &&
+ test -L '$SVN_TREE'/exec.sh"
+
+name='new symlink is added to a file that was also just made executable'
+
+test_expect_success "$name" "
+ chmod +x bar/zzz &&
+ ln -s bar/zzz exec-2.sh &&
+ git update-index --add bar/zzz exec-2.sh &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch5 &&
+ svn up '$SVN_TREE' &&
+ test -x '$SVN_TREE'/bar/zzz &&
+ test -L '$SVN_TREE'/exec-2.sh"
+
+name='modify a symlink to become a file'
+test_expect_success "$name" "
+ echo git help > help || true &&
+ rm exec-2.sh &&
+ cp help exec-2.sh &&
+ git update-index exec-2.sh &&
+ git commit -m '$name' &&
+ git-svn set-tree --find-copies-harder --rmdir \
+ remotes/git-svn..mybranch5 &&
+ svn up '$SVN_TREE' &&
+ test -f '$SVN_TREE'/exec-2.sh &&
+ test ! -L '$SVN_TREE'/exec-2.sh &&
+ diff -u help $SVN_TREE/exec-2.sh"
if test "$have_utf8" = t
then
name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
- echo '# hello' >> exec-2.sh
- git update-index exec-2.sh
- git commit -m 'éï∏'
- export LC_ALL="$GIT_SVN_LC_ALL"
- test_expect_success "$name" "git-svn commit HEAD"
+ LC_ALL="$GIT_SVN_LC_ALL"
+ export LC_ALL
+ test_expect_success "$name" "
+ echo '# hello' >> exec-2.sh &&
+ git update-index exec-2.sh &&
+ git commit -m 'éï∏' &&
+ git-svn set-tree HEAD"
unset LC_ALL
else
echo "UTF-8 locale not set, test skipped ($GIT_SVN_LC_ALL)"
@@ -207,12 +195,6 @@ test_expect_success "$name" \
git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
diff -u a b"
-if test -n "$NO_SYMLINK"
-then
- test_done
- exit 0
-fi
-
name='check imported tree checksums expected tree checksums'
rm -f expected
if test "$have_utf8" = t
@@ -228,6 +210,9 @@ tree 56a30b966619b863674f5978696f4a3594f2fca9
tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
EOF
+
+echo tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 >> expected
+
test_expect_success "$name" "diff -u a expected"
test_done
diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh
index a5a235f100..46fcec50a5 100755
--- a/t/t9101-git-svn-props.sh
+++ b/t/t9101-git-svn-props.sh
@@ -57,13 +57,10 @@ test_expect_success 'setup some commits to svn' \
'cd test_wc &&
echo Greetings >> kw.c &&
svn commit -m "Not yet an Id" &&
- svn up &&
echo Hello world >> kw.c &&
svn commit -m "Modified file, but still not yet an Id" &&
- svn up &&
svn propset svn:keywords Id kw.c &&
- svn commit -m "Propset Id" &&
- svn up &&
+ svn commit -m "Propset Id"
cd ..'
test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
@@ -74,7 +71,7 @@ test_expect_success "$name" \
'git checkout -b mybranch remotes/git-svn &&
echo Hi again >> kw.c &&
git commit -a -m "test keywoards ignoring" &&
- git-svn commit remotes/git-svn..mybranch &&
+ git-svn set-tree remotes/git-svn..mybranch &&
git pull . remotes/git-svn'
expect='/* $Id$ */'
@@ -86,8 +83,7 @@ test_expect_success "propset CR on crlf files" \
svn propset svn:eol-style CR empty &&
svn propset svn:eol-style CR crlf &&
svn propset svn:eol-style CR ne_crlf &&
- svn commit -m "propset CR on crlf files" &&
- svn up &&
+ svn commit -m "propset CR on crlf files"
cd ..'
test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
@@ -111,8 +107,7 @@ cd test_wc
svn propset svn:eol-style CRLF ne_cr &&
svn propset svn:keywords Id cr &&
svn propset svn:keywords Id ne_cr &&
- svn commit -m "propset CRLF on cr files" &&
- svn up'
+ svn commit -m "propset CRLF on cr files"'
cd ..
test_expect_success 'fetch and pull latest from svn' \
'git-svn fetch && git pull . remotes/git-svn'
diff --git a/t/t9102-git-svn-deep-rmdir.sh b/t/t9102-git-svn-deep-rmdir.sh
index d693d183c8..572aaedc06 100755
--- a/t/t9102-git-svn-deep-rmdir.sh
+++ b/t/t9102-git-svn-deep-rmdir.sh
@@ -21,7 +21,7 @@ test_expect_success 'mirror via git-svn' "
test_expect_success 'Try a commit on rmdir' "
git rm -f deeply/nested/directory/number/2/another &&
git commit -a -m 'remove another' &&
- git-svn commit --rmdir HEAD &&
+ git-svn set-tree --rmdir HEAD &&
svn ls -R $svnrepo | grep ^deeply/nested/directory/number/1
"
diff --git a/t/t9103-git-svn-graft-branches.sh b/t/t9103-git-svn-graft-branches.sh
index cc62d4ece8..b5f7677021 100755
--- a/t/t9103-git-svn-graft-branches.sh
+++ b/t/t9103-git-svn-graft-branches.sh
@@ -1,6 +1,8 @@
test_description='git-svn graft-branches'
. ./lib-git-svn.sh
+svnrepo="$svnrepo/test-git-svn"
+
test_expect_success 'initialize repo' "
mkdir import &&
cd import &&
@@ -14,25 +16,19 @@ test_expect_success 'initialize repo' "
cd wc &&
echo feedme >> branches/a/readme &&
svn commit -m hungry &&
- svn up &&
cd trunk &&
svn merge -r3:4 $svnrepo/branches/a &&
svn commit -m 'merge with a' &&
cd ../.. &&
- svn log -v $svnrepo &&
- git-svn init -i trunk $svnrepo/trunk &&
- git-svn init -i a $svnrepo/branches/a &&
- git-svn init -i tags/a $svnrepo/tags/a &&
- git-svn fetch -i tags/a &&
- git-svn fetch -i a &&
- git-svn fetch -i trunk
+ git-svn multi-init $svnrepo -T trunk -b branches -t tags &&
+ git-svn multi-fetch
"
r1=`git-rev-list remotes/trunk | tail -n1`
r2=`git-rev-list remotes/tags/a | tail -n1`
r3=`git-rev-list remotes/a | tail -n1`
-r4=`git-rev-list remotes/a | head -n1`
-r5=`git-rev-list remotes/trunk | head -n1`
+r4=`git-rev-parse remotes/a`
+r5=`git-rev-parse remotes/trunk`
test_expect_success 'test graft-branches regexes and copies' "
test -n "$r1" &&
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index 01488ff78a..8d2e2fec39 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -6,13 +6,6 @@
test_description='git-svn --follow-parent fetching'
. ./lib-git-svn.sh
-if test -n "$GIT_SVN_NO_LIB" && test "$GIT_SVN_NO_LIB" -ne 0
-then
- echo 'Skipping: --follow-parent needs SVN libraries'
- test_done
- exit 0
-fi
-
test_expect_success 'initialize repo' "
mkdir import &&
cd import &&
diff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh
index f994b72f80..6323c7e3ac 100755
--- a/t/t9105-git-svn-commit-diff.sh
+++ b/t/t9105-git-svn-commit-diff.sh
@@ -4,13 +4,6 @@
test_description='git-svn commit-diff'
. ./lib-git-svn.sh
-if test -n "$GIT_SVN_NO_LIB" && test "$GIT_SVN_NO_LIB" -ne 0
-then
- echo 'Skipping: commit-diff needs SVN libraries'
- test_done
- exit 0
-fi
-
test_expect_success 'initialize repo' "
mkdir import &&
cd import &&
@@ -33,7 +26,7 @@ prev=`git rev-parse --verify HEAD^1`
test_expect_success 'test the commit-diff command' "
test -n '$prev' && test -n '$head' &&
- git-svn commit-diff '$prev' '$head' '$svnrepo' &&
+ git-svn commit-diff -r1 '$prev' '$head' '$svnrepo' &&
svn co $svnrepo wc &&
cmp readme wc/readme
"
diff --git a/t/t9106-git-svn-commit-diff-clobber.sh b/t/t9106-git-svn-commit-diff-clobber.sh
new file mode 100755
index 0000000000..59b6425ce4
--- /dev/null
+++ b/t/t9106-git-svn-commit-diff-clobber.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Eric Wong
+test_description='git-svn commit-diff clobber'
+. ./lib-git-svn.sh
+
+test_expect_success 'initialize repo' "
+ mkdir import &&
+ cd import &&
+ echo initial > file &&
+ svn import -m 'initial' . $svnrepo &&
+ cd .. &&
+ echo initial > file &&
+ git update-index --add file &&
+ git commit -a -m 'initial'
+ "
+test_expect_success 'commit change from svn side' "
+ svn co $svnrepo t.svn &&
+ cd t.svn &&
+ echo second line from svn >> file &&
+ svn commit -m 'second line from svn' &&
+ cd .. &&
+ rm -rf t.svn
+ "
+
+test_expect_failure 'commit conflicting change from git' "
+ echo second line from git >> file &&
+ git commit -a -m 'second line from git' &&
+ git-svn commit-diff -r1 HEAD~1 HEAD $svnrepo
+ " || true
+
+test_expect_success 'commit complementing change from git' "
+ git reset --hard HEAD~1 &&
+ echo second line from svn >> file &&
+ git commit -a -m 'second line from svn' &&
+ echo third line from git >> file &&
+ git commit -a -m 'third line from git' &&
+ git-svn commit-diff -r2 HEAD~1 HEAD $svnrepo
+ "
+
+test_expect_failure 'dcommit fails to commit because of conflict' "
+ git-svn init $svnrepo &&
+ git-svn fetch &&
+ git reset --hard refs/remotes/git-svn &&
+ svn co $svnrepo t.svn &&
+ cd t.svn &&
+ echo fourth line from svn >> file &&
+ svn commit -m 'fourth line from svn' &&
+ cd .. &&
+ rm -rf t.svn &&
+ echo 'fourth line from git' >> file &&
+ git commit -a -m 'fourth line from git' &&
+ git-svn dcommit
+ " || true
+
+test_expect_success 'dcommit does the svn equivalent of an index merge' "
+ git reset --hard refs/remotes/git-svn &&
+ echo 'index merge' > file2 &&
+ git update-index --add file2 &&
+ git commit -a -m 'index merge' &&
+ echo 'more changes' >> file2 &&
+ git update-index file2 &&
+ git commit -a -m 'more changes' &&
+ git-svn dcommit
+ "
+
+test_done
diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh
new file mode 100755
index 0000000000..315119abff
--- /dev/null
+++ b/t/t9200-git-cvsexportcommit.sh
@@ -0,0 +1,215 @@
+#!/bin/bash
+#
+# Copyright (c) Robin Rosenberg
+#
+test_description='CVS export comit. '
+
+. ./test-lib.sh
+
+cvs >/dev/null 2>&1
+if test $? -ne 1
+then
+ test_expect_success 'skipping git-cvsexportcommit tests, cvs not found' :
+ test_done
+ exit
+fi
+
+CVSROOT=$(pwd)/cvsroot
+CVSWORK=$(pwd)/cvswork
+GIT_DIR=$(pwd)/.git
+export CVSROOT CVSWORK GIT_DIR
+
+rm -rf "$CVSROOT" "$CVSWORK"
+mkdir "$CVSROOT" &&
+cvs init &&
+cvs -Q co -d "$CVSWORK" . &&
+echo >empty &&
+git add empty &&
+git commit -q -a -m "Initial" 2>/dev/null ||
+exit 1
+
+test_expect_success \
+ 'New file' \
+ 'mkdir A B C D E F &&
+ echo hello1 >A/newfile1.txt &&
+ echo hello2 >B/newfile2.txt &&
+ cp ../test9200a.png C/newfile3.png &&
+ cp ../test9200a.png D/newfile4.png &&
+ 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 &&
+ test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.1/" &&
+ test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "newfile2.txt/1.1/" &&
+ test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "newfile3.png/1.1/-kb" &&
+ test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.1/-kb" &&
+ diff A/newfile1.txt ../A/newfile1.txt &&
+ diff B/newfile2.txt ../B/newfile2.txt &&
+ diff C/newfile3.png ../C/newfile3.png &&
+ diff D/newfile4.png ../D/newfile4.png
+ )'
+
+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 &&
+ cp ../test9200b.png D/newfile4.png &&
+ cp ../test9200a.png F/newfile6.png &&
+ 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 &&
+ test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
+ test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "newfile4.png/1.2/-kb" &&
+ test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
+ test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
+ diff A/newfile1.txt ../A/newfile1.txt &&
+ diff D/newfile4.png ../D/newfile4.png &&
+ diff E/newfile5.txt ../E/newfile5.txt &&
+ diff F/newfile6.png ../F/newfile6.png
+ )'
+
+# Should fail (but only on the git-cvsexportcommit stage)
+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" &&
+ ! git cvsexportcommit -c $id
+ )'
+
+#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" &&
+# ! git cvsexportcommit -c $id
+# )'
+
+# 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' \
+ 'git reset --hard HEAD^^ &&
+ 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 &&
+ test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "newfile1.txt/1.2/" &&
+ test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
+ test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
+ diff A/newfile1.txt ../A/newfile1.txt &&
+ diff E/newfile5.txt ../E/newfile5.txt &&
+ diff F/newfile6.png ../F/newfile6.png
+ )'
+
+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 &&
+ test "$(echo $(sort A/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort B/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort C/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort D/CVS/Entries|cut -d/ -f2,3,5))" = "" &&
+ test "$(echo $(sort E/CVS/Entries|cut -d/ -f2,3,5))" = "newfile5.txt/1.1/" &&
+ test "$(echo $(sort F/CVS/Entries|cut -d/ -f2,3,5))" = "newfile6.png/1.1/-kb" &&
+ diff E/newfile5.txt ../E/newfile5.txt &&
+ diff F/newfile6.png ../F/newfile6.png
+ )'
+
+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" && \
+ cp ../test9200a.png "G g/with spaces.png" && \
+ git add "G g/with spaces.png" &&
+ git commit -a -m "With spaces" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git-cvsexportcommit -c $id &&
+ test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.1/-kb with spaces.txt/1.1/"
+ )'
+
+test_expect_success \
+ 'Update file with spaces in file name' \
+ 'echo Ok then >>"G g/with spaces.txt" &&
+ cat ../test9200a.png >>"G g/with spaces.png" && \
+ git add "G g/with spaces.png" &&
+ git commit -a -m "Update with spaces" &&
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git-cvsexportcommit -c $id
+ test "$(echo $(sort "G g/CVS/Entries"|cut -d/ -f2,3,5))" = "with spaces.png/1.2/-kb with spaces.txt/1.2/"
+ )'
+
+# This test contains ISO-8859-1 characters
+test_expect_success \
+ 'File with non-ascii file name' \
+ '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////grdetsgrdet.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////grdetsgrdet.txt &&
+ cp ../test9200a.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////grdetsgrdet.png &&
+ 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////grdetsgrdet.png &&
+ git commit -a -m "Gr det s gr det" && \
+ id=$(git rev-list --max-count=1 HEAD) &&
+ (cd "$CVSWORK" &&
+ git-cvsexportcommit -v -c $id &&
+ test "$(echo $(sort /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////CVS/Entries|cut -d/ -f2,3,5))" = "grdetsgrdet.png/1.1/-kb grdetsgrdet.txt/1.1/"
+ )'
+
+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" &&
+ ! git-cvsexportcommit -c $id
+ )'
+
+test_expect_success \
+ '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" &&
+ git-cvsexportcommit -c HEAD
+ test -x G/on &&
+ ! test -x G/off
+ )'
+
+test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 470a909891..8e3ee6cd7b 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -28,13 +28,21 @@ unset GIT_DIR
unset GIT_EXTERNAL_DIFF
unset GIT_INDEX_FILE
unset GIT_OBJECT_DIRECTORY
-unset GIT_TRACE
unset SHA1_FILE_DIRECTORIES
unset SHA1_FILE_DIRECTORY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR VISUAL
+case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
+ 1|2|true)
+ echo "* warning: Some tests will not work if GIT_TRACE" \
+ "is set as to trace on STDERR ! *"
+ echo "* warning: Please set GIT_TRACE to something" \
+ "other than 1, 2 or true ! *"
+ ;;
+esac
+
# Each test should start with something like this, after copyright notices:
#
# test_description='Description of this test...
@@ -68,7 +76,8 @@ do
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
verbose=t; shift ;;
--no-python)
- no_python=t; shift ;;
+ # noop now...
+ shift ;;
*)
break ;;
esac
@@ -87,6 +96,17 @@ test_count=0
trap 'echo >&5 "FATAL: Unexpected exit with code $?"; exit 1' exit
+test_tick () {
+ if test -z "${test_tick+set}"
+ then
+ test_tick=1112911993
+ else
+ test_tick=$(($test_tick + 60))
+ fi
+ GIT_COMMITTER_DATE="$test_tick -0700"
+ GIT_AUTHOR_DATE="$test_tick -0700"
+ export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
+}
# You are not expected to call test_ok_ and test_failure_ directly, use
# the text_expect_* functions instead.
@@ -116,43 +136,79 @@ test_run_ () {
return 0
}
+test_skip () {
+ this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
+ this_test="$this_test.$(expr "$test_count" + 1)"
+ to_skip=
+ for skp in $GIT_SKIP_TESTS
+ do
+ case "$this_test" in
+ $skp)
+ to_skip=t
+ esac
+ done
+ case "$to_skip" in
+ t)
+ say >&3 "skipping test: $@"
+ test_count=$(expr "$test_count" + 1)
+ say "skip $test_count: $1"
+ : true
+ ;;
+ *)
+ false
+ ;;
+ esac
+}
+
test_expect_failure () {
test "$#" = 2 ||
error "bug in the test script: not 2 parameters to test-expect-failure"
- say >&3 "expecting failure: $2"
- test_run_ "$2"
- if [ "$?" = 0 -a "$eval_ret" != 0 ]
+ if ! test_skip "$@"
then
- test_ok_ "$1"
- else
- test_failure_ "$@"
+ say >&3 "expecting failure: $2"
+ test_run_ "$2"
+ if [ "$?" = 0 -a "$eval_ret" != 0 -a "$eval_ret" -lt 129 ]
+ then
+ test_ok_ "$1"
+ else
+ test_failure_ "$@"
+ fi
fi
+ echo >&3 ""
}
test_expect_success () {
test "$#" = 2 ||
error "bug in the test script: not 2 parameters to test-expect-success"
- say >&3 "expecting success: $2"
- test_run_ "$2"
- if [ "$?" = 0 -a "$eval_ret" = 0 ]
+ if ! test_skip "$@"
then
- test_ok_ "$1"
- else
- test_failure_ "$@"
+ say >&3 "expecting success: $2"
+ test_run_ "$2"
+ if [ "$?" = 0 -a "$eval_ret" = 0 ]
+ then
+ test_ok_ "$1"
+ else
+ test_failure_ "$@"
+ fi
fi
+ echo >&3 ""
}
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" ]
+ if ! test_skip "$@"
then
- test_ok_ "$2"
- else
- test_failure_ "$@"
+ say >&3 "expecting exit code $1: $3"
+ test_run_ "$3"
+ if [ "$?" = 0 -a "$eval_ret" = "$1" ]
+ then
+ test_ok_ "$2"
+ else
+ test_failure_ "$@"
+ fi
fi
+ echo >&3 ""
}
# Most tests can use the created repository, but some amy need to create more.
@@ -164,8 +220,8 @@ test_create_repo () {
repo="$1"
mkdir "$repo"
cd "$repo" || error "Cannot setup test environment"
- "$GIT_EXEC_PATH/git" init-db --template=$GIT_EXEC_PATH/templates/blt/ 2>/dev/null ||
- error "cannot run git init-db -- have you built things yet?"
+ "$GIT_EXEC_PATH/git" init --template=$GIT_EXEC_PATH/templates/blt/ >/dev/null 2>&1 ||
+ error "cannot run git init -- have you built things yet?"
mv .git/hooks .git/hooks-disabled
cd "$owd"
}
@@ -196,20 +252,12 @@ test_done () {
# t/ subdirectory and are run in trash subdirectory.
PATH=$(pwd)/..:$PATH
GIT_EXEC_PATH=$(pwd)/..
-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
-}
+GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
+HOME=$(pwd)/trash
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR HOME
+
+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?"
}
@@ -219,3 +267,22 @@ test=trash
rm -fr "$test"
test_create_repo $test
cd "$test"
+
+this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
+for skp in $GIT_SKIP_TESTS
+do
+ to_skip=
+ for skp in $GIT_SKIP_TESTS
+ do
+ case "$this_test" in
+ $skp)
+ to_skip=t
+ esac
+ done
+ case "$to_skip" in
+ t)
+ say >&3 "skipping test $this_test altogether"
+ say "skip all tests in $this_test"
+ test_done
+ esac
+done
diff --git a/t/test9200a.png b/t/test9200a.png
new file mode 100644
index 0000000000..7b181d15ce
--- /dev/null
+++ b/t/test9200a.png
Binary files differ
diff --git a/t/test9200b.png b/t/test9200b.png
new file mode 100644
index 0000000000..ac22ccbd3e
--- /dev/null
+++ b/t/test9200b.png
Binary files differ