summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/annotate-tests.sh12
-rw-r--r--t/gitweb-lib.sh2
-rw-r--r--t/lib-httpd.sh3
-rw-r--r--t/lib-httpd/apache.conf36
-rw-r--r--t/lib-httpd/passwd1
-rwxr-xr-xt/t0004-unwritable.sh52
-rwxr-xr-xt/t0050-filesystem.sh4
-rwxr-xr-xt/t1011-read-tree-sparse-checkout.sh10
-rwxr-xr-xt/t1412-reflog-loop.sh34
-rwxr-xr-xt/t1503-rev-parse-verify.sh4
-rwxr-xr-xt/t1509-root-worktree.sh28
-rwxr-xr-xt/t3020-ls-files-error-unmatch.sh1
-rwxr-xr-xt/t3402-rebase-merge.sh21
-rwxr-xr-xt/t3404-rebase-interactive.sh3
-rwxr-xr-xt/t3407-rebase-abort.sh12
-rwxr-xr-xt/t3415-rebase-autosquash.sh6
-rwxr-xr-xt/t3419-rebase-patch-id.sh109
-rwxr-xr-xt/t3501-revert-cherry-pick.sh10
-rwxr-xr-xt/t3506-cherry-pick-ff.sh10
-rwxr-xr-xt/t3903-stash.sh69
-rwxr-xr-xt/t4011-diff-symlink.sh26
-rwxr-xr-xt/t4012-diff-binary.sh4
-rwxr-xr-xt/t4015-diff-whitespace.sh37
-rwxr-xr-xt/t4018-diff-funcname.sh2
-rwxr-xr-xt/t4019-diff-wserror.sh9
-rwxr-xr-xt/t4034-diff-words.sh72
-rwxr-xr-xt/t4103-apply-binary.sh27
-rwxr-xr-xt/t4120-apply-popt.sh26
-rwxr-xr-xt/t4132-apply-removal.sh2
-rwxr-xr-xt/t4135-apply-weird-filenames.sh16
-rw-r--r--t/t4135/damaged-tz.diff5
-rw-r--r--t/t4135/funny-tz.diff5
-rwxr-xr-xt/t4151-am-abort.sh9
-rwxr-xr-xt/t4202-log.sh9
-rwxr-xr-xt/t4203-mailmap.sh67
-rwxr-xr-xt/t5407-post-rewrite-hook.sh18
-rwxr-xr-xt/t5550-http-fetch.sh23
-rwxr-xr-xt/t5551-http-fetch.sh8
-rwxr-xr-xt/t5560-http-backend-noserver.sh8
-rwxr-xr-xt/t556x_common4
-rwxr-xr-xt/t6006-rev-list-format.sh8
-rwxr-xr-xt/t6023-merge-file.sh8
-rwxr-xr-xt/t6050-replace.sh13
-rwxr-xr-xt/t7004-tag.sh66
-rwxr-xr-xt/t7006/test-terminal.perl1
-rwxr-xr-xt/t7403-submodule-sync.sh12
-rwxr-xr-xt/t7501-commit.sh4
-rwxr-xr-xt/t7607-merge-overwrite.sh118
-rwxr-xr-xt/t7609-merge-co-error-msgs.sh16
-rwxr-xr-xt/t8006-blame-textconv.sh83
-rwxr-xr-xt/t8007-cat-file-textconv.sh38
-rwxr-xr-xt/t9001-send-email.sh38
-rwxr-xr-xt/t9100-git-svn-basic.sh6
-rwxr-xr-xt/t9131-git-svn-empty-symlink.sh2
-rw-r--r--t/t9157-git-svn-fetch-merge.sh50
-rwxr-xr-xt/t9700/test.pl2
-rw-r--r--t/test-lib.sh53
57 files changed, 1125 insertions, 197 deletions
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index 396b965..141b60c 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -8,27 +8,27 @@ check_count () {
$PROG file $head >.result || return 1
cat .result | perl -e '
my %expect = (@ARGV);
- my %count = ();
+ my %count = map { $_ => 0 } keys %expect;
while (<STDIN>) {
if (/^[0-9a-f]+\t\(([^\t]+)\t/) {
my $author = $1;
for ($author) { s/^\s*//; s/\s*$//; }
- if (exists $expect{$author}) {
- $count{$author}++;
- }
+ $count{$author}++;
}
}
my $bad = 0;
while (my ($author, $count) = each %count) {
my $ok;
- if ($expect{$author} != $count) {
+ my $value = 0;
+ $value = $expect{$author} if defined $expect{$author};
+ if ($value != $count) {
$bad = 1;
$ok = "bad";
}
else {
$ok = "good";
}
- print STDERR "Author $author (expected $expect{$author}, attributed $count) $ok\n";
+ print STDERR "Author $author (expected $value, attributed $count) $ok\n";
}
exit($bad);
' "$@"
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
index 81ef2a0..1b9523d 100644
--- a/t/gitweb-lib.sh
+++ b/t/gitweb-lib.sh
@@ -80,7 +80,7 @@ if ! test_have_prereq PERL; then
test_done
fi
-perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || {
+perl -MEncode -e '$e="";decode_utf8($e, Encode::FB_CROAK)' >/dev/null 2>&1 || {
skip_all='skipping gitweb tests, perl version is too old'
test_done
}
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index e733f65..3f24384 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -75,12 +75,14 @@ fi
prepare_httpd() {
mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
+ cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
if test -n "$LIB_HTTPD_SSL"
then
HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT
+ AUTH_HTTPD_URL=https://user%40host:user%40host@127.0.0.1:$LIB_HTTPD_PORT
RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \
-config "$TEST_PATH/ssl.cnf" \
@@ -92,6 +94,7 @@ prepare_httpd() {
HTTPD_PARA="$HTTPD_PARA -DSSL"
else
HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
+ AUTH_HTTPD_URL=http://user%40host:user%40host@127.0.0.1:$LIB_HTTPD_PORT
fi
if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN"
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index 4961505..0a4cdfa 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -17,8 +17,33 @@ ErrorLog error.log
<IfModule !mod_env.c>
LoadModule env_module modules/mod_env.so
</IfModule>
+<IfModule !mod_rewrite.c>
+ LoadModule rewrite_module modules/mod_rewrite.so
+</IFModule>
+<IfModule !mod_version.c>
+ LoadModule version_module modules/mod_version.so
+</IfModule>
+
+<IfVersion < 2.1>
+<IfModule !mod_auth.c>
+ LoadModule auth_module modules/mod_auth.so
+</IfModule>
+</IfVersion>
+
+<IfVersion >= 2.1>
+<IfModule !mod_auth_basic.c>
+ LoadModule auth_basic_module modules/mod_auth_basic.so
+</IfModule>
+<IfModule !mod_authn_file.c>
+ LoadModule authn_file_module modules/mod_authn_file.so
+</IfModule>
+<IfModule !mod_authz_user.c>
+ LoadModule authz_user_module modules/mod_authz_user.so
+</IfModule>
+</IfVersion>
Alias /dumb/ www/
+Alias /auth/ www/auth/
<Location /smart/>
SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH}
@@ -36,6 +61,10 @@ ScriptAlias /smart_noexport/ ${GIT_EXEC_PATH}/git-http-backend/
Options ExecCGI
</Files>
+RewriteEngine on
+RewriteRule ^/smart-redir-perm/(.*)$ /smart/$1 [R=301]
+RewriteRule ^/smart-redir-temp/(.*)$ /smart/$1 [R=302]
+
<IfDefine SSL>
LoadModule ssl_module modules/mod_ssl.so
@@ -48,6 +77,13 @@ SSLMutex file:ssl_mutex
SSLEngine On
</IfDefine>
+<Location /auth/>
+ AuthType Basic
+ AuthName "git-auth"
+ AuthUserFile passwd
+ Require valid-user
+</Location>
+
<IfDefine DAV>
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
diff --git a/t/lib-httpd/passwd b/t/lib-httpd/passwd
new file mode 100644
index 0000000..f2fbcad
--- /dev/null
+++ b/t/lib-httpd/passwd
@@ -0,0 +1 @@
+user@host:nKpa8pZUHx/ic
diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
index 385b126..e3137d6 100755
--- a/t/t0004-unwritable.sh
+++ b/t/t0004-unwritable.sh
@@ -16,53 +16,29 @@ test_expect_success setup '
'
test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable repository' '
-
- (
- chmod a-w .git/objects .git/objects/?? &&
- test_must_fail git write-tree
- )
- status=$?
- chmod 775 .git/objects .git/objects/??
- (exit $status)
-
+ test_when_finished "chmod 775 .git/objects .git/objects/??" &&
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git write-tree
'
test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '
-
- (
- chmod a-w .git/objects .git/objects/?? &&
- test_must_fail git commit -m second
- )
- status=$?
- chmod 775 .git/objects .git/objects/??
- (exit $status)
-
+ test_when_finished "chmod 775 .git/objects .git/objects/??" &&
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git commit -m second
'
test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repository' '
-
- (
- echo 6O >file &&
- chmod a-w .git/objects .git/objects/?? &&
- test_must_fail git update-index file
- )
- status=$?
- chmod 775 .git/objects .git/objects/??
- (exit $status)
-
+ test_when_finished "chmod 775 .git/objects .git/objects/??" &&
+ echo 6O >file &&
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git update-index file
'
test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' '
-
- (
- echo b >file &&
- chmod a-w .git/objects .git/objects/?? &&
- test_must_fail git add file
- )
- status=$?
- chmod 775 .git/objects .git/objects/??
- (exit $status)
-
+ test_when_finished "chmod 775 .git/objects .git/objects/??" &&
+ echo b >file &&
+ chmod a-w .git/objects .git/objects/?? &&
+ test_must_fail git add file
'
test_done
diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh
index 41df6bc..07357ee 100755
--- a/t/t0050-filesystem.sh
+++ b/t/t0050-filesystem.sh
@@ -4,8 +4,8 @@ test_description='Various filesystem issues'
. ./test-lib.sh
-auml=`printf '\xc3\xa4'`
-aumlcdiar=`printf '\x61\xcc\x88'`
+auml=$(printf '\303\244')
+aumlcdiar=$(printf '\141\314\210')
case_insensitive=
unibad=
diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh
index 9a07de1..8008fa2 100755
--- a/t/t1011-read-tree-sparse-checkout.sh
+++ b/t/t1011-read-tree-sparse-checkout.sh
@@ -17,17 +17,19 @@ test_expect_success 'setup' '
cat >expected <<-\EOF &&
100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
+ 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 subsub/added
EOF
cat >expected.swt <<-\EOF &&
H init.t
H sub/added
+ H subsub/added
EOF
test_commit init &&
echo modified >>init.t &&
- mkdir sub &&
- touch sub/added &&
- git add init.t sub/added &&
+ mkdir sub subsub &&
+ touch sub/added subsub/added &&
+ git add init.t sub/added subsub/added &&
git commit -m "modified and added" &&
git tag top &&
git rm sub/added &&
@@ -81,6 +83,7 @@ test_expect_success 'match directories with trailing slash' '
cat >expected.swt-noinit <<-\EOF &&
S init.t
H sub/added
+ S subsub/added
EOF
echo sub/ > .git/info/sparse-checkout &&
@@ -105,6 +108,7 @@ test_expect_success 'checkout area changes' '
cat >expected.swt-nosub <<-\EOF &&
H init.t
S sub/added
+ S subsub/added
EOF
echo init.t >.git/info/sparse-checkout &&
diff --git a/t/t1412-reflog-loop.sh b/t/t1412-reflog-loop.sh
new file mode 100755
index 0000000..7f519e5
--- /dev/null
+++ b/t/t1412-reflog-loop.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+test_description='reflog walk shows repeated commits again'
+. ./test-lib.sh
+
+test_expect_success 'setup commits' '
+ test_tick &&
+ echo content >file && git add file && git commit -m one &&
+ git tag one &&
+ echo content >>file && git add file && git commit -m two &&
+ git tag two
+'
+
+test_expect_success 'setup reflog with alternating commits' '
+ git checkout -b topic &&
+ git reset one &&
+ git reset two &&
+ git reset one &&
+ git reset two
+'
+
+test_expect_success 'reflog shows all entries' '
+ cat >expect <<-\EOF
+ topic@{0} two: updating HEAD
+ topic@{1} one: updating HEAD
+ topic@{2} two: updating HEAD
+ topic@{3} one: updating HEAD
+ topic@{4} branch: Created from HEAD
+ EOF
+ git log -g --format="%gd %gs" topic >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index 100f857..813cc1b 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -106,8 +106,8 @@ test_expect_success 'use --default' '
test_expect_success 'master@{n} for various n' '
N=$(git reflog | wc -l) &&
- Nm1=$((N-1)) &&
- Np1=$((N+1)) &&
+ Nm1=$(($N-1)) &&
+ Np1=$(($N+1)) &&
git rev-parse --verify master@{0} &&
git rev-parse --verify master@{1} &&
git rev-parse --verify master@{$Nm1} &&
diff --git a/t/t1509-root-worktree.sh b/t/t1509-root-worktree.sh
index 7f60fd0..335420f 100755
--- a/t/t1509-root-worktree.sh
+++ b/t/t1509-root-worktree.sh
@@ -134,8 +134,8 @@ cat >ls.expected <<EOF
100644 $ONE_SHA1 0 me
EOF
-export GIT_DIR="$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=/
+GIT_DIR="$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=/ && export GIT_WORK_TREE
test_vars 'abs gitdir, root' "$GIT_DIR" "/" ""
test_foobar_root
@@ -154,24 +154,24 @@ say "GIT_DIR relative, GIT_WORK_TREE set"
test_expect_success 'go to /' 'cd /'
-export GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git"
-export GIT_WORK_TREE=/
+GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git" && export GIT_DIR
+GIT_WORK_TREE=/ && export GIT_WORK_TREE
test_vars 'rel gitdir, root' "$GIT_DIR" "/" ""
test_foobar_root
test_expect_success 'go to /foo' 'cd /foo'
-export GIT_DIR="../$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=/
+GIT_DIR="../$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=/ && export GIT_WORK_TREE
test_vars 'rel gitdir, foo' "$TRASH_DIRECTORY/.git" "/" "foo/"
test_foobar_foo
test_expect_success 'go to /foo/bar' 'cd /foo/bar'
-export GIT_DIR="../../$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=/
+GIT_DIR="../../$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=/ && export GIT_WORK_TREE
test_vars 'rel gitdir, foo/bar' "$TRASH_DIRECTORY/.git" "/" "foo/bar/"
test_foobar_foobar
@@ -180,24 +180,24 @@ say "GIT_DIR relative, GIT_WORK_TREE relative"
test_expect_success 'go to /' 'cd /'
-export GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git"
-export GIT_WORK_TREE=.
+GIT_DIR="$(echo $TRASH_DIRECTORY|sed 's,^/,,')/.git" && export GIT_DIR
+GIT_WORK_TREE=. && export GIT_WORK_TREE
test_vars 'rel gitdir, root' "$GIT_DIR" "/" ""
test_foobar_root
test_expect_success 'go to /' 'cd /foo'
-export GIT_DIR="../$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=..
+GIT_DIR="../$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=.. && export GIT_WORK_TREE
test_vars 'rel gitdir, foo' "$TRASH_DIRECTORY/.git" "/" "foo/"
test_foobar_foo
test_expect_success 'go to /foo/bar' 'cd /foo/bar'
-export GIT_DIR="../../$TRASH_DIRECTORY/.git"
-export GIT_WORK_TREE=../..
+GIT_DIR="../../$TRASH_DIRECTORY/.git" && export GIT_DIR
+GIT_WORK_TREE=../.. && export GIT_WORK_TREE
test_vars 'rel gitdir, foo/bar' "$TRASH_DIRECTORY/.git" "/" "foo/bar/"
test_foobar_foobar
diff --git a/t/t3020-ls-files-error-unmatch.sh b/t/t3020-ls-files-error-unmatch.sh
index a7d8187..ca01053 100755
--- a/t/t3020-ls-files-error-unmatch.sh
+++ b/t/t3020-ls-files-error-unmatch.sh
@@ -26,4 +26,3 @@ test_expect_success \
'git ls-files --error-unmatch foo bar'
test_done
-1
diff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh
index 2bea656..be8c1d5 100755
--- a/t/t3402-rebase-merge.sh
+++ b/t/t3402-rebase-merge.sh
@@ -117,4 +117,25 @@ test_expect_success 'picking rebase' '
esac
'
+test_expect_success 'rebase -s funny -Xopt' '
+ test_when_finished "rm -fr test-bin funny.was.run" &&
+ mkdir test-bin &&
+ cat >test-bin/git-merge-funny <<-EOF &&
+ #!$SHELL_PATH
+ case "\$1" in --opt) ;; *) exit 2 ;; esac
+ shift &&
+ >funny.was.run &&
+ exec git merge-recursive "\$@"
+ EOF
+ chmod +x test-bin/git-merge-funny &&
+ git reset --hard &&
+ git checkout -b test-funny master^ &&
+ test_commit funny &&
+ (
+ PATH=./test-bin:$PATH
+ git rebase -s funny -Xopt master
+ ) &&
+ test -f funny.was.run
+'
+
test_done
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 7d20a74..9e9474e 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -67,8 +67,9 @@ test_expect_success 'setup' '
# "exec" commands are ran with the user shell by default, but this may
# be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
# to create a file. Unseting SHELL avoids such non-portable behavior
-# in tests.
+# in tests. It must be exported for it to take effect where needed.
SHELL=
+export SHELL
test_expect_success 'rebase -i with the exec command' '
git checkout master &&
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index fbb3f2e..e573dc8 100755
--- a/t/t3407-rebase-abort.sh
+++ b/t/t3407-rebase-abort.sh
@@ -72,6 +72,18 @@ testrebase() {
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
test ! -d "$dotest"
'
+
+ test_expect_success "rebase$type --abort does not update reflog" '
+ cd "$work_dir" &&
+ # Clean up the state from the previous one
+ git reset --hard pre-rebase &&
+ git reflog show to-rebase > reflog_before &&
+ test_must_fail git rebase$type master &&
+ git rebase --abort &&
+ git reflog show to-rebase > reflog_after &&
+ test_cmp reflog_before reflog_after &&
+ rm reflog_before reflog_after
+ '
}
testrebase "" .git/rebase-apply
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index 37cb89a..fd2184c 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -26,7 +26,7 @@ test_auto_fixup() {
echo 1 >file1 &&
git add -u &&
test_tick &&
- git commit -m "fixup! first"
+ git commit -m "fixup! first" &&
git tag $1 &&
test_tick &&
@@ -55,7 +55,7 @@ test_auto_squash() {
echo 1 >file1 &&
git add -u &&
test_tick &&
- git commit -m "squash! first"
+ git commit -m "squash! first" &&
git tag $1 &&
test_tick &&
@@ -84,7 +84,7 @@ test_expect_success 'misspelled auto squash' '
echo 1 >file1 &&
git add -u &&
test_tick &&
- git commit -m "squash! forst"
+ git commit -m "squash! forst" &&
git tag final-missquash &&
test_tick &&
git rebase --autosquash -i HEAD^^^ &&
diff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh
new file mode 100755
index 0000000..bd8efaf
--- /dev/null
+++ b/t/t3419-rebase-patch-id.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+test_description='git rebase - test patch id computation'
+
+. ./test-lib.sh
+
+test_set_prereq NOT_EXPENSIVE
+test -n "$GIT_PATCHID_TIMING_TESTS" && test_set_prereq EXPENSIVE
+test -x /usr/bin/time && test_set_prereq USR_BIN_TIME
+
+count()
+{
+ i=0
+ while test $i -lt $1
+ do
+ echo "$i"
+ i=$(($i+1))
+ done
+}
+
+scramble()
+{
+ i=0
+ while read x
+ do
+ if test $i -ne 0
+ then
+ echo "$x"
+ fi
+ i=$((($i+1) % 10))
+ done < "$1" > "$1.new"
+ mv -f "$1.new" "$1"
+}
+
+run()
+{
+ echo \$ "$@"
+ /usr/bin/time "$@" >/dev/null
+}
+
+test_expect_success 'setup' '
+ git commit --allow-empty -m initial
+ git tag root
+'
+
+do_tests()
+{
+ pr=$1
+ nlines=$2
+
+ test_expect_success $pr "setup: $nlines lines" "
+ rm -f .gitattributes &&
+ git checkout -q -f master &&
+ git reset --hard root &&
+ count $nlines >file &&
+ git add file &&
+ git commit -q -m initial &&
+ git branch -f other &&
+
+ scramble file &&
+ git add file &&
+ git commit -q -m 'change big file' &&
+
+ git checkout -q other &&
+ : >newfile &&
+ git add newfile &&
+ git commit -q -m 'add small file' &&
+
+ git cherry-pick master >/dev/null 2>&1
+ "
+
+ test_debug "
+ run git diff master^\!
+ "
+
+ test_expect_success $pr 'setup attributes' "
+ echo 'file binary' >.gitattributes
+ "
+
+ test_debug "
+ run git format-patch --stdout master &&
+ run git format-patch --stdout --ignore-if-in-upstream master
+ "
+
+ test_expect_success $pr 'detect upstream patch' "
+ git checkout -q master &&
+ scramble file &&
+ git add file &&
+ git commit -q -m 'change big file again' &&
+ git checkout -q other^{} &&
+ git rebase master &&
+ test_must_fail test -n \"\$(git rev-list master...HEAD~)\"
+ "
+
+ test_expect_success $pr 'do not drop patch' "
+ git branch -f squashed master &&
+ git checkout -q -f squashed &&
+ git reset -q --soft HEAD~2 &&
+ git commit -q -m squashed &&
+ git checkout -q other^{} &&
+ test_must_fail git rebase squashed &&
+ rm -rf .git/rebase-apply
+ "
+}
+
+do_tests NOT_EXPENSIVE 500
+do_tests EXPENSIVE 50000
+
+test_done
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
index bc7aedd..0439544 100755
--- a/t/t3501-revert-cherry-pick.sh
+++ b/t/t3501-revert-cherry-pick.sh
@@ -81,6 +81,16 @@ test_expect_success 'revert after renaming branch' '
'
+test_expect_success 'cherry-pick on stat-dirty working tree' '
+ git clone . copy &&
+ (
+ cd copy &&
+ git checkout initial &&
+ test-chmtime +40 oops &&
+ git cherry-pick added
+ )
+'
+
test_expect_success 'revert forbidden on dirty working tree' '
echo content >extra_file &&
diff --git a/t/t3506-cherry-pick-ff.sh b/t/t3506-cherry-pick-ff.sh
index e17ae71..51ca391 100755
--- a/t/t3506-cherry-pick-ff.sh
+++ b/t/t3506-cherry-pick-ff.sh
@@ -95,4 +95,14 @@ test_expect_success 'cherry pick a merge relative to nonexistent parent with --f
test_must_fail git cherry-pick --ff -m 3 C
'
+test_expect_success 'cherry pick a root commit with --ff' '
+ git reset --hard first -- &&
+ git rm file1 &&
+ echo first >file2 &&
+ git add file2 &&
+ git commit --amend -m "file2" &&
+ git cherry-pick --ff first &&
+ test "$(git rev-parse --verify HEAD)" = "1df192cd8bc58a2b275d842cede4d221ad9000d1"
+'
+
test_done
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index a283dca..903a122 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -416,8 +416,37 @@ test_expect_success 'stash show - stashes on stack, stash-like argument' '
echo bar >> file &&
STASH_ID=$(git stash create) &&
git reset --hard &&
- git stash show ${STASH_ID}
+ cat >expected <<-EOF &&
+ file | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ EOF
+ git stash show ${STASH_ID} >actual &&
+ test_cmp expected actual
'
+
+test_expect_success 'stash show -p - stashes on stack, stash-like argument' '
+ git stash clear &&
+ test_when_finished "git reset --hard HEAD" &&
+ git reset --hard &&
+ echo foo >> file &&
+ git stash &&
+ test_when_finished "git stash drop" &&
+ echo bar >> file &&
+ STASH_ID=$(git stash create) &&
+ git reset --hard &&
+ cat >expected <<-EOF &&
+ diff --git a/file b/file
+ index 7601807..935fbd3 100644
+ --- a/file
+ +++ b/file
+ @@ -1 +1,2 @@
+ baz
+ +bar
+ EOF
+ git stash show -p ${STASH_ID} >actual &&
+ test_cmp expected actual
+'
+
test_expect_success 'stash show - no stashes on stack, stash-like argument' '
git stash clear &&
test_when_finished "git reset --hard HEAD" &&
@@ -425,7 +454,32 @@ test_expect_success 'stash show - no stashes on stack, stash-like argument' '
echo foo >> file &&
STASH_ID=$(git stash create) &&
git reset --hard &&
- git stash show ${STASH_ID}
+ cat >expected <<-EOF &&
+ file | 1 +
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ EOF
+ git stash show ${STASH_ID} >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'stash show -p - no stashes on stack, stash-like argument' '
+ git stash clear &&
+ test_when_finished "git reset --hard HEAD" &&
+ git reset --hard &&
+ echo foo >> file &&
+ STASH_ID=$(git stash create) &&
+ git reset --hard &&
+ cat >expected <<-EOF &&
+ diff --git a/file b/file
+ index 7601807..71b52c4 100644
+ --- a/file
+ +++ b/file
+ @@ -1 +1,2 @@
+ baz
+ +foo
+ EOF
+ git stash show -p ${STASH_ID} >actual &&
+ test_cmp expected actual
'
test_expect_success 'stash drop - fail early if specified stash is not a stash reference' '
@@ -491,4 +545,15 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '
git stash drop
'
+test_expect_success 'stash branch should not drop the stash if the branch exists' '
+ git stash clear &&
+ echo foo >file &&
+ git add file &&
+ git commit -m initial &&
+ echo bar >file &&
+ git stash &&
+ test_must_fail git stash branch master stash@{0} &&
+ git rev-parse stash@{0} --
+'
+
test_done
diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh
index 6f69489..408a19c 100755
--- a/t/t4011-diff-symlink.sh
+++ b/t/t4011-diff-symlink.sh
@@ -88,4 +88,30 @@ test_expect_success SYMLINKS \
test_must_fail git diff --no-index pinky brain > output 2> output.err &&
grep narf output &&
! grep error output.err'
+
+test_expect_success SYMLINKS 'setup symlinks with attributes' '
+ echo "*.bin diff=bin" >>.gitattributes &&
+ echo content >file.bin &&
+ ln -s file.bin link.bin &&
+ git add -N file.bin link.bin
+'
+
+cat >expect <<'EOF'
+diff --git a/file.bin b/file.bin
+index e69de29..d95f3ad 100644
+Binary files a/file.bin and b/file.bin differ
+diff --git a/link.bin b/link.bin
+index e69de29..dce41ec 120000
+--- a/link.bin
++++ b/link.bin
+@@ -0,0 +1 @@
++file.bin
+\ No newline at end of file
+EOF
+test_expect_success SYMLINKS 'symlinks do not respect userdiff config by path' '
+ git config diff.bin.binary true &&
+ git diff file.bin link.bin >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh
index bc46563..05ec062 100755
--- a/t/t4012-diff-binary.sh
+++ b/t/t4012-diff-binary.sh
@@ -77,10 +77,6 @@ test_expect_success 'apply binary patch' \
tree1=`git write-tree` &&
test "$tree1" = "$tree0"'
-nul_to_q() {
- perl -pe 'y/\000/Q/'
-}
-
test_expect_success 'diff --no-index with binary creation' '
echo Q | q_to_nul >binary &&
(: hide error code from diff, which just indicates differences
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 935d101..a8736f7 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -491,4 +491,41 @@ test_expect_success 'combined diff with autocrlf conversion' '
'
+# Start testing the colored format for whitespace checks
+
+test_expect_success 'setup diff colors' '
+ git config color.diff always &&
+ git config color.diff.plain normal &&
+ git config color.diff.meta bold &&
+ git config color.diff.frag cyan &&
+ git config color.diff.func normal &&
+ git config color.diff.old red &&
+ git config color.diff.new green &&
+ git config color.diff.commit yellow &&
+ git config color.diff.whitespace "normal red" &&
+
+ git config core.autocrlf false
+'
+cat >expected <<\EOF
+<BOLD>diff --git a/x b/x<RESET>
+<BOLD>index 9daeafb..2874b91 100644<RESET>
+<BOLD>--- a/x<RESET>
+<BOLD>+++ b/x<RESET>
+<CYAN>@@ -1 +1,4 @@<RESET>
+ test<RESET>
+<GREEN>+<RESET><GREEN>{<RESET>
+<GREEN>+<RESET><BRED> <RESET>
+<GREEN>+<RESET><GREEN>}<RESET>
+EOF
+
+test_expect_success 'diff that introduces a line with only tabs' '
+ git config core.whitespace blank-at-eol &&
+ git reset --hard &&
+ echo "test" > x &&
+ git commit -m "initial" x &&
+ echo "{NTN}" | tr "NT" "\n\t" >> x &&
+ git -c color.diff=always diff | test_decode_color >current &&
+ test_cmp expected current
+'
+
test_done
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index c8e1937..0a61b57 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -32,7 +32,7 @@ EOF
sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
-builtin_patterns="bibtex cpp csharp html java objc pascal php python ruby tex"
+builtin_patterns="bibtex cpp csharp fortran html java objc pascal php python ruby tex"
for p in $builtin_patterns
do
test_expect_success "builtin $p pattern compiles" '
diff --git a/t/t4019-diff-wserror.sh b/t/t4019-diff-wserror.sh
index f6d1f1e..87df0ae 100755
--- a/t/t4019-diff-wserror.sh
+++ b/t/t4019-diff-wserror.sh
@@ -178,6 +178,15 @@ test_expect_success 'trailing empty lines (2)' '
'
+test_expect_success 'checkdiff shows correct line number for trailing blank lines' '
+
+ printf "a\nb\n" > G &&
+ git add G &&
+ printf "x\nx\nx\na\nb\nc\n\n" > G &&
+ [ "$(git diff --check -- G)" = "G:7: new blank line at EOF." ]
+
+'
+
test_expect_success 'do not color trailing cr in context' '
git config --unset core.whitespace
rm -f .gitattributes &&
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 6f7548c..3f3c757 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -35,10 +35,10 @@ aeff = aeff * ( aaa )
EOF
cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 330b04f..5ed8eff 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1,3 +1,7 @@<RESET>
<RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
@@ -122,10 +122,10 @@ test_expect_success '--word-diff=plain --no-color' '
'
cat > expect <<EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 330b04f..5ed8eff 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1,3 +1,7 @@<RESET>
<RED>[-h(4)-]<RESET><GREEN>{+h(4),hh[44]+}<RESET>
@@ -143,10 +143,10 @@ test_expect_success '--word-diff=plain --color' '
'
cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 330b04f..5ed8eff 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1 +1 @@<RESET>
<RED>h(4)<RESET><GREEN>h(4),hh[44]<RESET>
<CYAN>@@ -3,0 +4,4 @@<RESET> <RESET><MAGENTA>a = b + c<RESET>
@@ -163,10 +163,10 @@ test_expect_success 'word diff without context' '
'
cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 330b04f..5ed8eff 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1,3 +1,7 @@<RESET>
h(4),<GREEN>hh<RESET>[44]
@@ -199,10 +199,10 @@ test_expect_success 'option overrides .gitattributes' '
'
cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 330b04f..5ed8eff 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1,3 +1,7 @@<RESET>
h(4)<GREEN>,hh[44]<RESET>
@@ -231,10 +231,10 @@ test_expect_success 'command-line overrides config' '
'
cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 330b04f..5ed8eff 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1,3 +1,7 @@<RESET>
h(4),<GREEN>{+hh+}<RESET>[44]
@@ -260,10 +260,10 @@ test_expect_success 'remove diff driver regex' '
'
cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 330b04f..5ed8eff 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 330b04f..5ed8eff 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1,3 +1,7 @@<RESET>
h(4),<GREEN>hh[44<RESET>]
@@ -282,10 +282,10 @@ echo 'aaa (aaa)' > pre
echo 'aaa (aaa) aaa' > post
cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index c29453b..be22f37 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index c29453b..be22f37 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1 +1 @@<RESET>
aaa (aaa) <GREEN>aaa<RESET>
EOF
@@ -301,10 +301,10 @@ echo '(:' > pre
echo '(' > post
cat > expect <<\EOF
-<WHITE>diff --git a/pre b/post<RESET>
-<WHITE>index 289cb9d..2d06f37 100644<RESET>
-<WHITE>--- a/pre<RESET>
-<WHITE>+++ b/post<RESET>
+<BOLD>diff --git a/pre b/post<RESET>
+<BOLD>index 289cb9d..2d06f37 100644<RESET>
+<BOLD>--- a/pre<RESET>
+<BOLD>+++ b/post<RESET>
<CYAN>@@ -1 +1 @@<RESET>
(<RED>:<RESET>
EOF
diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh
index 9692f16..08ad6d8 100755
--- a/t/t4103-apply-binary.sh
+++ b/t/t4103-apply-binary.sh
@@ -37,7 +37,16 @@ test_expect_success 'setup' "
git diff-tree -p -C master binary >C.diff &&
git diff-tree -p --binary master binary >BF.diff &&
- git diff-tree -p --binary -C master binary >CF.diff
+ git diff-tree -p --binary -C master binary >CF.diff &&
+
+ git diff-tree -p --full-index master binary >B-index.diff &&
+ git diff-tree -p -C --full-index master binary >C-index.diff &&
+
+ git init other-repo &&
+ (cd other-repo &&
+ git fetch .. master &&
+ git reset --hard FETCH_HEAD
+ )
"
test_expect_success 'stat binary diff -- should not fail.' \
@@ -100,6 +109,22 @@ test_expect_success 'apply binary diff (copy) -- should fail.' \
'do_reset &&
test_must_fail git apply --index C.diff'
+test_expect_success 'apply binary diff with full-index' '
+ do_reset &&
+ git apply B-index.diff
+'
+
+test_expect_success 'apply binary diff with full-index (copy)' '
+ do_reset &&
+ git apply C-index.diff
+'
+
+test_expect_success 'apply full-index binary diff in new repo' '
+ (cd other-repo &&
+ do_reset &&
+ test_must_fail git apply ../B-index.diff)
+'
+
test_expect_success 'apply binary diff without replacement.' \
'do_reset &&
git apply BF.diff'
diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh
index 2b2d00b..579c9e6 100755
--- a/t/t4120-apply-popt.sh
+++ b/t/t4120-apply-popt.sh
@@ -56,4 +56,30 @@ test_expect_success 'apply with too large -p and fancy filename' '
grep "removing 3 leading" err
'
+test_expect_success 'apply (-p2) diff, mode change only' '
+ cat >patch.chmod <<-\EOF &&
+ diff --git a/sub/file1 b/sub/file1
+ old mode 100644
+ new mode 100755
+ EOF
+ chmod 644 file1 &&
+ git apply -p2 patch.chmod &&
+ test -x file1
+'
+
+test_expect_success 'apply (-p2) diff, rename' '
+ cat >patch.rename <<-\EOF &&
+ diff --git a/sub/file1 b/sub/file2
+ similarity index 100%
+ rename from sub/file1
+ rename to sub/file2
+ EOF
+ echo A >expected &&
+
+ cp file1.saved file1 &&
+ rm -f file2 &&
+ git apply -p2 patch.rename &&
+ test_cmp expected file2
+'
+
test_done
diff --git a/t/t4132-apply-removal.sh b/t/t4132-apply-removal.sh
index bb1ffe3..a2bc1cd 100755
--- a/t/t4132-apply-removal.sh
+++ b/t/t4132-apply-removal.sh
@@ -30,6 +30,7 @@ test_expect_success setup '
epocWest="1969-12-31 16:00:00.000000000 -0800" &&
epocGMT="1970-01-01 00:00:00.000000000 +0000" &&
epocEast="1970-01-01 09:00:00.000000000 +0900" &&
+ epocWest2="1969-12-31 16:00:00 -08:00" &&
sed -e "s/TS0/$epocWest/" -e "s/TS1/$timeWest/" <c >createWest.patch &&
sed -e "s/TS0/$epocEast/" -e "s/TS1/$timeEast/" <c >createEast.patch &&
@@ -46,6 +47,7 @@ test_expect_success setup '
sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest/" <d >removeWest.patch &&
sed -e "s/TS0/$timeEast/" -e "s/TS1/$epocEast/" <d >removeEast.patch &&
sed -e "s/TS0/$timeGMT/" -e "s/TS1/$epocGMT/" <d >removeGMT.patch &&
+ sed -e "s/TS0/$timeWest/" -e "s/TS1/$epocWest2/" <d >removeWest2.patch &&
echo something >something &&
>empty
diff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh
index 1e5aad5..bf5dc57 100755
--- a/t/t4135-apply-weird-filenames.sh
+++ b/t/t4135-apply-weird-filenames.sh
@@ -72,4 +72,20 @@ test_expect_success 'whitespace-damaged traditional patch' '
test_cmp expected postimage.txt
'
+test_expect_success 'traditional patch with colon in timezone' '
+ echo postimage >expected &&
+ reset_preimage &&
+ rm -f "post image.txt" &&
+ git apply "$vector/funny-tz.diff" &&
+ test_cmp expected "post image.txt"
+'
+
+test_expect_success 'traditional, whitespace-damaged, colon in timezone' '
+ echo postimage >expected &&
+ reset_preimage &&
+ rm -f "post image.txt" &&
+ git apply "$vector/damaged-tz.diff" &&
+ test_cmp expected "post image.txt"
+'
+
test_done
diff --git a/t/t4135/damaged-tz.diff b/t/t4135/damaged-tz.diff
new file mode 100644
index 0000000..07aaf08
--- /dev/null
+++ b/t/t4135/damaged-tz.diff
@@ -0,0 +1,5 @@
+diff -urN -X /usr/people/jes/exclude-linux linux-2.6.12-rc2-mm3-vanilla/post image.txt linux-2.6.12-rc2-mm3/post image.txt
+--- linux-2.6.12-rc2-mm3-vanilla/post image.txt 1969-12-31 16:00:00 -08:00
++++ linux-2.6.12-rc2-mm3/post image.txt 2005-04-12 02:14:06 -07:00
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/funny-tz.diff b/t/t4135/funny-tz.diff
new file mode 100644
index 0000000..998e3a8
--- /dev/null
+++ b/t/t4135/funny-tz.diff
@@ -0,0 +1,5 @@
+diff -urN -X /usr/people/jes/exclude-linux linux-2.6.12-rc2-mm3-vanilla/post image.txt linux-2.6.12-rc2-mm3/post image.txt
+--- linux-2.6.12-rc2-mm3-vanilla/post image.txt 1969-12-31 16:00:00 -08:00
++++ linux-2.6.12-rc2-mm3/post image.txt 2005-04-12 02:14:06 -07:00
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh
index b55c411..c95c4cc 100755
--- a/t/t4151-am-abort.sh
+++ b/t/t4151-am-abort.sh
@@ -62,4 +62,13 @@ do
done
+test_expect_success 'am --abort will keep the local commits intact' '
+ test_must_fail git am 0004-*.patch &&
+ test_commit unrelated &&
+ git rev-parse HEAD >expect &&
+ git am --abort &&
+ git rev-parse HEAD >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 2e51356..2043bb8 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -422,6 +422,15 @@ test_expect_success 'log.decorate configuration' '
test_cmp expect.full actual &&
git config --unset-all log.decorate &&
+ git config log.decorate 1 &&
+ git log --oneline >actual &&
+ test_cmp expect.short actual &&
+ git log --oneline --decorate=full >actual &&
+ test_cmp expect.full actual &&
+ git log --oneline --decorate=no >actual &&
+ test_cmp expect.none actual &&
+
+ git config --unset-all log.decorate &&
git config log.decorate short &&
git log --oneline >actual &&
test_cmp expect.short actual &&
diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 9a7d1b4..e818de6 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -4,6 +4,14 @@ test_description='.mailmap configurations'
. ./test-lib.sh
+fuzz_blame () {
+ sed "
+ s/$_x05[0-9a-f][0-9a-f][0-9a-f]/OBJID/g
+ s/$_x05[0-9a-f][0-9a-f]/OBJI/g
+ s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
+ " "$@"
+}
+
test_expect_success setup '
echo one >one &&
git add one &&
@@ -11,6 +19,7 @@ test_expect_success setup '
git commit -m initial &&
echo two >>one &&
git add one &&
+ test_tick &&
git commit --author "nick1 <bugs@company.xx>" -m second
'
@@ -54,7 +63,7 @@ Repo Guy (1):
EOF
test_expect_success 'mailmap.file set' '
- mkdir internal_mailmap &&
+ mkdir -p internal_mailmap &&
echo "Internal Guy <bugs@company.xx>" > internal_mailmap/.mailmap &&
git config mailmap.file internal_mailmap/.mailmap &&
git shortlog HEAD >actual &&
@@ -93,6 +102,40 @@ test_expect_success 'mailmap.file non-existant' '
'
cat >expect <<\EOF
+Internal Guy (1):
+ second
+
+Repo Guy (1):
+ initial
+
+EOF
+
+test_expect_success 'name entry after email entry' '
+ mkdir -p internal_mailmap &&
+ echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
+ echo "Internal Guy <bugs@company.xx>" >>internal_mailmap/.mailmap &&
+ git shortlog HEAD >actual &&
+ test_cmp expect actual
+'
+
+cat >expect <<\EOF
+Internal Guy (1):
+ second
+
+Repo Guy (1):
+ initial
+
+EOF
+
+test_expect_success 'name entry after email entry, case-insensitive' '
+ mkdir -p internal_mailmap &&
+ echo "<bugs@company.xy> <bugs@company.xx>" >internal_mailmap/.mailmap &&
+ echo "Internal Guy <BUGS@Company.xx>" >>internal_mailmap/.mailmap &&
+ git shortlog HEAD >actual &&
+ test_cmp expect actual
+'
+
+cat >expect <<\EOF
A U Thor (1):
initial
@@ -101,7 +144,7 @@ nick1 (1):
EOF
test_expect_success 'No mailmap files, but configured' '
- rm .mailmap &&
+ rm -f .mailmap internal_mailmap/.mailmap &&
git shortlog HEAD >actual &&
test_cmp expect actual
'
@@ -153,7 +196,7 @@ test_expect_success 'Shortlog output (complex mapping)' '
test_tick &&
git commit --author "CTO <cto@coompany.xx>" -m seventh &&
- mkdir internal_mailmap &&
+ mkdir -p internal_mailmap &&
echo "Committed <committer@example.com>" > internal_mailmap/.mailmap &&
echo "<cto@company.xx> <cto@coompany.xx>" >> internal_mailmap/.mailmap &&
echo "Some Dude <some@dude.xx> nick1 <bugs@company.xx>" >> internal_mailmap/.mailmap &&
@@ -198,18 +241,18 @@ test_expect_success 'Log output (complex mapping)' '
# git blame
cat >expect <<\EOF
-^3a2fdcb (A U Thor 2005-04-07 15:13:13 -0700 1) one
-7de6f99b (Some Dude 2005-04-07 15:13:13 -0700 2) two
-5815879d (Other Author 2005-04-07 15:14:13 -0700 3) three
-ff859d96 (Other Author 2005-04-07 15:15:13 -0700 4) four
-5ab6d4fa (Santa Claus 2005-04-07 15:16:13 -0700 5) five
-38a42d8b (Santa Claus 2005-04-07 15:17:13 -0700 6) six
-8ddc0386 (CTO 2005-04-07 15:18:13 -0700 7) seven
+^OBJI (A U Thor DATE 1) one
+OBJID (Some Dude DATE 2) two
+OBJID (Other Author DATE 3) three
+OBJID (Other Author DATE 4) four
+OBJID (Santa Claus DATE 5) five
+OBJID (Santa Claus DATE 6) six
+OBJID (CTO DATE 7) seven
EOF
-
test_expect_success 'Blame output (complex mapping)' '
git blame one >actual &&
- test_cmp expect actual
+ fuzz_blame actual >actual.fuzz &&
+ test_cmp expect actual.fuzz
'
test_done
diff --git a/t/t5407-post-rewrite-hook.sh b/t/t5407-post-rewrite-hook.sh
index 552da65..baa670c 100755
--- a/t/t5407-post-rewrite-hook.sh
+++ b/t/t5407-post-rewrite-hook.sh
@@ -10,7 +10,11 @@ test_expect_success 'setup' '
test_commit A foo A &&
test_commit B foo B &&
test_commit C foo C &&
- test_commit D foo D
+ test_commit D foo D &&
+ git checkout A^0 &&
+ test_commit E bar E &&
+ test_commit F foo F &&
+ git checkout master
'
mkdir .git/hooks
@@ -79,6 +83,18 @@ EOF
verify_hook_input
'
+test_expect_success 'git rebase --skip the last one' '
+ git reset --hard F &&
+ clear_hook_input &&
+ test_must_fail git rebase --onto D A &&
+ git rebase --skip &&
+ echo rebase >expected.args &&
+ cat >expected.data <<EOF &&
+$(git rev-parse E) $(git rev-parse HEAD)
+EOF
+ verify_hook_input
+'
+
test_expect_success 'git rebase -m' '
git reset --hard D &&
clear_hook_input &&
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index 2fb48d0..a1883ca 100755
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
@@ -30,18 +30,37 @@ test_expect_success 'create http-accessible bare repository' '
'
test_expect_success 'clone http repository' '
- git clone $HTTPD_URL/dumb/repo.git clone &&
+ git clone $HTTPD_URL/dumb/repo.git clone-tmpl &&
+ cp -R clone-tmpl clone &&
test_cmp file clone/file
'
+test_expect_success 'clone http repository with authentication' '
+ mkdir "$HTTPD_DOCUMENT_ROOT_PATH/auth/" &&
+ cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" "$HTTPD_DOCUMENT_ROOT_PATH/auth/repo.git" &&
+ git clone $AUTH_HTTPD_URL/auth/repo.git clone-auth &&
+ test_cmp file clone-auth/file
+'
+
test_expect_success 'fetch changes via http' '
echo content >>file &&
git commit -a -m two &&
- git push public
+ git push public &&
(cd clone && git pull) &&
test_cmp file clone/file
'
+test_expect_success 'fetch changes via manual http-fetch' '
+ cp -R clone-tmpl clone2 &&
+
+ HEAD=$(git rev-parse --verify HEAD) &&
+ (cd clone2 &&
+ git http-fetch -a -w heads/master-new $HEAD $(git config remote.origin.url) &&
+ git checkout master-new &&
+ test $HEAD = $(git rev-parse --verify HEAD)) &&
+ test_cmp file clone2/file
+'
+
test_expect_success 'http remote detects correct HEAD' '
git push public master:other &&
(cd clone &&
diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh
index fd19121..26d3557 100755
--- a/t/t5551-http-fetch.sh
+++ b/t/t5551-http-fetch.sh
@@ -101,5 +101,13 @@ test_expect_success 'used upload-pack service' '
test_cmp exp act
'
+test_expect_success 'follow redirects (301)' '
+ git clone $HTTPD_URL/smart-redir-perm/repo.git --quiet repo-p
+'
+
+test_expect_success 'follow redirects (302)' '
+ git clone $HTTPD_URL/smart-redir-temp/repo.git --quiet repo-t
+'
+
stop_httpd
test_done
diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index 44885b8..94f9d2e 100755
--- a/t/t5560-http-backend-noserver.sh
+++ b/t/t5560-http-backend-noserver.sh
@@ -14,7 +14,7 @@ run_backend() {
}
GET() {
- export REQUEST_METHOD="GET" &&
+ REQUEST_METHOD="GET" && export REQUEST_METHOD &&
run_backend "/repo.git/$1" &&
unset REQUEST_METHOD &&
if ! grep "Status" act.out >act
@@ -26,8 +26,8 @@ GET() {
}
POST() {
- export REQUEST_METHOD="POST" &&
- export CONTENT_TYPE="application/x-$1-request" &&
+ REQUEST_METHOD="POST" && export REQUEST_METHOD &&
+ CONTENT_TYPE="application/x-$1-request" && export CONTENT_TYPE &&
run_backend "/repo.git/$1" "$2" &&
unset REQUEST_METHOD &&
unset CONTENT_TYPE &&
@@ -46,7 +46,7 @@ log_div() {
. "$TEST_DIRECTORY"/t556x_common
expect_aliased() {
- export REQUEST_METHOD="GET" &&
+ REQUEST_METHOD="GET" && export REQUEST_METHOD &&
if test $1 = 0; then
run_backend "$2"
else
diff --git a/t/t556x_common b/t/t556x_common
index be024e5..51287d8 100755
--- a/t/t556x_common
+++ b/t/t556x_common
@@ -50,7 +50,7 @@ get_static_files() {
}
SMART=smart
-export GIT_HTTP_EXPORT_ALL=1
+GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
test_expect_success 'direct refs/heads/master not found' '
log_div "refs/heads/master"
GET refs/heads/master "404 Not Found"
@@ -73,7 +73,7 @@ test_expect_success 'export if git-daemon-export-ok' '
get_static_files "200 OK"
'
SMART=smart
-export GIT_HTTP_EXPORT_ALL=1
+GIT_HTTP_EXPORT_ALL=1 && export GIT_HTTP_EXPORT_ALL
test_expect_success 'static file if http.getanyfile true is ok' '
log_div "getanyfile true"
config http.getanyfile true &&
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index cccacd4..d918cc0 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -162,6 +162,14 @@ commit 131a310eb913d107dd3c09a65d1651175898735d
commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
EOF
+test_expect_success '%x00 shows NUL' '
+ echo >expect commit f58db70b055c5718631e5c61528b28b12090cdea &&
+ echo >>expect fooQbar &&
+ git rev-list -1 --format=foo%x00bar HEAD >actual.nul &&
+ nul_to_q <actual.nul >actual &&
+ test_cmp expect actual
+'
+
test_expect_success '%ad respects --date=' '
echo 2005-04-07 >expect.ad-short &&
git log -1 --date=short --pretty=tformat:%ad >output.ad-short master &&
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index d486d73..d9f3439 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -64,6 +64,14 @@ cp new1.txt test.txt
test_expect_success "merge without conflict" \
"git merge-file test.txt orig.txt new2.txt"
+test_expect_success 'works in subdirectory' '
+ mkdir dir &&
+ cp new1.txt dir/a.txt &&
+ cp orig.txt dir/o.txt &&
+ cp new2.txt dir/b.txt &&
+ ( cd dir && git merge-file a.txt o.txt b.txt )
+'
+
cp new1.txt test.txt
test_expect_success "merge without conflict (--quiet)" \
"git merge-file --quiet test.txt orig.txt new2.txt"
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index c907523..95b180f 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -205,9 +205,16 @@ test_expect_success 'fetch branch with replacement' '
git branch tofetch $HASH6 &&
(
cd clone_dir &&
- git fetch origin refs/heads/tofetch:refs/heads/parallel3
- git log --pretty=oneline parallel3 | grep $PARA3
- git show $PARA3 | grep "A U Thor"
+ git fetch origin refs/heads/tofetch:refs/heads/parallel3 &&
+ git log --pretty=oneline parallel3 > output.txt &&
+ ! grep $PARA3 output.txt &&
+ git show $PARA3 > para3.txt &&
+ grep "A U Thor" para3.txt &&
+ git fetch origin "refs/replace/*:refs/replace/*" &&
+ git log --pretty=oneline parallel3 > output.txt &&
+ grep $PARA3 output.txt &&
+ git show $PARA3 > para3.txt &&
+ grep "O Thor" para3.txt
)
'
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index ac943f5..6841c23 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1030,6 +1030,72 @@ test_expect_success GPG \
test_cmp expect actual
'
+# usage with rfc1991 signatures
+echo "rfc1991" > gpghome/gpg.conf
+get_tag_header rfc1991-signed-tag $commit commit $time >expect
+echo "RFC1991 signed tag" >>expect
+echo '-----BEGIN PGP MESSAGE-----' >>expect
+test_expect_success GPG \
+ 'creating a signed tag with rfc1991' '
+ git tag -s -m "RFC1991 signed tag" rfc1991-signed-tag $commit &&
+ get_tag_msg rfc1991-signed-tag >actual &&
+ test_cmp expect actual
+'
+
+cat >fakeeditor <<'EOF'
+#!/bin/sh
+cp "$1" actual
+EOF
+chmod +x fakeeditor
+
+test_expect_success GPG \
+ 'reediting a signed tag body omits signature' '
+ echo "RFC1991 signed tag" >expect &&
+ GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
+ test_cmp expect actual
+'
+
+test_expect_success GPG \
+ 'verifying rfc1991 signature' '
+ git tag -v rfc1991-signed-tag
+'
+
+test_expect_success GPG \
+ 'list tag with rfc1991 signature' '
+ echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
+ git tag -l -n1 rfc1991-signed-tag >actual &&
+ test_cmp expect actual &&
+ git tag -l -n2 rfc1991-signed-tag >actual &&
+ test_cmp expect actual &&
+ git tag -l -n999 rfc1991-signed-tag >actual &&
+ test_cmp expect actual
+'
+
+rm -f gpghome/gpg.conf
+
+test_expect_success GPG \
+ 'verifying rfc1991 signature without --rfc1991' '
+ git tag -v rfc1991-signed-tag
+'
+
+test_expect_success GPG \
+ 'list tag with rfc1991 signature without --rfc1991' '
+ echo "rfc1991-signed-tag RFC1991 signed tag" >expect &&
+ git tag -l -n1 rfc1991-signed-tag >actual &&
+ test_cmp expect actual &&
+ git tag -l -n2 rfc1991-signed-tag >actual &&
+ test_cmp expect actual &&
+ git tag -l -n999 rfc1991-signed-tag >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success GPG \
+ 'reediting a signed tag body omits signature' '
+ echo "RFC1991 signed tag" >expect &&
+ GIT_EDITOR=./fakeeditor git tag -f -s rfc1991-signed-tag $commit &&
+ test_cmp expect actual
+'
+
# try to sign with bad user.signingkey
git config user.signingkey BobTheMouse
test_expect_success GPG \
diff --git a/t/t7006/test-terminal.perl b/t/t7006/test-terminal.perl
index 73ff809..6b5f22a 100755
--- a/t/t7006/test-terminal.perl
+++ b/t/t7006/test-terminal.perl
@@ -1,4 +1,5 @@
#!/usr/bin/perl
+use 5.008;
use strict;
use warnings;
use IO::Pty;
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 02522f9..e5b1953 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -23,7 +23,9 @@ test_expect_success setup '
git commit -m "submodule"
) &&
git clone super super-clone &&
- (cd super-clone && git submodule update --init)
+ (cd super-clone && git submodule update --init) &&
+ git clone super empty-clone &&
+ (cd empty-clone && git submodule init)
'
test_expect_success 'change submodule' '
@@ -64,4 +66,12 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
)
'
+test_expect_success '"git submodule sync" should update submodule URLs if not yet cloned' '
+ (cd empty-clone &&
+ git pull &&
+ git submodule sync &&
+ test -d "$(git config submodule.submodule.url)"
+ )
+'
+
test_done
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 8297cb4..8980738 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -230,6 +230,10 @@ test_expect_success 'amend commit to fix date' '
'
+test_expect_success 'commit complains about bogus date' '
+ test_must_fail git commit --amend --date=10.11.2010
+'
+
test_expect_success 'sign off (1)' '
echo 1 >positive &&
diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh
index d82349a..4d5ce4e 100755
--- a/t/t7607-merge-overwrite.sh
+++ b/t/t7607-merge-overwrite.sh
@@ -7,48 +7,54 @@ Do not overwrite changes.'
. ./test-lib.sh
test_expect_success 'setup' '
- echo c0 > c0.c &&
- git add c0.c &&
- git commit -m c0 &&
- git tag c0 &&
- echo c1 > c1.c &&
- git add c1.c &&
- git commit -m c1 &&
- git tag c1 &&
+ test_commit c0 c0.c &&
+ test_commit c1 c1.c &&
+ test_commit c1a c1.c "c1 a" &&
git reset --hard c0 &&
- echo c2 > c2.c &&
- git add c2.c &&
- git commit -m c2 &&
- git tag c2 &&
- git reset --hard c1 &&
- echo "c1 a" > c1.c &&
- git add c1.c &&
- git commit -m "c1 a" &&
- git tag c1a &&
+ test_commit c2 c2.c &&
+ git reset --hard c0 &&
+ mkdir sub &&
+ echo "sub/f" > sub/f &&
+ mkdir sub2 &&
+ echo "sub2/f" > sub2/f &&
+ git add sub/f sub2/f &&
+ git commit -m sub &&
+ git tag sub &&
echo "VERY IMPORTANT CHANGES" > important
'
test_expect_success 'will not overwrite untracked file' '
git reset --hard c1 &&
- cat important > c2.c &&
+ cp important c2.c &&
test_must_fail git merge c2 &&
+ test_path_is_missing .git/MERGE_HEAD &&
test_cmp important c2.c
'
+test_expect_success 'will overwrite tracked file' '
+ git reset --hard c1 &&
+ cp important c2.c &&
+ git add c2.c &&
+ git commit -m important &&
+ git checkout c2
+'
+
test_expect_success 'will not overwrite new file' '
git reset --hard c1 &&
- cat important > c2.c &&
+ cp important c2.c &&
git add c2.c &&
test_must_fail git merge c2 &&
+ test_path_is_missing .git/MERGE_HEAD &&
test_cmp important c2.c
'
test_expect_success 'will not overwrite staged changes' '
git reset --hard c1 &&
- cat important > c2.c &&
+ cp important c2.c &&
git add c2.c &&
rm c2.c &&
test_must_fail git merge c2 &&
+ test_path_is_missing .git/MERGE_HEAD &&
git checkout c2.c &&
test_cmp important c2.c
'
@@ -57,7 +63,7 @@ test_expect_success 'will not overwrite removed file' '
git reset --hard c1 &&
git rm c1.c &&
git commit -m "rm c1.c" &&
- cat important > c1.c &&
+ cp important c1.c &&
test_must_fail git merge c1a &&
test_cmp important c1.c
'
@@ -66,9 +72,10 @@ test_expect_success 'will not overwrite re-added file' '
git reset --hard c1 &&
git rm c1.c &&
git commit -m "rm c1.c" &&
- cat important > c1.c &&
+ cp important c1.c &&
git add c1.c &&
test_must_fail git merge c1a &&
+ test_path_is_missing .git/MERGE_HEAD &&
test_cmp important c1.c
'
@@ -76,12 +83,77 @@ test_expect_success 'will not overwrite removed file with staged changes' '
git reset --hard c1 &&
git rm c1.c &&
git commit -m "rm c1.c" &&
- cat important > c1.c &&
+ cp important c1.c &&
git add c1.c &&
rm c1.c &&
test_must_fail git merge c1a &&
+ test_path_is_missing .git/MERGE_HEAD &&
git checkout c1.c &&
test_cmp important c1.c
'
+test_expect_success 'will not overwrite untracked subtree' '
+ git reset --hard c0 &&
+ rm -rf sub &&
+ mkdir -p sub/f &&
+ cp important sub/f/important &&
+ test_must_fail git merge sub &&
+ test_path_is_missing .git/MERGE_HEAD &&
+ test_cmp important sub/f/important
+'
+
+cat >expect <<\EOF
+error: The following untracked working tree files would be overwritten by merge:
+ sub
+ sub2
+Please move or remove them before you can merge.
+EOF
+
+test_expect_success 'will not overwrite untracked file in leading path' '
+ git reset --hard c0 &&
+ rm -rf sub &&
+ cp important sub &&
+ cp important sub2 &&
+ test_must_fail git merge sub 2>out &&
+ test_cmp out expect &&
+ test_path_is_missing .git/MERGE_HEAD &&
+ test_cmp important sub &&
+ test_cmp important sub2 &&
+ rm -f sub sub2
+'
+
+test_expect_failure SYMLINKS 'will not overwrite untracked symlink in leading path' '
+ git reset --hard c0 &&
+ rm -rf sub &&
+ mkdir sub2 &&
+ ln -s sub2 sub &&
+ test_must_fail git merge sub &&
+ test_path_is_missing .git/MERGE_HEAD
+'
+
+test_expect_success SYMLINKS 'will not be confused by symlink in leading path' '
+ git reset --hard c0 &&
+ rm -rf sub &&
+ ln -s sub2 sub &&
+ git add sub &&
+ git commit -m ln &&
+ git checkout sub
+'
+
+cat >expect <<\EOF
+error: Untracked working tree file 'c0.c' would be overwritten by merge.
+fatal: read-tree failed
+EOF
+
+test_expect_success 'will not overwrite untracked file on unborn branch' '
+ git reset --hard c0 &&
+ git rm -fr . &&
+ git checkout --orphan new &&
+ cp important c0.c &&
+ test_must_fail git merge c0 2>out &&
+ test_cmp out expect &&
+ test_path_is_missing .git/MERGE_HEAD &&
+ test_cmp important c0.c
+'
+
test_done
diff --git a/t/t7609-merge-co-error-msgs.sh b/t/t7609-merge-co-error-msgs.sh
index 114d2bd..c994836 100755
--- a/t/t7609-merge-co-error-msgs.sh
+++ b/t/t7609-merge-co-error-msgs.sh
@@ -27,10 +27,10 @@ test_expect_success 'setup' '
cat >expect <<\EOF
error: The following untracked working tree files would be overwritten by merge:
- two
- three
- four
five
+ four
+ three
+ two
Please move or remove them before you can merge.
EOF
@@ -49,9 +49,9 @@ test_expect_success 'untracked files overwritten by merge (fast and non-fast for
cat >expect <<\EOF
error: Your local changes to the following files would be overwritten by merge:
- two
- three
four
+ three
+ two
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:
five
@@ -68,8 +68,8 @@ test_expect_success 'untracked files or local changes ovewritten by merge' '
cat >expect <<\EOF
error: Your local changes to the following files would be overwritten by checkout:
- rep/two
rep/one
+ rep/two
Please, commit your changes or stash them before you can switch branches.
EOF
@@ -89,8 +89,8 @@ test_expect_success 'cannot switch branches because of local changes' '
cat >expect <<\EOF
error: Your local changes to the following files would be overwritten by checkout:
- rep/two
rep/one
+ rep/two
Please, commit your changes or stash them before you can switch branches.
EOF
@@ -102,8 +102,8 @@ test_expect_success 'not uptodate file porcelain checkout error' '
cat >expect <<\EOF
error: Updating the following directories would lose untracked files in it:
- rep2
rep
+ rep2
EOF
diff --git a/t/t8006-blame-textconv.sh b/t/t8006-blame-textconv.sh
index 9ad96d4..ea64cd8 100755
--- a/t/t8006-blame-textconv.sh
+++ b/t/t8006-blame-textconv.sh
@@ -9,22 +9,29 @@ find_blame() {
cat >helper <<'EOF'
#!/bin/sh
-sed 's/^/converted: /' "$@"
+grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
+sed 's/^bin: /converted: /' "$1"
EOF
chmod +x helper
test_expect_success 'setup ' '
- echo test 1 >one.bin &&
- echo test number 2 >two.bin &&
+ echo "bin: test 1" >one.bin &&
+ echo "bin: test number 2" >two.bin &&
+ if test_have_prereq SYMLINKS; then
+ ln -s one.bin symlink.bin
+ fi &&
git add . &&
GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
- echo test 1 version 2 >one.bin &&
- echo test number 2 version 2 >>two.bin &&
+ echo "bin: test 1 version 2" >one.bin &&
+ echo "bin: test number 2 version 2" >>two.bin &&
+ if test_have_prereq SYMLINKS; then
+ ln -sf two.bin symlink.bin
+ fi &&
GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
'
cat >expected <<EOF
-(Number2 2010-01-01 20:00:00 +0000 1) test 1 version 2
+(Number2 2010-01-01 20:00:00 +0000 1) bin: test 1 version 2
EOF
test_expect_success 'no filter specified' '
@@ -66,8 +73,29 @@ test_expect_success 'blame --textconv going through revisions' '
test_cmp expected result
'
+test_expect_success 'setup +cachetextconv' '
+ git config diff.test.cachetextconv true
+'
+
+cat >expected_one <<EOF
+(Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
+EOF
+
+test_expect_success 'blame --textconv works with textconvcache' '
+ git blame --textconv two.bin >blame &&
+ find_blame <blame >result &&
+ test_cmp expected result &&
+ git blame --textconv one.bin >blame &&
+ find_blame <blame >result &&
+ test_cmp expected_one result
+'
+
+test_expect_success 'setup -cachetextconv' '
+ git config diff.test.cachetextconv false
+'
+
test_expect_success 'make a new commit' '
- echo "test number 2 version 3" >>two.bin &&
+ echo "bin: test number 2 version 3" >>two.bin &&
GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
'
@@ -77,4 +105,45 @@ test_expect_success 'blame from previous revision' '
test_cmp expected result
'
+cat >expected <<EOF
+(Number2 2010-01-01 20:00:00 +0000 1) two.bin
+EOF
+
+test_expect_success SYMLINKS 'blame with --no-textconv (on symlink)' '
+ git blame --no-textconv symlink.bin >blame &&
+ find_blame <blame >result &&
+ test_cmp expected result
+'
+
+test_expect_success SYMLINKS 'blame --textconv (on symlink)' '
+ git blame --textconv symlink.bin >blame &&
+ find_blame <blame >result &&
+ test_cmp expected result
+'
+
+# cp two.bin three.bin and make small tweak
+# (this will direct blame -C -C three.bin to consider two.bin and symlink.bin)
+test_expect_success SYMLINKS 'make another new commit' '
+ cat >three.bin <<\EOF &&
+bin: test number 2
+bin: test number 2 version 2
+bin: test number 2 version 3
+bin: test number 3
+EOF
+ git add three.bin &&
+ GIT_AUTHOR_NAME=Number4 git commit -a -m Fourth --date="2010-01-01 23:00:00"
+'
+
+test_expect_success SYMLINKS 'blame on last commit (-C -C, symlink)' '
+ git blame -C -C three.bin >blame &&
+ find_blame <blame >result &&
+ cat >expected <<\EOF &&
+(Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
+(Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
+(Number3 2010-01-01 22:00:00 +0000 3) converted: test number 2 version 3
+(Number4 2010-01-01 23:00:00 +0000 4) converted: test number 3
+EOF
+ test_cmp expected result
+'
+
test_done
diff --git a/t/t8007-cat-file-textconv.sh b/t/t8007-cat-file-textconv.sh
index 38ac05e..78a0085 100755
--- a/t/t8007-cat-file-textconv.sh
+++ b/t/t8007-cat-file-textconv.sh
@@ -5,15 +5,19 @@ test_description='git cat-file textconv support'
cat >helper <<'EOF'
#!/bin/sh
-sed 's/^/converted: /' "$@"
+grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
+sed 's/^bin: /converted: /' "$1"
EOF
chmod +x helper
test_expect_success 'setup ' '
- echo test >one.bin &&
+ echo "bin: test" >one.bin &&
+ if test_have_prereq SYMLINKS; then
+ ln -s one.bin symlink.bin
+ fi &&
git add . &&
GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
- echo test version 2 >one.bin &&
+ echo "bin: test version 2" >one.bin &&
GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
'
@@ -33,7 +37,7 @@ test_expect_success 'setup textconv filters' '
'
cat >expected <<EOF
-test version 2
+bin: test version 2
EOF
test_expect_success 'cat-file without --textconv' '
@@ -42,7 +46,7 @@ test_expect_success 'cat-file without --textconv' '
'
cat >expected <<EOF
-test
+bin: test
EOF
test_expect_success 'cat-file without --textconv on previous commit' '
@@ -67,4 +71,28 @@ test_expect_success 'cat-file --textconv on previous commit' '
git cat-file --textconv HEAD^:one.bin >result &&
test_cmp expected result
'
+
+test_expect_success SYMLINKS 'cat-file without --textconv (symlink)' '
+ git cat-file blob :symlink.bin >result &&
+ printf "%s" "one.bin" >expected
+ test_cmp expected result
+'
+
+
+test_expect_success SYMLINKS 'cat-file --textconv on index (symlink)' '
+ ! git cat-file --textconv :symlink.bin 2>result &&
+ cat >expected <<\EOF &&
+fatal: git cat-file --textconv: unable to run textconv on :symlink.bin
+EOF
+ test_cmp expected result
+'
+
+test_expect_success SYMLINKS 'cat-file --textconv on HEAD (symlink)' '
+ ! git cat-file --textconv HEAD:symlink.bin 2>result &&
+ cat >expected <<EOF &&
+fatal: git cat-file --textconv: unable to run textconv on HEAD:symlink.bin
+EOF
+ test_cmp expected result
+'
+
test_done
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 71b3df9..f1047d2 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -279,7 +279,7 @@ test_expect_success $PREREQ 'Invalid In-Reply-To' '
--to=nobody@example.com \
--in-reply-to=" " \
--smtp-server="$(pwd)/fake.sendmail" \
- $patches
+ $patches \
2>errors
! grep "^In-Reply-To: < *>" msgtxt1
'
@@ -1032,4 +1032,40 @@ test_expect_success $PREREQ '--8bit-encoding also treats subject' '
test_cmp expected actual
'
+# Note that the patches in this test are deliberately out of order; we
+# want to make sure it works even if the cover-letter is not in the
+# first mail.
+test_expect_success $PREREQ 'refusing to send cover letter template' '
+ clean_fake_sendmail &&
+ rm -fr outdir &&
+ git format-patch --cover-letter -2 -o outdir &&
+ test_must_fail git send-email \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ outdir/0002-*.patch \
+ outdir/0000-*.patch \
+ outdir/0001-*.patch \
+ 2>errors >out &&
+ grep "SUBJECT HERE" errors &&
+ test -z "$(ls msgtxt*)"
+'
+
+test_expect_success $PREREQ '--force sends cover letter template anyway' '
+ clean_fake_sendmail &&
+ rm -fr outdir &&
+ git format-patch --cover-letter -2 -o outdir &&
+ git send-email \
+ --force \
+ --from="Example <nobody@example.com>" \
+ --to=nobody@example.com \
+ --smtp-server="$(pwd)/fake.sendmail" \
+ outdir/0002-*.patch \
+ outdir/0000-*.patch \
+ outdir/0001-*.patch \
+ 2>errors >out &&
+ ! grep "SUBJECT HERE" errors &&
+ test -n "$(ls msgtxt*)"
+'
+
test_done
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index 2f458f7..b041516 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -143,7 +143,7 @@ test_expect_success "$name" '
git svn set-tree --find-copies-harder --rmdir \
${remotes_git_svn}..mybranch5 &&
svn_cmd up "$SVN_TREE" &&
- test -L "$SVN_TREE"/exec.sh'
+ test -h "$SVN_TREE"/exec.sh'
name='new symlink is added to a file that was also just made executable'
@@ -156,7 +156,7 @@ test_expect_success "$name" '
${remotes_git_svn}..mybranch5 &&
svn_cmd up "$SVN_TREE" &&
test -x "$SVN_TREE"/bar/zzz &&
- test -L "$SVN_TREE"/exec-2.sh'
+ test -h "$SVN_TREE"/exec-2.sh'
name='modify a symlink to become a file'
test_expect_success "$name" '
@@ -169,7 +169,7 @@ test_expect_success "$name" '
${remotes_git_svn}..mybranch5 &&
svn_cmd up "$SVN_TREE" &&
test -f "$SVN_TREE"/exec-2.sh &&
- test ! -L "$SVN_TREE"/exec-2.sh &&
+ test ! -h "$SVN_TREE"/exec-2.sh &&
test_cmp help "$SVN_TREE"/exec-2.sh'
name="commit with UTF-8 message: locale: $GIT_SVN_LC_ALL"
diff --git a/t/t9131-git-svn-empty-symlink.sh b/t/t9131-git-svn-empty-symlink.sh
index 9a24a65..f762038 100755
--- a/t/t9131-git-svn-empty-symlink.sh
+++ b/t/t9131-git-svn-empty-symlink.sh
@@ -88,7 +88,7 @@ test_expect_success 'enable broken symlink workaround' \
test_expect_success '"bar" is an empty file' 'test -f x/bar && ! test -s x/bar'
test_expect_success 'get "bar" => symlink fix from svn' \
'(cd x && git svn rebase)'
-test_expect_success SYMLINKS '"bar" becomes a symlink' 'test -L x/bar'
+test_expect_success SYMLINKS '"bar" becomes a symlink' 'test -h x/bar'
test_expect_success 'clone using git svn' 'git svn clone -r1 "$svnrepo" y'
diff --git a/t/t9157-git-svn-fetch-merge.sh b/t/t9157-git-svn-fetch-merge.sh
new file mode 100644
index 0000000..da582c5
--- /dev/null
+++ b/t/t9157-git-svn-fetch-merge.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Steven Walter
+#
+
+test_description='git svn merge detection'
+. ./lib-git-svn.sh
+
+test_expect_success 'initialize source svn repo' '
+ svn_cmd mkdir -m x "$svnrepo"/trunk &&
+ svn_cmd mkdir -m x "$svnrepo"/branches &&
+ svn_cmd co "$svnrepo"/trunk "$SVN_TREE" &&
+ (
+ cd "$SVN_TREE" &&
+ touch foo &&
+ svn add foo &&
+ svn commit -m "initial commit" &&
+ svn cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch1 &&
+ touch bar &&
+ svn add bar &&
+ svn commit -m x &&
+ svn cp -m branch "$svnrepo"/trunk "$svnrepo"/branches/branch2 &&
+ svn switch "$svnrepo"/branches/branch1 &&
+ touch baz &&
+ svn add baz &&
+ svn commit -m x &&
+ svn switch "$svnrepo"/trunk &&
+ svn merge "$svnrepo"/branches/branch1 &&
+ svn commit -m "merge" &&
+ svn switch "$svnrepo"/branches/branch1 &&
+ svn commit -m x &&
+ svn switch "$svnrepo"/branches/branch2 &&
+ svn merge "$svnrepo"/branches/branch1 &&
+ svn commit -m "merge branch1" &&
+ svn switch "$svnrepo"/trunk &&
+ svn merge "$svnrepo"/branches/branch2 &&
+ svn resolved baz &&
+ svn commit -m "merge branch2"
+ ) &&
+ rm -rf "$SVN_TREE"
+'
+
+test_expect_success 'clone svn repo' '
+ git svn init -s "$svnrepo" &&
+ git svn fetch
+'
+
+test_expect_success 'verify merge commit' 'git rev-parse HEAD^2'
+
+test_done
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 671f38d..c15ca2d 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use lib (split(/:/, $ENV{GITPERLLIB}));
-use 5.006002;
+use 5.008;
use warnings;
use strict;
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 830e5e7..1fb76ab 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -238,14 +238,51 @@ test_set_editor () {
}
test_decode_color () {
- sed -e 's/.\[1m/<WHITE>/g' \
- -e 's/.\[31m/<RED>/g' \
- -e 's/.\[32m/<GREEN>/g' \
- -e 's/.\[33m/<YELLOW>/g' \
- -e 's/.\[34m/<BLUE>/g' \
- -e 's/.\[35m/<MAGENTA>/g' \
- -e 's/.\[36m/<CYAN>/g' \
- -e 's/.\[m/<RESET>/g'
+ awk '
+ function name(n) {
+ if (n == 0) return "RESET";
+ if (n == 1) return "BOLD";
+ if (n == 30) return "BLACK";
+ if (n == 31) return "RED";
+ if (n == 32) return "GREEN";
+ if (n == 33) return "YELLOW";
+ if (n == 34) return "BLUE";
+ if (n == 35) return "MAGENTA";
+ if (n == 36) return "CYAN";
+ if (n == 37) return "WHITE";
+ if (n == 40) return "BLACK";
+ if (n == 41) return "BRED";
+ if (n == 42) return "BGREEN";
+ if (n == 43) return "BYELLOW";
+ if (n == 44) return "BBLUE";
+ if (n == 45) return "BMAGENTA";
+ if (n == 46) return "BCYAN";
+ if (n == 47) return "BWHITE";
+ }
+ {
+ while (match($0, /\033\[[0-9;]*m/) != 0) {
+ printf "%s<", substr($0, 1, RSTART-1);
+ codes = substr($0, RSTART+2, RLENGTH-3);
+ if (length(codes) == 0)
+ printf "%s", name(0)
+ else {
+ n = split(codes, ary, ";");
+ sep = "";
+ for (i = 1; i <= n; i++) {
+ printf "%s%s", sep, name(ary[i]);
+ sep = ";"
+ }
+ }
+ printf ">";
+ $0 = substr($0, RSTART + RLENGTH, length($0) - RSTART - RLENGTH + 1);
+ }
+ print
+ }
+ '
+}
+
+nul_to_q () {
+ perl -pe 'y/\000/Q/'
}
q_to_nul () {