summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/lib-git-p4.sh64
-rw-r--r--t/lib-git-svn.sh2
-rw-r--r--t/lib-httpd.sh1
-rw-r--r--t/lib-httpd/apache.conf4
-rwxr-xr-xt/lib-httpd/broken-smart-http.sh11
-rw-r--r--t/perf/README2
-rwxr-xr-xt/t0003-attributes.sh3
-rwxr-xr-xt/t0008-ignores.sh15
-rwxr-xr-xt/t0024-crlf-archive.sh6
-rwxr-xr-xt/t0030-stripspace.sh35
-rwxr-xr-xt/t1504-ceiling-dirs.sh17
-rwxr-xr-xt/t1507-rev-parse-upstream.sh4
-rwxr-xr-xt/t1509/prepare-chroot.sh2
-rwxr-xr-xt/t1510-repo-setup.sh19
-rwxr-xr-xt/t2003-checkout-cache-mkdir.sh169
-rwxr-xr-xt/t2200-add-update.sh16
-rwxr-xr-xt/t3200-branch.sh501
-rwxr-xr-xt/t3201-branch-contains.sh35
-rwxr-xr-xt/t3211-peel-ref.sh64
-rwxr-xr-xt/t3400-rebase.sh3
-rwxr-xr-xt/t3404-rebase-interactive.sh13
-rwxr-xr-xt/t3511-cherry-pick-x.sh219
-rwxr-xr-xt/t4001-diff-rename.sh54
-rwxr-xr-xt/t4014-format-patch.sh289
-rwxr-xr-xt/t4018-diff-funcname.sh5
-rwxr-xr-xt/t4034-diff-words.sh7
-rwxr-xr-xt/t4038-diff-combined.sh135
-rwxr-xr-xt/t4042-diff-textconv-caching.sh8
-rwxr-xr-xt/t4202-log.sh28
-rwxr-xr-xt/t4210-log-i18n.sh58
-rwxr-xr-xt/t5000-tar-tree.sh3
-rwxr-xr-xt/t5003-archive-zip.sh12
-rwxr-xr-xt/t5004-archive-corner-cases.sh102
-rw-r--r--t/t5004/empty.zipbin0 -> 62 bytes
-rwxr-xr-xt/t5304-prune.sh26
-rwxr-xr-xt/t5500-fetch-pack.sh9
-rwxr-xr-xt/t5503-tagfollow.sh64
-rwxr-xr-xt/t5512-ls-remote.sh12
-rwxr-xr-xt/t5516-fetch-push.sh134
-rwxr-xr-xt/t5520-pull.sh18
-rwxr-xr-xt/t5521-pull-options.sh27
-rwxr-xr-xt/t5541-http-push.sh3
-rwxr-xr-xt/t5551-http-fetch.sh5
-rwxr-xr-xt/t5700-clone-reference.sh18
-rwxr-xr-xt/t6009-rev-list-parent.sh13
-rwxr-xr-xt/t6012-rev-list-simplify.sh26
-rwxr-xr-xt/t7004-tag.sh12
-rwxr-xr-xt/t7060-wtstatus.sh1
-rwxr-xr-xt/t7062-wtstatus-ignorecase.sh20
-rwxr-xr-xt/t7400-submodule-basic.sh100
-rwxr-xr-xt/t7402-submodule-rebase.sh30
-rwxr-xr-xt/t7406-submodule-update.sh3
-rwxr-xr-xt/t7500-commit.sh6
-rwxr-xr-xt/t7502-commit.sh95
-rwxr-xr-xt/t7508-status.sh89
-rwxr-xr-xt/t7512-status-help.sh3
-rwxr-xr-xt/t7600-merge.sh60
-rwxr-xr-xt/t7800-difftool.sh390
-rwxr-xr-xt/t7811-grep-open.sh5
-rwxr-xr-xt/t9500-gitweb-standalone-no-errors.sh3
-rwxr-xr-xt/t9800-git-p4-basic.sh5
-rwxr-xr-xt/t9802-git-p4-filetype.sh117
-rwxr-xr-xt/t9806-git-p4-options.sh51
-rwxr-xr-xt/t9807-git-p4-submit.sh14
-rwxr-xr-xt/t9808-git-p4-chdir.sh41
-rwxr-xr-xt/t9809-git-p4-client-view.sh16
-rwxr-xr-xt/t9812-git-p4-wildcards.sh37
-rwxr-xr-xt/t9815-git-p4-submit-fail.sh11
-rwxr-xr-xt/t9903-bash-prompt.sh78
-rw-r--r--t/test-lib-functions.sh8
-rw-r--r--t/test-lib.sh9
71 files changed, 2652 insertions, 813 deletions
diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh
index 7061dce..2098b9b 100644
--- a/t/lib-git-p4.sh
+++ b/t/lib-git-p4.sh
@@ -8,7 +8,8 @@ TEST_NO_CREATE_REPO=NoThanks
. ./test-lib.sh
-if ! test_have_prereq PYTHON; then
+if ! test_have_prereq PYTHON
+then
skip_all='skipping git p4 tests; python not available'
test_done
fi
@@ -17,6 +18,24 @@ fi
test_done
}
+# On cygwin, the NT version of Perforce can be used. When giving
+# it paths, either on the command-line or in client specifications,
+# be sure to use the native windows form.
+#
+# Older versions of perforce were available compiled natively for
+# cygwin. Those do not accept native windows paths, so make sure
+# not to convert for them.
+native_path() {
+ path="$1" &&
+ if test_have_prereq CYGWIN && ! p4 -V | grep -q CYGWIN
+ then
+ path=$(cygpath --windows "$path")
+ else
+ path=$(test-path-utils real_path "$path")
+ fi &&
+ echo "$path"
+}
+
# Try to pick a unique port: guess a large number, then hope
# no more than one of each test is running.
#
@@ -32,7 +51,7 @@ P4EDITOR=:
export P4PORT P4CLIENT P4EDITOR
db="$TRASH_DIRECTORY/db"
-cli=$(test-path-utils real_path "$TRASH_DIRECTORY/cli")
+cli="$TRASH_DIRECTORY/cli"
git="$TRASH_DIRECTORY/git"
pidfile="$TRASH_DIRECTORY/p4d.pid"
@@ -40,8 +59,11 @@ start_p4d() {
mkdir -p "$db" "$cli" "$git" &&
rm -f "$pidfile" &&
(
- p4d -q -r "$db" -p $P4DPORT &
- echo $! >"$pidfile"
+ cd "$db" &&
+ {
+ p4d -q -p $P4DPORT &
+ echo $! >"$pidfile"
+ }
) &&
# This gives p4d a long time to start up, as it can be
@@ -74,15 +96,8 @@ start_p4d() {
fi
# build a client
- (
- cd "$cli" &&
- p4 client -i <<-EOF
- Client: client
- Description: client
- Root: $cli
- View: //depot/... //client/...
- EOF
- )
+ client_view "//depot/... //client/..." &&
+
return 0
}
@@ -123,13 +138,26 @@ marshal_dump() {
client_view() {
(
cat <<-EOF &&
- Client: client
- Description: client
+ Client: $P4CLIENT
+ Description: $P4CLIENT
Root: $cli
+ AltRoots: $(native_path "$cli")
+ LineEnd: unix
View:
EOF
- for arg ; do
- printf "\t$arg\n"
- done
+ printf "\t%s\n" "$@"
) | p4 client -i
}
+
+is_cli_file_writeable() {
+ # cygwin version of p4 does not set read-only attr,
+ # will be marked 444 but -w is true
+ file="$1" &&
+ if test_have_prereq CYGWIN && p4 -V | grep -q CYGWIN
+ then
+ stat=$(stat --format=%a "$file") &&
+ test $stat = 644
+ else
+ test -w "$file"
+ fi
+}
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 199f22c..c5e55b1 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -148,7 +148,7 @@ stop_httpd () {
convert_to_rev_db () {
"$PERL_PATH" -w -- - "$@" <<\EOF
use strict;
-@ARGV == 2 or die "Usage: convert_to_rev_db <input> <output>";
+@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
my $size = (stat($rd))[7];
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 02f442b..895b925 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -80,6 +80,7 @@ fi
prepare_httpd() {
mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH"
cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH"
+ cp "$TEST_PATH"/broken-smart-http.sh "$HTTPD_ROOT_PATH"
ln -s "$LIB_HTTPD_MODULE_PATH" "$HTTPD_ROOT_PATH/modules"
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index fe76e84..938b4cf 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -62,9 +62,13 @@ Alias /auth/dumb/ www/auth/dumb/
SetEnv GIT_COMMITTER_EMAIL custom@example.com
</LocationMatch>
ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1
+ScriptAlias /broken_smart/ broken-smart-http.sh/
<Directory ${GIT_EXEC_PATH}>
Options FollowSymlinks
</Directory>
+<Files broken-smart-http.sh>
+ Options ExecCGI
+</Files>
<Files ${GIT_EXEC_PATH}/git-http-backend>
Options ExecCGI
</Files>
diff --git a/t/lib-httpd/broken-smart-http.sh b/t/lib-httpd/broken-smart-http.sh
new file mode 100755
index 0000000..f7ebfff
--- /dev/null
+++ b/t/lib-httpd/broken-smart-http.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+printf "Content-Type: text/%s\n" "html"
+echo
+printf "%s\n" "001e# service=git-upload-pack"
+printf "%s" "0000"
+printf "%s%c%s%s\n" \
+ "00a58681d9f286a48b08f37b3a095330da16689e3693 HEAD" \
+ 0 \
+ " include-tag multi_ack_detailed multi_ack ofs-delta" \
+ " side-band side-band-64k thin-pack no-progress shallow no-done "
+printf "%s" "0000"
diff --git a/t/perf/README b/t/perf/README
index b2dbad4..c552f56 100644
--- a/t/perf/README
+++ b/t/perf/README
@@ -56,7 +56,7 @@ You can set the following variables (also in your config.mak):
GIT_PERF_REPEAT_COUNT
Number of times a test should be repeated for best-of-N
- measurements. Defaults to 5.
+ measurements. Defaults to 3.
GIT_PERF_MAKE_OPTS
Options to use when automatically building a git tree for
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 43b2513..0b98b6f 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -198,7 +198,8 @@ test_expect_success 'root subdir attribute test' '
test_expect_success 'negative patterns' '
echo "!f test=bar" >.gitattributes &&
- test_must_fail git check-attr test -- f
+ git check-attr test -- '"'"'!f'"'"' 2>errors &&
+ test_i18ngrep "Negative patterns are ignored" errors
'
test_expect_success 'patterns starting with exclamation' '
diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
index d7df719..9c1bde1 100755
--- a/t/t0008-ignores.sh
+++ b/t/t0008-ignores.sh
@@ -75,6 +75,16 @@ test_check_ignore () {
stderr_empty_on_success "$expect_code"
}
+# Runs the same code with 3 different levels of output verbosity,
+# expecting success each time. Takes advantage of the fact that
+# check-ignore --verbose output is the same as normal output except
+# for the extra first column.
+#
+# Arguments:
+# - (optional) prereqs for this test, e.g. 'SYMLINKS'
+# - test name
+# - output to expect from -v / --verbose mode
+# - code to run (should invoke test_check_ignore)
test_expect_success_multi () {
prereq=
if test $# -eq 4
@@ -128,6 +138,7 @@ test_expect_success 'setup' '
cat <<-\EOF >.gitignore &&
one
ignored-*
+ top-level-dir/
EOF
for dir in . a
do
@@ -167,6 +178,10 @@ test_expect_success 'setup' '
#
# test invalid inputs
+test_expect_success_multi '. corner-case' '' '
+ test_check_ignore . 1
+'
+
test_expect_success_multi 'empty command line' '' '
test_check_ignore "" 128 &&
stderr_contains "fatal: no path specified"
diff --git a/t/t0024-crlf-archive.sh b/t/t0024-crlf-archive.sh
index 5378787..4e9fa3c 100755
--- a/t/t0024-crlf-archive.sh
+++ b/t/t0024-crlf-archive.sh
@@ -3,12 +3,6 @@
test_description='respect crlf in git archive'
. ./test-lib.sh
-GIT_UNZIP=${GIT_UNZIP:-unzip}
-
-test_lazy_prereq UNZIP '
- "$GIT_UNZIP" -v
- test $? -ne 127
-'
test_expect_success setup '
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
index ccb0a3c..a8e84d8 100755
--- a/t/t0030-stripspace.sh
+++ b/t/t0030-stripspace.sh
@@ -397,4 +397,39 @@ test_expect_success 'strip comments, too' '
test -z "$(echo "# comment" | git stripspace -s)"
'
+test_expect_success 'strip comments with changed comment char' '
+ test ! -z "$(echo "; comment" | git -c core.commentchar=";" stripspace)" &&
+ test -z "$(echo "; comment" | git -c core.commentchar=";" stripspace -s)"
+'
+
+test_expect_success '-c with single line' '
+ printf "# foo\n" >expect &&
+ printf "foo" | git stripspace -c >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '-c with single line followed by empty line' '
+ printf "# foo\n#\n" >expect &&
+ printf "foo\n\n" | git stripspace -c >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '-c with newline only' '
+ printf "#\n" >expect &&
+ printf "\n" | git stripspace -c >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '--comment-lines with single line' '
+ printf "# foo\n" >expect &&
+ printf "foo" | git stripspace -c >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '-c with changed comment char' '
+ printf "; foo\n" >expect &&
+ printf "foo" | git -c core.commentchar=";" stripspace -c >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t1504-ceiling-dirs.sh b/t/t1504-ceiling-dirs.sh
index cce87a5..3d51615 100755
--- a/t/t1504-ceiling-dirs.sh
+++ b/t/t1504-ceiling-dirs.sh
@@ -44,6 +44,10 @@ test_prefix ceil_at_sub ""
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
test_prefix ceil_at_sub_slash ""
+if test_have_prereq SYMLINKS
+then
+ ln -s sub top
+fi
mkdir -p sub/dir || exit 1
cd sub/dir || exit 1
@@ -68,6 +72,19 @@ test_fail subdir_ceil_at_sub
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/"
test_fail subdir_ceil_at_sub_slash
+if test_have_prereq SYMLINKS
+then
+ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top"
+ test_fail subdir_ceil_at_top
+ GIT_CEILING_DIRECTORIES="$TRASH_ROOT/top/"
+ test_fail subdir_ceil_at_top_slash
+
+ GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top"
+ test_prefix subdir_ceil_at_top_no_resolve "sub/dir/"
+ GIT_CEILING_DIRECTORIES=":$TRASH_ROOT/top/"
+ test_prefix subdir_ceil_at_top_slash_no_resolve "sub/dir/"
+fi
+
GIT_CEILING_DIRECTORIES="$TRASH_ROOT/sub/dir"
test_prefix subdir_ceil_at_subdir "sub/dir/"
diff --git a/t/t1507-rev-parse-upstream.sh b/t/t1507-rev-parse-upstream.sh
index d6e5761..b27a720 100755
--- a/t/t1507-rev-parse-upstream.sh
+++ b/t/t1507-rev-parse-upstream.sh
@@ -54,6 +54,10 @@ test_expect_success 'my-side@{upstream} resolves to correct full name' '
test refs/remotes/origin/side = "$(full_name my-side@{u})"
'
+test_expect_success 'refs/heads/my-side@{upstream} does not resolve to my-side{upstream}' '
+ test_must_fail full_name refs/heads/my-side@{upstream}
+'
+
test_expect_success 'my-side@{u} resolves to correct commit' '
git checkout side &&
test_commit 5 &&
diff --git a/t/t1509/prepare-chroot.sh b/t/t1509/prepare-chroot.sh
index c5334a8..6269117 100755
--- a/t/t1509/prepare-chroot.sh
+++ b/t/t1509/prepare-chroot.sh
@@ -14,7 +14,7 @@ xmkdir() {
R="$1"
-[ -n "$R" ] || die "Usage: prepare-chroot.sh <root>"
+[ -n "$R" ] || die "usage: prepare-chroot.sh <root>"
[ -x git ] || die "This script needs to be executed at git source code's top directory"
[ -x /bin/busybox ] || die "You need busybox"
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 80aedfc..cf2ee78 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -517,6 +517,25 @@ test_expect_success '#16c: bare .git has no worktree' '
"$here/16c/.git" "(null)" "$here/16c/sub" "(null)"
'
+test_expect_success '#16d: bareness preserved across alias' '
+ setup_repo 16d unset "" unset &&
+ (
+ cd 16d/.git &&
+ test_must_fail git status &&
+ git config alias.st status &&
+ test_must_fail git st
+ )
+'
+
+test_expect_success '#16e: bareness preserved by --bare' '
+ setup_repo 16e unset "" unset &&
+ (
+ cd 16e/.git &&
+ test_must_fail git status &&
+ test_must_fail git --bare status
+ )
+'
+
test_expect_success '#17: GIT_WORK_TREE without explicit GIT_DIR is accepted (bare case)' '
# Just like #16.
setup_repo 17a unset "" true &&
diff --git a/t/t2003-checkout-cache-mkdir.sh b/t/t2003-checkout-cache-mkdir.sh
index 02a4fc5..ff163cf 100755
--- a/t/t2003-checkout-cache-mkdir.sh
+++ b/t/t2003-checkout-cache-mkdir.sh
@@ -12,85 +12,108 @@ the GIT controlled paths.
. ./test-lib.sh
-test_expect_success \
- 'setup' \
- 'mkdir path1 &&
- echo frotz >path0 &&
- echo rezrov >path1/file1 &&
- git update-index --add path0 path1/file1'
+test_expect_success 'setup' '
+ mkdir path1 &&
+ echo frotz >path0 &&
+ echo rezrov >path1/file1 &&
+ git update-index --add path0 path1/file1
+'
+
+test_expect_success SYMLINKS 'have symlink in place where dir is expected.' '
+ rm -fr path0 path1 &&
+ mkdir path2 &&
+ ln -s path2 path1 &&
+ git checkout-index -f -a &&
+ test ! -h path1 && test -d path1 &&
+ test -f path1/file1 && test ! -f path2/file1
+'
-test_expect_success SYMLINKS \
- 'have symlink in place where dir is expected.' \
- 'rm -fr path0 path1 &&
- mkdir path2 &&
- ln -s path2 path1 &&
- git checkout-index -f -a &&
- test ! -h path1 && test -d path1 &&
- test -f path1/file1 && test ! -f path2/file1'
+test_expect_success 'use --prefix=path2/' '
+ rm -fr path0 path1 path2 &&
+ mkdir path2 &&
+ git checkout-index --prefix=path2/ -f -a &&
+ test -f path2/path0 &&
+ test -f path2/path1/file1 &&
+ test ! -f path0 &&
+ test ! -f path1/file1
+'
+
+test_expect_success 'use --prefix=tmp-' '
+ rm -fr path0 path1 path2 tmp* &&
+ git checkout-index --prefix=tmp- -f -a &&
+ test -f tmp-path0 &&
+ test -f tmp-path1/file1 &&
+ test ! -f path0 &&
+ test ! -f path1/file1
+'
-test_expect_success \
- 'use --prefix=path2/' \
- 'rm -fr path0 path1 path2 &&
- mkdir path2 &&
- git checkout-index --prefix=path2/ -f -a &&
- test -f path2/path0 &&
- test -f path2/path1/file1 &&
- test ! -f path0 &&
- test ! -f path1/file1'
+test_expect_success 'use --prefix=tmp- but with a conflicting file and dir' '
+ rm -fr path0 path1 path2 tmp* &&
+ echo nitfol >tmp-path1 &&
+ mkdir tmp-path0 &&
+ git checkout-index --prefix=tmp- -f -a &&
+ test -f tmp-path0 &&
+ test -f tmp-path1/file1 &&
+ test ! -f path0 &&
+ test ! -f path1/file1
+'
-test_expect_success \
- 'use --prefix=tmp-' \
- 'rm -fr path0 path1 path2 tmp* &&
- git checkout-index --prefix=tmp- -f -a &&
- test -f tmp-path0 &&
- test -f tmp-path1/file1 &&
- test ! -f path0 &&
- test ! -f path1/file1'
+test_expect_success SYMLINKS 'use --prefix=tmp/orary/ where tmp is a symlink' '
+ rm -fr path0 path1 path2 tmp* &&
+ mkdir tmp1 tmp1/orary &&
+ ln -s tmp1 tmp &&
+ git checkout-index --prefix=tmp/orary/ -f -a &&
+ test -d tmp1/orary &&
+ test -f tmp1/orary/path0 &&
+ test -f tmp1/orary/path1/file1 &&
+ test -h tmp
+'
-test_expect_success \
- 'use --prefix=tmp- but with a conflicting file and dir' \
- 'rm -fr path0 path1 path2 tmp* &&
- echo nitfol >tmp-path1 &&
- mkdir tmp-path0 &&
- git checkout-index --prefix=tmp- -f -a &&
- test -f tmp-path0 &&
- test -f tmp-path1/file1 &&
- test ! -f path0 &&
- test ! -f path1/file1'
+test_expect_success SYMLINKS 'use --prefix=tmp/orary- where tmp is a symlink' '
+ rm -fr path0 path1 path2 tmp* &&
+ mkdir tmp1 &&
+ ln -s tmp1 tmp &&
+ git checkout-index --prefix=tmp/orary- -f -a &&
+ test -f tmp1/orary-path0 &&
+ test -f tmp1/orary-path1/file1 &&
+ test -h tmp
+'
-# Linus fix #1
-test_expect_success SYMLINKS \
- 'use --prefix=tmp/orary/ where tmp is a symlink' \
- 'rm -fr path0 path1 path2 tmp* &&
- mkdir tmp1 tmp1/orary &&
- ln -s tmp1 tmp &&
- git checkout-index --prefix=tmp/orary/ -f -a &&
- test -d tmp1/orary &&
- test -f tmp1/orary/path0 &&
- test -f tmp1/orary/path1/file1 &&
- test -h tmp'
+test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' '
+ rm -fr path0 path1 path2 tmp* &&
+ mkdir tmp1 &&
+ ln -s tmp1 tmp-path1 &&
+ git checkout-index --prefix=tmp- -f -a &&
+ test -f tmp-path0 &&
+ test ! -h tmp-path1 &&
+ test -d tmp-path1 &&
+ test -f tmp-path1/file1
+'
-# Linus fix #2
-test_expect_success SYMLINKS \
- 'use --prefix=tmp/orary- where tmp is a symlink' \
- 'rm -fr path0 path1 path2 tmp* &&
- mkdir tmp1 &&
- ln -s tmp1 tmp &&
- git checkout-index --prefix=tmp/orary- -f -a &&
- test -f tmp1/orary-path0 &&
- test -f tmp1/orary-path1/file1 &&
- test -h tmp'
+test_expect_success 'apply filter from working tree .gitattributes with --prefix' '
+ rm -fr path0 path1 path2 tmp* &&
+ mkdir path1 &&
+ mkdir tmp &&
+ git config filter.replace-all.smudge "sed -e s/./,/g" &&
+ git config filter.replace-all.clean cat &&
+ git config filter.replace-all.required true &&
+ echo "file1 filter=replace-all" >path1/.gitattributes &&
+ git checkout-index --prefix=tmp/ -f -a &&
+ echo frotz >expected &&
+ test_cmp expected tmp/path0 &&
+ echo ,,,,,, >expected &&
+ test_cmp expected tmp/path1/file1
+'
-# Linus fix #3
-test_expect_success SYMLINKS \
- 'use --prefix=tmp- where tmp-path1 is a symlink' \
- 'rm -fr path0 path1 path2 tmp* &&
- mkdir tmp1 &&
- ln -s tmp1 tmp-path1 &&
- git checkout-index --prefix=tmp- -f -a &&
- test -f tmp-path0 &&
- test ! -h tmp-path1 &&
- test -d tmp-path1 &&
- test -f tmp-path1/file1'
+test_expect_success 'apply CRLF filter from working tree .gitattributes with --prefix' '
+ rm -fr path0 path1 path2 tmp* &&
+ mkdir path1 &&
+ mkdir tmp &&
+ echo "file1 eol=crlf" >path1/.gitattributes &&
+ git checkout-index --prefix=tmp/ -f -a &&
+ echo rezrovQ >expected &&
+ tr \\015 Q <tmp/path1/file1 >actual &&
+ test_cmp expected actual
+'
test_done
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 4cdebda..c317254 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -80,6 +80,22 @@ test_expect_success 'change gets noticed' '
'
+# Note that this is scheduled to change in Git 2.0, when
+# "git add -u" will become full-tree by default.
+test_expect_success 'non-limited update in subdir leaves root alone' '
+ (
+ cd dir1 &&
+ echo even more >>sub2 &&
+ git add -u
+ ) &&
+ cat >expect <<-\EOF &&
+ check
+ top
+ EOF
+ git diff-files --name-only >actual &&
+ test_cmp expect actual
+'
+
test_expect_success SYMLINKS 'replace a file with a symlink' '
rm foo &&
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index 80e6be3..b08c9f2 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -7,20 +7,18 @@ test_description='git branch assorted tests'
. ./test-lib.sh
-test_expect_success \
- 'prepare a trivial repository' \
- 'echo Hello > A &&
- git update-index --add A &&
- git commit -m "Initial commit." &&
- echo World >> A &&
- git update-index --add A &&
- git commit -m "Second commit." &&
- HEAD=$(git rev-parse --verify HEAD)'
-
-test_expect_success \
- 'git branch --help should not have created a bogus branch' '
- test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
- test_path_is_missing .git/refs/heads/--help
+test_expect_success 'prepare a trivial repository' '
+ echo Hello >A &&
+ git update-index --add A &&
+ git commit -m "Initial commit." &&
+ echo World >>A &&
+ git update-index --add A &&
+ git commit -m "Second commit." &&
+ HEAD=$(git rev-parse --verify HEAD)'
+
+test_expect_success 'git branch --help should not have created a bogus branch' '
+ test_might_fail git branch --help </dev/null >/dev/null 2>/dev/null &&
+ test_path_is_missing .git/refs/heads/--help
'
test_expect_success 'branch -h in broken repository' '
@@ -34,63 +32,67 @@ test_expect_success 'branch -h in broken repository' '
test_i18ngrep "[Uu]sage" broken/usage
'
-test_expect_success \
- 'git branch abc should create a branch' \
- 'git branch abc && test_path_is_file .git/refs/heads/abc'
+test_expect_success 'git branch abc should create a branch' '
+ git branch abc && test_path_is_file .git/refs/heads/abc
+'
+
+test_expect_success 'git branch a/b/c should create a branch' '
+ git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c
+'
-test_expect_success \
- 'git branch a/b/c should create a branch' \
- 'git branch a/b/c && test_path_is_file .git/refs/heads/a/b/c'
+test_expect_success 'git branch HEAD should fail' '
+ test_must_fail git branch HEAD
+'
cat >expect <<EOF
$_z40 $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' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git branch -l d/e/f &&
- test_path_is_file .git/refs/heads/d/e/f &&
- test_path_is_file .git/logs/refs/heads/d/e/f &&
- test_cmp expect .git/logs/refs/heads/d/e/f'
-
-test_expect_success \
- 'git branch -d d/e/f should delete a branch and a log' \
- 'git branch -d d/e/f &&
- test_path_is_missing .git/refs/heads/d/e/f &&
- test_path_is_missing .git/logs/refs/heads/d/e/f'
-
-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 dumps usage' \
- 'test_expect_code 129 git branch -m 2>err &&
- test_i18ngrep "[Uu]sage: git branch" err'
-
-test_expect_success \
- 'git branch -m m m/m should work' \
- 'git branch -l m &&
- git branch -m m m/m &&
- test_path_is_file .git/logs/refs/heads/m/m'
-
-test_expect_success \
- 'git branch -m n/n n should work' \
- 'git branch -l n/n &&
+test_expect_success 'git branch -l d/e/f should create a branch and a log' '
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
+ git branch -l d/e/f &&
+ test_path_is_file .git/refs/heads/d/e/f &&
+ test_path_is_file .git/logs/refs/heads/d/e/f &&
+ test_cmp expect .git/logs/refs/heads/d/e/f
+'
+
+test_expect_success 'git branch -d d/e/f should delete a branch and a log' '
+ git branch -d d/e/f &&
+ test_path_is_missing .git/refs/heads/d/e/f &&
+ test_path_is_missing .git/logs/refs/heads/d/e/f
+'
+
+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 dumps usage' '
+ test_expect_code 128 git branch -m 2>err &&
+ test_i18ngrep "too many branches for a rename operation" err
+'
+
+test_expect_success 'git branch -m m m/m should work' '
+ git branch -l m &&
+ git branch -m m m/m &&
+ test_path_is_file .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_path_is_file .git/logs/refs/heads/n'
+ test_path_is_file .git/logs/refs/heads/n
+'
test_expect_success 'git branch -m o/o o should fail when o/p exists' '
git branch o/o &&
- git branch o/p &&
+ git branch o/p &&
test_must_fail git branch -m o/o o
'
@@ -248,19 +250,20 @@ mv .git/config-saved .git/config
git 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_expect_success 'git branch -m s/s s should work when s/t is deleted' '
+ git branch -l s/s &&
test_path_is_file .git/logs/refs/heads/s/s &&
- git branch -l s/t &&
+ git branch -l s/t &&
test_path_is_file .git/logs/refs/heads/s/t &&
- git branch -d s/t &&
- git branch -m s/s s &&
- test_path_is_file .git/logs/refs/heads/s'
+ git branch -d s/t &&
+ git branch -m s/s s &&
+ test_path_is_file .git/logs/refs/heads/s
+'
-test_expect_success 'config information was renamed, too' \
- "test $(git config branch.s.dummy) = Hello &&
- test_must_fail git config branch.s/s/dummy"
+test_expect_success 'config information was renamed, too' '
+ test $(git config branch.s.dummy) = Hello &&
+ test_must_fail git config branch.s/s/dummy
+'
test_expect_success 'deleting a symref' '
git branch target &&
@@ -281,8 +284,7 @@ test_expect_success 'deleting a dangling symref' '
test_i18ncmp expect actual
'
-test_expect_success 'renaming a symref is not allowed' \
-'
+test_expect_success 'renaming a symref is not allowed' '
git symbolic-ref refs/heads/master2 refs/heads/master &&
test_must_fail git branch -m master2 master3 &&
git symbolic-ref refs/heads/master2 &&
@@ -290,146 +292,179 @@ test_expect_success 'renaming a symref is not allowed' \
test_path_is_missing .git/refs/heads/master3
'
-test_expect_success SYMLINKS \
- '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 &&
- test_must_fail git branch -m u v
-'
-
-test_expect_success 'test tracking setup via --track' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my1 local/master &&
- test $(git config branch.my1.remote) = local &&
- test $(git config branch.my1.merge) = refs/heads/master'
-
-test_expect_success 'test tracking setup (non-wildcard, matching)' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my4 local/master &&
- test $(git config branch.my4.remote) = local &&
- test $(git config branch.my4.merge) = refs/heads/master'
-
-test_expect_success 'test tracking setup (non-wildcard, not matching)' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --track my5 local/master &&
- ! test "$(git config branch.my5.remote)" = local &&
- ! test "$(git config branch.my5.merge)" = refs/heads/master'
-
-test_expect_success 'test tracking setup via config' \
- 'git config branch.autosetupmerge true &&
- git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch my3 local/master &&
- test $(git config branch.my3.remote) = local &&
- test $(git config branch.my3.merge) = refs/heads/master'
-
-test_expect_success 'test overriding tracking setup via --no-track' \
- 'git config branch.autosetupmerge true &&
- git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/master || git fetch local) &&
- git branch --no-track my2 local/master &&
- git config branch.autosetupmerge false &&
- ! test "$(git config branch.my2.remote)" = local &&
- ! test "$(git config branch.my2.merge)" = refs/heads/master'
-
-test_expect_success 'no tracking without .fetch entries' \
- 'git config branch.autosetupmerge true &&
- git branch my6 s &&
- git config branch.automsetupmerge false &&
- test -z "$(git config branch.my6.remote)" &&
- test -z "$(git config branch.my6.merge)"'
-
-test_expect_success 'test tracking setup via --track but deeper' \
- 'git config remote.local.url . &&
- git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
- (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
- git branch --track my7 local/o/o &&
- test "$(git config branch.my7.remote)" = local &&
- test "$(git config branch.my7.merge)" = refs/heads/o/o'
-
-test_expect_success 'test deleting branch deletes branch config' \
- 'git branch -d my7 &&
- test -z "$(git config branch.my7.remote)" &&
- test -z "$(git config branch.my7.merge)"'
-
-test_expect_success 'test deleting branch without config' \
- 'git branch my7 s &&
- sha1=$(git rev-parse my7 | cut -c 1-7) &&
- echo "Deleted branch my7 (was $sha1)." >expect &&
- git branch -d my7 >actual 2>&1 &&
- test_i18ncmp expect actual'
-
-test_expect_success 'test --track without .fetch entries' \
- 'git branch --track my8 &&
- test "$(git config branch.my8.remote)" &&
- test "$(git config branch.my8.merge)"'
-
-test_expect_success \
- 'branch from non-branch HEAD w/autosetupmerge=always' \
- 'git config branch.autosetupmerge always &&
- git branch my9 HEAD^ &&
- git config branch.autosetupmerge false'
-
-test_expect_success \
- 'branch from non-branch HEAD w/--track causes failure' \
- 'test_must_fail git branch --track my10 HEAD^'
-
-test_expect_success \
- 'branch from tag w/--track causes failure' \
- 'git tag foobar &&
- test_must_fail git branch --track my11 foobar'
-
-test_expect_success 'use --set-upstream-to modify HEAD' \
- 'test_config branch.master.remote foo &&
- test_config branch.master.merge foo &&
- git branch my12
- git branch --set-upstream-to my12 &&
- test "$(git config branch.master.remote)" = "." &&
- test "$(git config branch.master.merge)" = "refs/heads/my12"'
-
-test_expect_success 'use --set-upstream-to modify a particular branch' \
- 'git branch my13
- git branch --set-upstream-to master my13 &&
- test "$(git config branch.my13.remote)" = "." &&
- test "$(git config branch.my13.merge)" = "refs/heads/master"'
-
-test_expect_success '--unset-upstream should fail if given a non-existent branch' \
- 'test_must_fail git branch --unset-upstream i-dont-exist'
-
-test_expect_success 'test --unset-upstream on HEAD' \
- 'git branch my14
- test_config branch.master.remote foo &&
- test_config branch.master.merge foo &&
- git branch --set-upstream-to my14 &&
- git branch --unset-upstream &&
- test_must_fail git config branch.master.remote &&
- test_must_fail git config branch.master.merge &&
- # fail for a branch without upstream set
- test_must_fail git branch --unset-upstream
-'
-
-test_expect_success 'test --unset-upstream on a particular branch' \
- 'git branch my15
- git branch --set-upstream-to master my14 &&
- git branch --unset-upstream my14 &&
- test_must_fail git config branch.my14.remote &&
- test_must_fail git config branch.my14.merge'
-
-test_expect_success '--set-upstream shows message when creating a new branch that exists as remote-tracking' \
- 'git update-ref refs/remotes/origin/master HEAD &&
- git branch --set-upstream origin/master 2>actual &&
- test_when_finished git update-ref -d refs/remotes/origin/master &&
- test_when_finished git branch -d origin/master &&
- cat >expected <<EOF &&
+test_expect_success SYMLINKS '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 &&
+ test_must_fail git branch -m u v
+'
+
+test_expect_success 'test tracking setup via --track' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --track my1 local/master &&
+ test $(git config branch.my1.remote) = local &&
+ test $(git config branch.my1.merge) = refs/heads/master
+'
+
+test_expect_success 'test tracking setup (non-wildcard, matching)' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/master:refs/remotes/local/master &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --track my4 local/master &&
+ test $(git config branch.my4.remote) = local &&
+ test $(git config branch.my4.merge) = refs/heads/master
+'
+
+test_expect_success 'test tracking setup (non-wildcard, not matching)' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --track my5 local/master &&
+ ! test "$(git config branch.my5.remote)" = local &&
+ ! test "$(git config branch.my5.merge)" = refs/heads/master
+'
+
+test_expect_success 'test tracking setup via config' '
+ git config branch.autosetupmerge true &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch my3 local/master &&
+ test $(git config branch.my3.remote) = local &&
+ test $(git config branch.my3.merge) = refs/heads/master
+'
+
+test_expect_success 'test overriding tracking setup via --no-track' '
+ git config branch.autosetupmerge true &&
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/master || git fetch local) &&
+ git branch --no-track my2 local/master &&
+ git config branch.autosetupmerge false &&
+ ! test "$(git config branch.my2.remote)" = local &&
+ ! test "$(git config branch.my2.merge)" = refs/heads/master
+'
+
+test_expect_success 'no tracking without .fetch entries' '
+ git config branch.autosetupmerge true &&
+ git branch my6 s &&
+ git config branch.automsetupmerge false &&
+ test -z "$(git config branch.my6.remote)" &&
+ test -z "$(git config branch.my6.merge)"
+'
+
+test_expect_success 'test tracking setup via --track but deeper' '
+ git config remote.local.url . &&
+ git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
+ (git show-ref -q refs/remotes/local/o/o || git fetch local) &&
+ git branch --track my7 local/o/o &&
+ test "$(git config branch.my7.remote)" = local &&
+ test "$(git config branch.my7.merge)" = refs/heads/o/o
+'
+
+test_expect_success 'test deleting branch deletes branch config' '
+ git branch -d my7 &&
+ test -z "$(git config branch.my7.remote)" &&
+ test -z "$(git config branch.my7.merge)"
+'
+
+test_expect_success 'test deleting branch without config' '
+ git branch my7 s &&
+ sha1=$(git rev-parse my7 | cut -c 1-7) &&
+ echo "Deleted branch my7 (was $sha1)." >expect &&
+ git branch -d my7 >actual 2>&1 &&
+ test_i18ncmp expect actual
+'
+
+test_expect_success 'test --track without .fetch entries' '
+ git branch --track my8 &&
+ test "$(git config branch.my8.remote)" &&
+ test "$(git config branch.my8.merge)"
+'
+
+test_expect_success 'branch from non-branch HEAD w/autosetupmerge=always' '
+ git config branch.autosetupmerge always &&
+ git branch my9 HEAD^ &&
+ git config branch.autosetupmerge false
+'
+
+test_expect_success 'branch from non-branch HEAD w/--track causes failure' '
+ test_must_fail git branch --track my10 HEAD^
+'
+
+test_expect_success 'branch from tag w/--track causes failure' '
+ git tag foobar &&
+ test_must_fail git branch --track my11 foobar
+'
+
+test_expect_success '--set-upstream-to fails on multiple branches' '
+ test_must_fail git branch --set-upstream-to master a b c
+'
+
+test_expect_success '--set-upstream-to fails on detached HEAD' '
+ git checkout HEAD^{} &&
+ test_must_fail git branch --set-upstream-to master &&
+ git checkout -
+'
+
+test_expect_success 'use --set-upstream-to modify HEAD' '
+ test_config branch.master.remote foo &&
+ test_config branch.master.merge foo &&
+ git branch my12
+ git branch --set-upstream-to my12 &&
+ test "$(git config branch.master.remote)" = "." &&
+ test "$(git config branch.master.merge)" = "refs/heads/my12"
+'
+
+test_expect_success 'use --set-upstream-to modify a particular branch' '
+ git branch my13
+ git branch --set-upstream-to master my13 &&
+ test "$(git config branch.my13.remote)" = "." &&
+ test "$(git config branch.my13.merge)" = "refs/heads/master"
+'
+
+test_expect_success '--unset-upstream should fail if given a non-existent branch' '
+ test_must_fail git branch --unset-upstream i-dont-exist
+'
+
+test_expect_success 'test --unset-upstream on HEAD' '
+ git branch my14
+ test_config branch.master.remote foo &&
+ test_config branch.master.merge foo &&
+ git branch --set-upstream-to my14 &&
+ git branch --unset-upstream &&
+ test_must_fail git config branch.master.remote &&
+ test_must_fail git config branch.master.merge &&
+ # fail for a branch without upstream set
+ test_must_fail git branch --unset-upstream
+'
+
+test_expect_success '--unset-upstream should fail on multiple branches' '
+ test_must_fail git branch --unset-upstream a b c
+'
+
+test_expect_success '--unset-upstream should fail on detached HEAD' '
+ git checkout HEAD^{} &&
+ test_must_fail git branch --unset-upstream &&
+ git checkout -
+'
+
+test_expect_success 'test --unset-upstream on a particular branch' '
+ git branch my15
+ git branch --set-upstream-to master my14 &&
+ git branch --unset-upstream my14 &&
+ test_must_fail git config branch.my14.remote &&
+ test_must_fail git config branch.my14.merge
+'
+
+test_expect_success '--set-upstream shows message when creating a new branch that exists as remote-tracking' '
+ git update-ref refs/remotes/origin/master HEAD &&
+ git branch --set-upstream origin/master 2>actual &&
+ test_when_finished git update-ref -d refs/remotes/origin/master &&
+ test_when_finished git branch -d origin/master &&
+ cat >expected <<EOF &&
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
If you wanted to make '"'master'"' track '"'origin/master'"', do this:
@@ -437,38 +472,38 @@ If you wanted to make '"'master'"' track '"'origin/master'"', do this:
git branch -d origin/master
git branch --set-upstream-to origin/master
EOF
- test_cmp expected actual
+ test_cmp expected actual
'
-test_expect_success '--set-upstream with two args only shows the deprecation message' \
- 'git branch --set-upstream master my13 2>actual &&
- test_when_finished git branch --unset-upstream master &&
- cat >expected <<EOF &&
+test_expect_success '--set-upstream with two args only shows the deprecation message' '
+ git branch --set-upstream master my13 2>actual &&
+ test_when_finished git branch --unset-upstream master &&
+ cat >expected <<EOF &&
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
EOF
- test_cmp expected actual
+ test_cmp expected actual
'
-test_expect_success '--set-upstream with one arg only shows the deprecation message if the branch existed' \
- 'git branch --set-upstream my13 2>actual &&
- test_when_finished git branch --unset-upstream my13 &&
- cat >expected <<EOF &&
+test_expect_success '--set-upstream with one arg only shows the deprecation message if the branch existed' '
+ git branch --set-upstream my13 2>actual &&
+ test_when_finished git branch --unset-upstream my13 &&
+ cat >expected <<EOF &&
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
EOF
- test_cmp expected actual
+ test_cmp expected actual
'
# Keep this test last, as it changes the current branch
cat >expect <<EOF
$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
EOF
-test_expect_success \
- 'git checkout -b g/h/i -l should create a branch and a log' \
- 'GIT_COMMITTER_DATE="2005-05-26 23:30" \
- git checkout -b g/h/i -l master &&
- test_path_is_file .git/refs/heads/g/h/i &&
- test_path_is_file .git/logs/refs/heads/g/h/i &&
- test_cmp expect .git/logs/refs/heads/g/h/i'
+test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' '
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
+ git checkout -b g/h/i -l master &&
+ test_path_is_file .git/refs/heads/g/h/i &&
+ test_path_is_file .git/logs/refs/heads/g/h/i &&
+ test_cmp expect .git/logs/refs/heads/g/h/i
+'
test_expect_success 'checkout -b makes reflog by default' '
git checkout master &&
@@ -739,7 +774,7 @@ test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
test_expect_success 'detect misconfigured autosetuprebase (no value)' '
git config --unset branch.autosetuprebase &&
- echo "[branch] autosetuprebase" >> .git/config &&
+ echo "[branch] autosetuprebase" >>.git/config &&
test_must_fail git branch &&
git config --unset branch.autosetuprebase
'
diff --git a/t/t3201-branch-contains.sh b/t/t3201-branch-contains.sh
index f86f4bc..141b061 100755
--- a/t/t3201-branch-contains.sh
+++ b/t/t3201-branch-contains.sh
@@ -55,6 +55,16 @@ test_expect_success 'branch --contains=side' '
'
+test_expect_success 'branch --contains with pattern implies --list' '
+
+ git branch --contains=master master >actual &&
+ {
+ echo " master"
+ } >expect &&
+ test_cmp expect actual
+
+'
+
test_expect_success 'side: branch --merged' '
git branch --merged >actual &&
@@ -66,6 +76,16 @@ test_expect_success 'side: branch --merged' '
'
+test_expect_success 'branch --merged with pattern implies --list' '
+
+ git branch --merged=side master >actual &&
+ {
+ echo " master"
+ } >expect &&
+ test_cmp expect actual
+
+'
+
test_expect_success 'side: branch --no-merged' '
git branch --no-merged >actual &&
@@ -95,4 +115,19 @@ test_expect_success 'master: branch --no-merged' '
'
+test_expect_success 'branch --no-merged with pattern implies --list' '
+
+ git branch --no-merged=master master >actual &&
+ >expect &&
+ test_cmp expect actual
+
+'
+
+test_expect_success 'implicit --list conflicts with modification options' '
+
+ test_must_fail git branch --contains=master -d &&
+ test_must_fail git branch --contains=master -m foo
+
+'
+
test_done
diff --git a/t/t3211-peel-ref.sh b/t/t3211-peel-ref.sh
new file mode 100755
index 0000000..d4d7792
--- /dev/null
+++ b/t/t3211-peel-ref.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+test_description='tests for the peel_ref optimization of packed-refs'
+. ./test-lib.sh
+
+test_expect_success 'create annotated tag in refs/tags' '
+ test_commit base &&
+ git tag -m annotated foo
+'
+
+test_expect_success 'create annotated tag outside of refs/tags' '
+ git update-ref refs/outside/foo refs/tags/foo
+'
+
+# This matches show-ref's output
+print_ref() {
+ echo "$(git rev-parse "$1") $1"
+}
+
+test_expect_success 'set up expected show-ref output' '
+ {
+ print_ref "refs/heads/master" &&
+ print_ref "refs/outside/foo" &&
+ print_ref "refs/outside/foo^{}" &&
+ print_ref "refs/tags/base" &&
+ print_ref "refs/tags/foo" &&
+ print_ref "refs/tags/foo^{}"
+ } >expect
+'
+
+test_expect_success 'refs are peeled outside of refs/tags (loose)' '
+ git show-ref -d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'refs are peeled outside of refs/tags (packed)' '
+ git pack-refs --all &&
+ git show-ref -d >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'create old-style pack-refs without fully-peeled' '
+ # Git no longer writes without fully-peeled, so we just write our own
+ # from scratch; we could also munge the existing file to remove the
+ # fully-peeled bits, but that seems even more prone to failure,
+ # especially if the format ever changes again. At least this way we
+ # know we are emulating exactly what an older git would have written.
+ {
+ echo "# pack-refs with: peeled " &&
+ print_ref "refs/heads/master" &&
+ print_ref "refs/outside/foo" &&
+ print_ref "refs/tags/base" &&
+ print_ref "refs/tags/foo" &&
+ echo "^$(git rev-parse "refs/tags/foo^{}")"
+ } >tmp &&
+ mv tmp .git/packed-refs
+'
+
+test_expect_success 'refs are peeled outside of refs/tags (old packed)' '
+ git show-ref -d >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 1de0ebd..f6cc102 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -138,8 +138,7 @@ test_expect_success 'rebase a single mode change' '
'
test_expect_success 'rebase is not broken by diff.renames' '
- git config diff.renames copies &&
- test_when_finished "git config --unset diff.renames" &&
+ test_config diff.renames copies &&
git checkout filemove &&
GIT_TRACE=1 git rebase force-3way
'
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 8462be1..a58406d 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -934,4 +934,17 @@ test_expect_success 'rebase --edit-todo can be used to modify todo' '
test L = $(git cat-file commit HEAD | sed -ne \$p)
'
+test_expect_success 'rebase -i respects core.commentchar' '
+ git reset --hard &&
+ git checkout E^0 &&
+ test_config core.commentchar "\\" &&
+ write_script remove-all-but-first.sh <<-\EOF &&
+ sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" &&
+ mv "$1.tmp" "$1"
+ EOF
+ test_set_editor "$(pwd)/remove-all-but-first.sh" &&
+ git rebase -i B &&
+ test B = $(git cat-file commit HEAD^ | sed -ne \$p)
+'
+
test_done
diff --git a/t/t3511-cherry-pick-x.sh b/t/t3511-cherry-pick-x.sh
new file mode 100755
index 0000000..f977279
--- /dev/null
+++ b/t/t3511-cherry-pick-x.sh
@@ -0,0 +1,219 @@
+#!/bin/sh
+
+test_description='Test cherry-pick -x and -s'
+
+. ./test-lib.sh
+
+pristine_detach () {
+ git cherry-pick --quit &&
+ git checkout -f "$1^0" &&
+ git read-tree -u --reset HEAD &&
+ git clean -d -f -f -q -x
+}
+
+mesg_one_line='base: commit message'
+
+mesg_no_footer="$mesg_one_line
+
+OneWordBodyThatsNotA-S-o-B"
+
+mesg_with_footer="$mesg_no_footer
+
+Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+Signed-off-by: A.U. Thor <author@example.com>
+Signed-off-by: B.U. Thor <buthor@example.com>"
+
+mesg_broken_footer="$mesg_no_footer
+
+The signed-off-by string should begin with the words Signed-off-by followed
+by a colon and space, and then the signers name and email address. e.g.
+Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+
+mesg_with_footer_sob="$mesg_with_footer
+Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+
+mesg_with_cherry_footer="$mesg_with_footer_sob
+(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
+Tested-by: C.U. Thor <cuthor@example.com>"
+
+
+test_expect_success setup '
+ git config advice.detachedhead false &&
+ echo unrelated >unrelated &&
+ git add unrelated &&
+ test_commit initial foo a &&
+ test_commit "$mesg_one_line" foo b mesg-one-line &&
+ git reset --hard initial &&
+ test_commit "$mesg_no_footer" foo b mesg-no-footer &&
+ git reset --hard initial &&
+ test_commit "$mesg_broken_footer" foo b mesg-broken-footer &&
+ git reset --hard initial &&
+ test_commit "$mesg_with_footer" foo b mesg-with-footer &&
+ git reset --hard initial &&
+ test_commit "$mesg_with_footer_sob" foo b mesg-with-footer-sob &&
+ git reset --hard initial &&
+ test_commit "$mesg_with_cherry_footer" foo b mesg-with-cherry-footer &&
+ pristine_detach initial &&
+ test_commit conflicting unrelated
+'
+
+test_expect_success 'cherry-pick -x inserts blank line after one line subject' '
+ pristine_detach initial &&
+ sha1=`git rev-parse mesg-one-line^0` &&
+ git cherry-pick -x mesg-one-line &&
+ cat <<-EOF >expect &&
+ $mesg_one_line
+
+ (cherry picked from commit $sha1)
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -s inserts blank line after one line subject' '
+ pristine_detach initial &&
+ git cherry-pick -s mesg-one-line &&
+ cat <<-EOF >expect &&
+ $mesg_one_line
+
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -s inserts blank line after non-conforming footer' '
+ pristine_detach initial &&
+ git cherry-pick -s mesg-broken-footer &&
+ cat <<-EOF >expect &&
+ $mesg_broken_footer
+
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -x inserts blank line when conforming footer not found' '
+ pristine_detach initial &&
+ sha1=`git rev-parse mesg-no-footer^0` &&
+ git cherry-pick -x mesg-no-footer &&
+ cat <<-EOF >expect &&
+ $mesg_no_footer
+
+ (cherry picked from commit $sha1)
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -s inserts blank line when conforming footer not found' '
+ pristine_detach initial &&
+ git cherry-pick -s mesg-no-footer &&
+ cat <<-EOF >expect &&
+ $mesg_no_footer
+
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -x -s inserts blank line when conforming footer not found' '
+ pristine_detach initial &&
+ sha1=`git rev-parse mesg-no-footer^0` &&
+ git cherry-pick -x -s mesg-no-footer &&
+ cat <<-EOF >expect &&
+ $mesg_no_footer
+
+ (cherry picked from commit $sha1)
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -s adds sob when last sob doesnt match committer' '
+ pristine_detach initial &&
+ git cherry-pick -s mesg-with-footer &&
+ cat <<-EOF >expect &&
+ $mesg_with_footer
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -x -s adds sob when last sob doesnt match committer' '
+ pristine_detach initial &&
+ sha1=`git rev-parse mesg-with-footer^0` &&
+ git cherry-pick -x -s mesg-with-footer &&
+ cat <<-EOF >expect &&
+ $mesg_with_footer
+ (cherry picked from commit $sha1)
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -s refrains from adding duplicate trailing sob' '
+ pristine_detach initial &&
+ git cherry-pick -s mesg-with-footer-sob &&
+ cat <<-EOF >expect &&
+ $mesg_with_footer_sob
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -x -s adds sob even when trailing sob exists for committer' '
+ pristine_detach initial &&
+ sha1=`git rev-parse mesg-with-footer-sob^0` &&
+ git cherry-pick -x -s mesg-with-footer-sob &&
+ cat <<-EOF >expect &&
+ $mesg_with_footer_sob
+ (cherry picked from commit $sha1)
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -x treats "(cherry picked from..." line as part of footer' '
+ pristine_detach initial &&
+ sha1=`git rev-parse mesg-with-cherry-footer^0` &&
+ git cherry-pick -x mesg-with-cherry-footer &&
+ cat <<-EOF >expect &&
+ $mesg_with_cherry_footer
+ (cherry picked from commit $sha1)
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -s treats "(cherry picked from..." line as part of footer' '
+ pristine_detach initial &&
+ git cherry-pick -s mesg-with-cherry-footer &&
+ cat <<-EOF >expect &&
+ $mesg_with_cherry_footer
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'cherry-pick -x -s treats "(cherry picked from..." line as part of footer' '
+ pristine_detach initial &&
+ sha1=`git rev-parse mesg-with-cherry-footer^0` &&
+ git cherry-pick -x -s mesg-with-cherry-footer &&
+ cat <<-EOF >expect &&
+ $mesg_with_cherry_footer
+ (cherry picked from commit $sha1)
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+ EOF
+ git log -1 --pretty=format:%B >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh
index 844277c..2f327b7 100755
--- a/t/t4001-diff-rename.sh
+++ b/t/t4001-diff-rename.sh
@@ -102,4 +102,58 @@ test_expect_success 'setup for many rename source candidates' '
grep warning actual.err
'
+test_expect_success 'rename pretty print with nothing in common' '
+ mkdir -p a/b/ &&
+ : >a/b/c &&
+ git add a/b/c &&
+ git commit -m "create a/b/c" &&
+ mkdir -p c/b/ &&
+ git mv a/b/c c/b/a &&
+ git commit -m "a/b/c -> c/b/a" &&
+ git diff -M --summary HEAD^ HEAD >output &&
+ test_i18ngrep " a/b/c => c/b/a " output &&
+ git diff -M --stat HEAD^ HEAD >output &&
+ test_i18ngrep " a/b/c => c/b/a " output
+'
+
+test_expect_success 'rename pretty print with common prefix' '
+ mkdir -p c/d &&
+ git mv c/b/a c/d/e &&
+ git commit -m "c/b/a -> c/d/e" &&
+ git diff -M --summary HEAD^ HEAD >output &&
+ test_i18ngrep " c/{b/a => d/e} " output &&
+ git diff -M --stat HEAD^ HEAD >output &&
+ test_i18ngrep " c/{b/a => d/e} " output
+'
+
+test_expect_success 'rename pretty print with common suffix' '
+ mkdir d &&
+ git mv c/d/e d/e &&
+ git commit -m "c/d/e -> d/e" &&
+ git diff -M --summary HEAD^ HEAD >output &&
+ test_i18ngrep " {c/d => d}/e " output &&
+ git diff -M --stat HEAD^ HEAD >output &&
+ test_i18ngrep " {c/d => d}/e " output
+'
+
+test_expect_success 'rename pretty print with common prefix and suffix' '
+ mkdir d/f &&
+ git mv d/e d/f/e &&
+ git commit -m "d/e -> d/f/e" &&
+ git diff -M --summary HEAD^ HEAD >output &&
+ test_i18ngrep " d/{ => f}/e " output &&
+ git diff -M --stat HEAD^ HEAD >output &&
+ test_i18ngrep " d/{ => f}/e " output
+'
+
+test_expect_success 'rename pretty print common prefix and suffix overlap' '
+ mkdir d/f/f &&
+ git mv d/f/e d/f/f/e &&
+ git commit -m "d/f/e d/f/f/e" &&
+ git diff -M --summary HEAD^ HEAD >output &&
+ test_i18ngrep " d/f/{ => f}/e " output &&
+ git diff -M --stat HEAD^ HEAD >output &&
+ test_i18ngrep " d/f/{ => f}/e " output
+'
+
test_done
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 7fa3647..b993dae 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -837,25 +837,26 @@ Subject: [PATCH] =?UTF-8?q?f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
=?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
=?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
=?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=
- =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3?=
- =?UTF-8?q?=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
- =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3?=
- =?UTF-8?q?=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
+ =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
=?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
=?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
=?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=
- =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3?=
- =?UTF-8?q?=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
- =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3?=
- =?UTF-8?q?=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
+ =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
=?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
=?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
=?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=
- =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3?=
- =?UTF-8?q?=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
- =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3?=
- =?UTF-8?q?=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
- =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
+ =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
+ =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
+ =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
+ =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=
+ =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=
+ =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
+ =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=
+ =?UTF-8?q?bar?=
EOF
test_expect_success 'format-patch wraps extremely long subject (rfc2047)' '
rm -rf patches/ &&
@@ -971,6 +972,268 @@ test_expect_success 'empty subject prefix does not have extra space' '
test_cmp expect actual
'
+append_signoff()
+{
+ C=$(git commit-tree HEAD^^{tree} -p HEAD) &&
+ git format-patch --stdout --signoff $C^..$C >append_signoff.patch &&
+ sed -n -e "1,/^---$/p" append_signoff.patch |
+ egrep -n "^Subject|Sign|^$"
+}
+
+test_expect_success 'signoff: commit with no body' '
+ append_signoff </dev/null >actual &&
+ cat <<\EOF | sed "s/EOL$//" >expected &&
+4:Subject: [PATCH] EOL
+8:
+9:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: commit with only subject' '
+ echo subject | append_signoff >actual &&
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+9:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: commit with only subject that does not end with NL' '
+ printf subject | append_signoff >actual &&
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+9:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: no existing signoffs' '
+ append_signoff <<\EOF >actual &&
+subject
+
+body
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:
+11:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: no existing signoffs and no trailing NL' '
+ printf "subject\n\nbody" | append_signoff >actual &&
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:
+11:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: some random signoff' '
+ append_signoff <<\EOF >actual &&
+subject
+
+body
+
+Signed-off-by: my@house
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:
+11:Signed-off-by: my@house
+12:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: misc conforming footer elements' '
+ append_signoff <<\EOF >actual &&
+subject
+
+body
+
+Signed-off-by: my@house
+(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)
+Tested-by: Some One <someone@example.com>
+Bug: 1234
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:
+11:Signed-off-by: my@house
+15:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: some random signoff-alike' '
+ append_signoff <<\EOF >actual &&
+subject
+
+body
+Fooled-by-me: my@house
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+11:
+12:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: not really a signoff' '
+ append_signoff <<\EOF >actual &&
+subject
+
+I want to mention about Signed-off-by: here.
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+9:I want to mention about Signed-off-by: here.
+10:
+11:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: not really a signoff (2)' '
+ append_signoff <<\EOF >actual &&
+subject
+
+My unfortunate
+Signed-off-by: example happens to be wrapped here.
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:Signed-off-by: example happens to be wrapped here.
+11:
+12:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: valid S-o-b paragraph in the middle' '
+ append_signoff <<\EOF >actual &&
+subject
+
+Signed-off-by: my@house
+Signed-off-by: your@house
+
+A lot of houses.
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+9:Signed-off-by: my@house
+10:Signed-off-by: your@house
+11:
+13:
+14:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: the same signoff at the end' '
+ append_signoff <<\EOF >actual &&
+subject
+
+body
+
+Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:
+11:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: the same signoff at the end, no trailing NL' '
+ printf "subject\n\nSigned-off-by: C O Mitter <committer@example.com>" |
+ append_signoff >actual &&
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+9:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: the same signoff NOT at the end' '
+ append_signoff <<\EOF >actual &&
+subject
+
+body
+
+Signed-off-by: C O Mitter <committer@example.com>
+Signed-off-by: my@house
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:
+11:Signed-off-by: C O Mitter <committer@example.com>
+12:Signed-off-by: my@house
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: detect garbage in non-conforming footer' '
+ append_signoff <<\EOF >actual &&
+subject
+
+body
+
+Tested-by: my@house
+Some Trash
+Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:
+13:Signed-off-by: C O Mitter <committer@example.com>
+14:
+15:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'signoff: footer begins with non-signoff without @ sign' '
+ append_signoff <<\EOF >actual &&
+subject
+
+body
+
+Reviewed-id: Noone
+Tested-by: my@house
+Change-id: Ideadbeef
+Signed-off-by: C O Mitter <committer@example.com>
+Bug: 1234
+EOF
+ cat >expected <<\EOF &&
+4:Subject: [PATCH] subject
+8:
+10:
+14:Signed-off-by: C O Mitter <committer@example.com>
+EOF
+ test_cmp expected actual
+'
+
test_expect_success 'format patch ignores color.ui' '
test_unconfig color.ui &&
git format-patch --stdout -1 >expect &&
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 082d3e8..38a092a 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -93,11 +93,6 @@ sed -e '
s/song;/song();/
' <Beer.perl >Beer-correct.perl
-test_config () {
- git config "$1" "$2" &&
- test_when_finished "git config --unset $1"
-}
-
test_expect_funcname () {
lang=${2-java}
test_expect_code 1 git diff --no-index -U1 \
diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 40ab333..f2f55fc 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -230,7 +230,7 @@ test_expect_success '.gitattributes override config' '
'
test_expect_success 'setup: remove diff driver regex' '
- test_might_fail git config --unset diff.testdriver.wordRegex
+ test_unconfig diff.testdriver.wordRegex
'
test_expect_success 'use configured regex' '
@@ -335,8 +335,7 @@ test_expect_success 'word-diff with diff.sbe' '
c
EOF
- test_when_finished "git config --unset diff.suppress-blank-empty" &&
- git config diff.suppress-blank-empty true &&
+ test_config diff.suppress-blank-empty true &&
word_diff --word-diff=plain
'
@@ -368,7 +367,7 @@ test_expect_success 'setup history with two files' '
test_expect_success 'wordRegex for the first file does not apply to the second' '
echo "*.tex diff=tex" >.gitattributes &&
- git config diff.tex.wordRegex "[a-z]+|." &&
+ test_config diff.tex.wordRegex "[a-z]+|." &&
cat >expect <<-\EOF &&
diff --git a/a.tex b/a.tex
--- a/a.tex
diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh
index 40277c7..b7e16a7 100755
--- a/t/t4038-diff-combined.sh
+++ b/t/t4038-diff-combined.sh
@@ -3,6 +3,7 @@
test_description='combined diff'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/diff-lib.sh
setup_helper () {
one=$1 branch=$2 side=$3 &&
@@ -89,4 +90,138 @@ test_expect_success 'diagnose truncated file' '
grep "diff --cc file" out
'
+test_expect_success 'setup for --cc --raw' '
+ blob=$(echo file | git hash-object --stdin -w) &&
+ base_tree=$(echo "100644 blob $blob file" | git mktree) &&
+ trees= &&
+ for i in `test_seq 1 40`
+ do
+ blob=$(echo file$i | git hash-object --stdin -w) &&
+ trees="$trees$(echo "100644 blob $blob file" | git mktree)$LF"
+ done
+'
+
+test_expect_success 'check --cc --raw with four trees' '
+ four_trees=$(echo "$trees" | sed -e 4q) &&
+ git diff --cc --raw $four_trees $base_tree >out &&
+ # Check for four leading colons in the output:
+ grep "^::::[^:]" out
+'
+
+test_expect_success 'check --cc --raw with forty trees' '
+ git diff --cc --raw $trees $base_tree >out &&
+ # Check for forty leading colons in the output:
+ grep "^::::::::::::::::::::::::::::::::::::::::[^:]" out
+'
+
+test_expect_success 'setup combined ignore spaces' '
+ git checkout master &&
+ >test &&
+ git add test &&
+ git commit -m initial &&
+
+ tr -d Q <<-\EOF >test &&
+ always coalesce
+ eol space coalesce Q
+ space change coalesce
+ all spa ces coalesce
+ eol spaces Q
+ space change
+ all spa ces
+ EOF
+ git commit -m "test space change" -a &&
+
+ git checkout -b side HEAD^ &&
+ tr -d Q <<-\EOF >test &&
+ always coalesce
+ eol space coalesce
+ space change coalesce
+ all spaces coalesce
+ eol spaces
+ space change
+ all spaces
+ EOF
+ git commit -m "test other space changes" -a &&
+
+ test_must_fail git merge master &&
+ tr -d Q <<-\EOF >test &&
+ eol spaces Q
+ space change
+ all spa ces
+ EOF
+ git commit -m merged -a
+'
+
+test_expect_success 'check combined output (no ignore space)' '
+ git show >actual.tmp &&
+ sed -e "1,/^@@@/d" < actual.tmp >actual &&
+ tr -d Q <<-\EOF >expected &&
+ --always coalesce
+ - eol space coalesce
+ - space change coalesce
+ - all spaces coalesce
+ - eol spaces
+ - space change
+ - all spaces
+ -eol space coalesce Q
+ -space change coalesce
+ -all spa ces coalesce
+ + eol spaces Q
+ + space change
+ + all spa ces
+ EOF
+ compare_diff_patch expected actual
+'
+
+test_expect_success 'check combined output (ignore space at eol)' '
+ git show --ignore-space-at-eol >actual.tmp &&
+ sed -e "1,/^@@@/d" < actual.tmp >actual &&
+ tr -d Q <<-\EOF >expected &&
+ --always coalesce
+ --eol space coalesce
+ - space change coalesce
+ - all spaces coalesce
+ -space change coalesce
+ -all spa ces coalesce
+ eol spaces Q
+ - space change
+ - all spaces
+ + space change
+ + all spa ces
+ EOF
+ compare_diff_patch expected actual
+'
+
+test_expect_success 'check combined output (ignore space change)' '
+ git show -b >actual.tmp &&
+ sed -e "1,/^@@@/d" < actual.tmp >actual &&
+ tr -d Q <<-\EOF >expected &&
+ --always coalesce
+ --eol space coalesce
+ --space change coalesce
+ - all spaces coalesce
+ -all spa ces coalesce
+ eol spaces Q
+ space change
+ - all spaces
+ + all spa ces
+ EOF
+ compare_diff_patch expected actual
+'
+
+test_expect_success 'check combined output (ignore all spaces)' '
+ git show -w >actual.tmp &&
+ sed -e "1,/^@@@/d" < actual.tmp >actual &&
+ tr -d Q <<-\EOF >expected &&
+ --always coalesce
+ --eol space coalesce
+ --space change coalesce
+ --all spaces coalesce
+ eol spaces Q
+ space change
+ all spa ces
+ EOF
+ compare_diff_patch expected actual
+'
+
test_done
diff --git a/t/t4042-diff-textconv-caching.sh b/t/t4042-diff-textconv-caching.sh
index 91f8198..04a44d5 100755
--- a/t/t4042-diff-textconv-caching.sh
+++ b/t/t4042-diff-textconv-caching.sh
@@ -106,4 +106,12 @@ test_expect_success 'switching diff driver produces correct results' '
test_cmp expect actual
'
+# The point here is to test that we can log the notes cache and still use it to
+# produce a diff later (older versions of git would segfault on this). It's
+# much more likely to come up in the real world with "log --all -p", but using
+# --no-walk lets us reliably reproduce the order of traversal.
+test_expect_success 'log notes cache and still use cache for -p' '
+ git log --no-walk -p refs/notes/textconv/magic HEAD
+'
+
test_done
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index fa686b8..9243a97 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -419,8 +419,6 @@ test_expect_success 'log --graph with merge' '
'
test_expect_success 'log.decorate configuration' '
- test_might_fail git config --unset-all log.decorate &&
-
git log --oneline >expect.none &&
git log --oneline --decorate >expect.short &&
git log --oneline --decorate=full >expect.full &&
@@ -429,8 +427,7 @@ test_expect_success 'log.decorate configuration' '
git log --oneline >actual &&
test_cmp expect.short actual &&
- git config --unset-all log.decorate &&
- git config log.decorate true &&
+ test_config log.decorate true &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --decorate=full >actual &&
@@ -438,8 +435,7 @@ test_expect_success 'log.decorate configuration' '
git log --oneline --decorate=no >actual &&
test_cmp expect.none actual &&
- git config --unset-all log.decorate &&
- git config log.decorate no &&
+ test_config log.decorate no &&
git log --oneline >actual &&
test_cmp expect.none actual &&
git log --oneline --decorate >actual &&
@@ -447,8 +443,7 @@ test_expect_success 'log.decorate configuration' '
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
- git config --unset-all log.decorate &&
- git config log.decorate 1 &&
+ test_config log.decorate 1 &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --decorate=full >actual &&
@@ -456,8 +451,7 @@ test_expect_success 'log.decorate configuration' '
git log --oneline --decorate=no >actual &&
test_cmp expect.none actual &&
- git config --unset-all log.decorate &&
- git config log.decorate short &&
+ test_config log.decorate short &&
git log --oneline >actual &&
test_cmp expect.short actual &&
git log --oneline --no-decorate >actual &&
@@ -465,8 +459,7 @@ test_expect_success 'log.decorate configuration' '
git log --oneline --decorate=full >actual &&
test_cmp expect.full actual &&
- git config --unset-all log.decorate &&
- git config log.decorate full &&
+ test_config log.decorate full &&
git log --oneline >actual &&
test_cmp expect.full actual &&
git log --oneline --no-decorate >actual &&
@@ -474,16 +467,15 @@ test_expect_success 'log.decorate configuration' '
git log --oneline --decorate >actual &&
test_cmp expect.short actual
- git config --unset-all log.decorate &&
+ test_unconfig log.decorate &&
git log --pretty=raw >expect.raw &&
- git config log.decorate full &&
+ test_config log.decorate full &&
git log --pretty=raw >actual &&
test_cmp expect.raw actual
'
test_expect_success 'reflog is expected format' '
- test_might_fail git config --remove-section log &&
git log -g --abbrev-commit --pretty=oneline >expect &&
git reflog >actual &&
test_cmp expect actual
@@ -496,10 +488,6 @@ test_expect_success 'whatchanged is expected format' '
'
test_expect_success 'log.abbrevCommit configuration' '
- test_when_finished "git config --unset log.abbrevCommit" &&
-
- test_might_fail git config --unset log.abbrevCommit &&
-
git log --abbrev-commit >expect.log.abbrev &&
git log --no-abbrev-commit >expect.log.full &&
git log --pretty=raw >expect.log.raw &&
@@ -508,7 +496,7 @@ test_expect_success 'log.abbrevCommit configuration' '
git whatchanged --abbrev-commit >expect.whatchanged.abbrev &&
git whatchanged --no-abbrev-commit >expect.whatchanged.full &&
- git config log.abbrevCommit true &&
+ test_config log.abbrevCommit true &&
git log >actual &&
test_cmp expect.log.abbrev actual &&
diff --git a/t/t4210-log-i18n.sh b/t/t4210-log-i18n.sh
new file mode 100755
index 0000000..52a7472
--- /dev/null
+++ b/t/t4210-log-i18n.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+test_description='test log with i18n features'
+. ./test-lib.sh
+
+# two forms of é
+utf8_e=$(printf '\303\251')
+latin1_e=$(printf '\351')
+
+test_expect_success 'create commits in different encodings' '
+ test_tick &&
+ cat >msg <<-EOF &&
+ utf8
+
+ t${utf8_e}st
+ EOF
+ git add msg &&
+ git -c i18n.commitencoding=utf8 commit -F msg &&
+ cat >msg <<-EOF &&
+ latin1
+
+ t${latin1_e}st
+ EOF
+ git add msg &&
+ git -c i18n.commitencoding=ISO-8859-1 commit -F msg
+'
+
+test_expect_success 'log --grep searches in log output encoding (utf8)' '
+ cat >expect <<-\EOF &&
+ latin1
+ utf8
+ EOF
+ git log --encoding=utf8 --format=%s --grep=$utf8_e >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --grep searches in log output encoding (latin1)' '
+ cat >expect <<-\EOF &&
+ latin1
+ utf8
+ EOF
+ git log --encoding=ISO-8859-1 --format=%s --grep=$latin1_e >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --grep does not find non-reencoded values (utf8)' '
+ >expect &&
+ git log --encoding=utf8 --format=%s --grep=$latin1_e >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'log --grep does not find non-reencoded values (latin1)' '
+ >expect &&
+ git log --encoding=ISO-8859-1 --format=%s --grep=$utf8_e >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index e7c240f..3fbd366 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -212,7 +212,8 @@ test_expect_success 'git-archive --prefix=olde-' '
test_expect_success 'setup tar filters' '
git config tar.tar.foo.command "tr ab ba" &&
git config tar.bar.command "tr ab ba" &&
- git config tar.bar.remote true
+ git config tar.bar.remote true &&
+ git config tar.invalid baz
'
test_expect_success 'archive --list mentions user filter' '
diff --git a/t/t5003-archive-zip.sh b/t/t5003-archive-zip.sh
index 7cfe9ca..4e7b05d 100755
--- a/t/t5003-archive-zip.sh
+++ b/t/t5003-archive-zip.sh
@@ -3,15 +3,9 @@
test_description='git archive --format=zip test'
. ./test-lib.sh
-GIT_UNZIP=${GIT_UNZIP:-unzip}
SUBSTFORMAT=%H%n
-test_lazy_prereq UNZIP '
- "$GIT_UNZIP" -v
- test $? -ne 127
-'
-
test_lazy_prereq UNZIP_SYMLINKS '
(
mkdir unzip-symlinks &&
@@ -76,6 +70,12 @@ test_expect_success \
git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
git commit-tree $treeid </dev/null)'
+test_expect_success 'setup export-subst' '
+ echo "substfile?" export-subst >>.git/info/attributes &&
+ git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
+ >a/substfile1
+'
+
test_expect_success \
'create bare clone' \
'git clone --bare . bare.git &&
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
new file mode 100755
index 0000000..cdb7d7a
--- /dev/null
+++ b/t/t5004-archive-corner-cases.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+
+test_description='test corner cases of git-archive'
+. ./test-lib.sh
+
+test_expect_success 'create commit with empty tree' '
+ git commit --allow-empty -m foo
+'
+
+# Make a dir and clean it up afterwards
+make_dir() {
+ mkdir "$1" &&
+ test_when_finished "rm -rf '$1'"
+}
+
+# Check that the dir given in "$1" contains exactly the
+# set of paths given as arguments.
+check_dir() {
+ dir=$1; shift
+ {
+ echo "$dir" &&
+ for i in "$@"; do
+ echo "$dir/$i"
+ done
+ } | sort >expect &&
+ find "$dir" -print | sort >actual &&
+ test_cmp expect actual
+}
+
+test_expect_success 'tar archive of empty tree is empty' '
+ git archive --format=tar HEAD >empty.tar &&
+ make_dir extract &&
+ "$TAR" xf empty.tar -C extract &&
+ check_dir extract
+'
+
+test_expect_success 'tar archive of empty tree with prefix' '
+ git archive --format=tar --prefix=foo/ HEAD >prefix.tar &&
+ make_dir extract &&
+ "$TAR" xf prefix.tar -C extract &&
+ check_dir extract foo
+'
+
+test_expect_success UNZIP 'zip archive of empty tree is empty' '
+ # Detect the exit code produced when our particular flavor of unzip
+ # sees an empty archive. Infozip will generate a warning and exit with
+ # code 1. But in the name of sanity, we do not expect other unzip
+ # implementations to do the same thing (it would be perfectly
+ # reasonable to exit 0, for example).
+ #
+ # This makes our test less rigorous on some platforms (unzip may not
+ # handle the empty repo at all, making our later check of its exit code
+ # a no-op). But we cannot do anything reasonable except skip the test
+ # on such platforms anyway, and this is the moral equivalent.
+ "$GIT_UNZIP" "$TEST_DIRECTORY"/t5004/empty.zip
+ expect_code=$?
+
+ git archive --format=zip HEAD >empty.zip &&
+ make_dir extract &&
+ (
+ cd extract &&
+ test_expect_code $expect_code "$GIT_UNZIP" ../empty.zip
+ ) &&
+ check_dir extract
+'
+
+test_expect_success UNZIP 'zip archive of empty tree with prefix' '
+ # We do not have to play exit-code tricks here, because our
+ # result should not be empty; it has a directory in it.
+ git archive --format=zip --prefix=foo/ HEAD >prefix.zip &&
+ make_dir extract &&
+ (
+ cd extract &&
+ "$GIT_UNZIP" ../prefix.zip
+ ) &&
+ check_dir extract foo
+'
+
+test_expect_success 'archive complains about pathspec on empty tree' '
+ test_must_fail git archive --format=tar HEAD -- foo >/dev/null
+'
+
+test_expect_success 'create a commit with an empty subtree' '
+ empty_tree=$(git hash-object -t tree /dev/null) &&
+ root_tree=$(printf "040000 tree $empty_tree\tsub\n" | git mktree)
+'
+
+test_expect_success 'archive empty subtree with no pathspec' '
+ git archive --format=tar $root_tree >subtree-all.tar &&
+ make_dir extract &&
+ "$TAR" xf subtree-all.tar -C extract &&
+ check_dir extract sub
+'
+
+test_expect_success 'archive empty subtree by direct pathspec' '
+ git archive --format=tar $root_tree -- sub >subtree-path.tar &&
+ make_dir extract &&
+ "$TAR" xf subtree-path.tar -C extract &&
+ check_dir extract sub
+'
+
+test_done
diff --git a/t/t5004/empty.zip b/t/t5004/empty.zip
new file mode 100644
index 0000000..1a76bb6
--- /dev/null
+++ b/t/t5004/empty.zip
Binary files differ
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index d645328..e4bb3a1 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -195,4 +195,30 @@ test_expect_success 'gc: prune old objects after local clone' '
)
'
+test_expect_success 'garbage report in count-objects -v' '
+ : >.git/objects/pack/foo &&
+ : >.git/objects/pack/foo.bar &&
+ : >.git/objects/pack/foo.keep &&
+ : >.git/objects/pack/foo.pack &&
+ : >.git/objects/pack/fake.bar &&
+ : >.git/objects/pack/fake.keep &&
+ : >.git/objects/pack/fake.pack &&
+ : >.git/objects/pack/fake.idx &&
+ : >.git/objects/pack/fake2.keep &&
+ : >.git/objects/pack/fake3.idx &&
+ git count-objects -v 2>stderr &&
+ grep "index file .git/objects/pack/fake.idx is too small" stderr &&
+ grep "^warning:" stderr | sort >actual &&
+ cat >expected <<\EOF &&
+warning: garbage found: .git/objects/pack/fake.bar
+warning: garbage found: .git/objects/pack/foo
+warning: garbage found: .git/objects/pack/foo.bar
+warning: no corresponding .idx nor .pack: .git/objects/pack/fake2.keep
+warning: no corresponding .idx: .git/objects/pack/foo.keep
+warning: no corresponding .idx: .git/objects/pack/foo.pack
+warning: no corresponding .pack: .git/objects/pack/fake3.idx
+EOF
+ test_cmp expected actual
+'
+
test_done
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 354d32c..d574085 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -364,6 +364,15 @@ EOF
test_cmp count7.expected count7.actual
'
+test_expect_success 'clone shallow with packed refs' '
+ git pack-refs --all &&
+ git clone --depth 1 --branch A "file://$(pwd)/." shallow8 &&
+ echo "in-pack: 4" > count8.expected &&
+ GIT_DIR=shallow8/.git git count-objects -v |
+ grep "^in-pack" > count8.actual &&
+ test_cmp count8.expected count8.actual
+'
+
test_expect_success 'setup tests for the --stdin parameter' '
for head in C D E F
do
diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh
index 60de2d6..f30c038 100755
--- a/t/t5503-tagfollow.sh
+++ b/t/t5503-tagfollow.sh
@@ -4,10 +4,6 @@ test_description='test automatic tag following'
. ./test-lib.sh
-if ! test_have_prereq NOT_MINGW; then
- say "GIT_DEBUG_SEND_PACK not supported - skipping tests"
-fi
-
# End state of the repository:
#
# T - tag1 S - tag2
@@ -17,7 +13,7 @@ fi
# \ C - origin/cat \
# origin/master master
-test_expect_success NOT_MINGW setup '
+test_expect_success setup '
test_tick &&
echo ichi >file &&
git add file &&
@@ -39,28 +35,35 @@ test_expect_success NOT_MINGW setup '
'
U=UPLOAD_LOG
+UPATH="$(pwd)/$U"
-test_expect_success NOT_MINGW 'setup expect' '
+test_expect_success 'setup expect' '
cat - <<EOF >expect
-#S
want $A
-#E
EOF
'
-test_expect_success NOT_MINGW 'fetch A (new commit : 1 connection)' '
+get_needs () {
+ test -s "$1" &&
+ perl -alne '
+ next unless $F[1] eq "upload-pack<";
+ last if $F[2] eq "0000";
+ print $F[2], " ", $F[3];
+ ' "$1"
+}
+
+test_expect_success 'fetch A (new commit : 1 connection)' '
rm -f $U &&
(
cd cloned &&
- GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ GIT_TRACE_PACKET=$UPATH git fetch &&
test $A = $(git rev-parse --verify origin/master)
) &&
- test -s $U &&
- cut -d" " -f1,2 $U >actual &&
+ get_needs $U >actual &&
test_cmp expect actual
'
-test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
+test_expect_success "create tag T on A, create C on branch cat" '
git tag -a -m tag1 tag1 $A &&
T=$(git rev-parse --verify tag1) &&
@@ -72,30 +75,27 @@ test_expect_success NOT_MINGW "create tag T on A, create C on branch cat" '
git checkout master
'
-test_expect_success NOT_MINGW 'setup expect' '
+test_expect_success 'setup expect' '
cat - <<EOF >expect
-#S
want $C
want $T
-#E
EOF
'
-test_expect_success NOT_MINGW 'fetch C, T (new branch, tag : 1 connection)' '
+test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
rm -f $U &&
(
cd cloned &&
- GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ GIT_TRACE_PACKET=$UPATH git fetch &&
test $C = $(git rev-parse --verify origin/cat) &&
test $T = $(git rev-parse --verify tag1) &&
test $A = $(git rev-parse --verify tag1^0)
) &&
- test -s $U &&
- cut -d" " -f1,2 $U >actual &&
+ get_needs $U >actual &&
test_cmp expect actual
'
-test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
+test_expect_success "create commits O, B, tag S on B" '
test_tick &&
echo O >file &&
git add file &&
@@ -111,39 +111,34 @@ test_expect_success NOT_MINGW "create commits O, B, tag S on B" '
S=$(git rev-parse --verify tag2)
'
-test_expect_success NOT_MINGW 'setup expect' '
+test_expect_success 'setup expect' '
cat - <<EOF >expect
-#S
want $B
want $S
-#E
EOF
'
-test_expect_success NOT_MINGW 'fetch B, S (commit and tag : 1 connection)' '
+test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
rm -f $U &&
(
cd cloned &&
- GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ GIT_TRACE_PACKET=$UPATH git fetch &&
test $B = $(git rev-parse --verify origin/master) &&
test $B = $(git rev-parse --verify tag2^0) &&
test $S = $(git rev-parse --verify tag2)
) &&
- test -s $U &&
- cut -d" " -f1,2 $U >actual &&
+ get_needs $U >actual &&
test_cmp expect actual
'
-test_expect_success NOT_MINGW 'setup expect' '
+test_expect_success 'setup expect' '
cat - <<EOF >expect
-#S
want $B
want $S
-#E
EOF
'
-test_expect_success NOT_MINGW 'new clone fetch master and tags' '
+test_expect_success 'new clone fetch master and tags' '
git branch -D cat
rm -f $U
(
@@ -151,15 +146,14 @@ test_expect_success NOT_MINGW 'new clone fetch master and tags' '
cd clone2 &&
git init &&
git remote add origin .. &&
- GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+ GIT_TRACE_PACKET=$UPATH git fetch &&
test $B = $(git rev-parse --verify origin/master) &&
test $S = $(git rev-parse --verify tag2) &&
test $B = $(git rev-parse --verify tag2^0) &&
test $T = $(git rev-parse --verify tag1) &&
test $A = $(git rev-parse --verify tag1^0)
) &&
- test -s $U &&
- cut -d" " -f1,2 $U >actual &&
+ get_needs $U >actual &&
test_cmp expect actual
'
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index d16e5d3..321c3e5 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -126,4 +126,16 @@ test_expect_success 'Report match with --exit-code' '
test_cmp expect actual
'
+for configsection in transfer uploadpack
+do
+ test_expect_success "Hide some refs with $configsection.hiderefs" '
+ test_config $configsection.hiderefs refs/tags &&
+ git ls-remote . >actual &&
+ test_unconfig $configsection.hiderefs &&
+ git ls-remote . |
+ sed -e "/ refs\/tags\//d" >expect &&
+ test_cmp expect actual
+ '
+done
+
test_done
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 8f024a0..d3dc5df 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -1016,4 +1016,138 @@ test_expect_success 'push --prune refspec' '
! check_push_result $the_first_commit tmp/foo tmp/bar
'
+for configsection in transfer receive
+do
+ test_expect_success "push to update a ref hidden by $configsection.hiderefs" '
+ mk_test heads/master hidden/one hidden/two hidden/three &&
+ (
+ cd testrepo &&
+ git config $configsection.hiderefs refs/hidden
+ ) &&
+
+ # push to unhidden ref succeeds normally
+ git push testrepo master:refs/heads/master &&
+ check_push_result $the_commit heads/master &&
+
+ # push to update a hidden ref should fail
+ test_must_fail git push testrepo master:refs/hidden/one &&
+ check_push_result $the_first_commit hidden/one &&
+
+ # push to delete a hidden ref should fail
+ test_must_fail git push testrepo :refs/hidden/two &&
+ check_push_result $the_first_commit hidden/two &&
+
+ # idempotent push to update a hidden ref should fail
+ test_must_fail git push testrepo $the_first_commit:refs/hidden/three &&
+ check_push_result $the_first_commit hidden/three
+ '
+done
+
+test_expect_success 'fetch exact SHA1' '
+ mk_test heads/master hidden/one &&
+ git push testrepo master:refs/hidden/one &&
+ (
+ cd testrepo &&
+ git config transfer.hiderefs refs/hidden
+ ) &&
+ check_push_result $the_commit hidden/one &&
+
+ mk_child child &&
+ (
+ cd child &&
+
+ # make sure $the_commit does not exist here
+ git repack -a -d &&
+ git prune &&
+ test_must_fail git cat-file -t $the_commit &&
+
+ # fetching the hidden object should fail by default
+ test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy &&
+ test_must_fail git rev-parse --verify refs/heads/copy &&
+
+ # the server side can allow it to succeed
+ (
+ cd ../testrepo &&
+ git config uploadpack.allowtipsha1inwant true
+ ) &&
+
+ git fetch -v ../testrepo $the_commit:refs/heads/copy &&
+ result=$(git rev-parse --verify refs/heads/copy) &&
+ test "$the_commit" = "$result"
+ )
+'
+
+test_expect_success 'fetch follows tags by default' '
+ mk_test heads/master &&
+ rm -fr src dst &&
+ git init src &&
+ (
+ cd src &&
+ git pull ../testrepo master &&
+ git tag -m "annotated" tag &&
+ git for-each-ref >tmp1 &&
+ (
+ cat tmp1
+ sed -n "s|refs/heads/master$|refs/remotes/origin/master|p" tmp1
+ ) |
+ sort -k 3 >../expect
+ ) &&
+ git init dst &&
+ (
+ cd dst &&
+ git remote add origin ../src &&
+ git config branch.master.remote origin &&
+ git config branch.master.merge refs/heads/master &&
+ git pull &&
+ git for-each-ref >../actual
+ ) &&
+ test_cmp expect actual
+'
+
+test_expect_success 'push does not follow tags by default' '
+ mk_test heads/master &&
+ rm -fr src dst &&
+ git init src &&
+ git init --bare dst &&
+ (
+ cd src &&
+ git pull ../testrepo master &&
+ git tag -m "annotated" tag &&
+ git checkout -b another &&
+ git commit --allow-empty -m "future commit" &&
+ git tag -m "future" future &&
+ git checkout master &&
+ git for-each-ref refs/heads/master >../expect &&
+ git push ../dst master
+ ) &&
+ (
+ cd dst &&
+ git for-each-ref >../actual
+ ) &&
+ test_cmp expect actual
+'
+
+test_expect_success 'push --follow-tag only pushes relevant tags' '
+ mk_test heads/master &&
+ rm -fr src dst &&
+ git init src &&
+ git init --bare dst &&
+ (
+ cd src &&
+ git pull ../testrepo master &&
+ git tag -m "annotated" tag &&
+ git checkout -b another &&
+ git commit --allow-empty -m "future commit" &&
+ git tag -m "future" future &&
+ git checkout master &&
+ git for-each-ref refs/heads/master refs/tags/tag >../expect
+ git push --follow-tag ../dst master
+ ) &&
+ (
+ cd dst &&
+ git for-each-ref >../actual
+ ) &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 35304b4..6af6c63 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -96,8 +96,7 @@ test_expect_success '--rebase' '
'
test_expect_success 'pull.rebase' '
git reset --hard before-rebase &&
- git config --bool pull.rebase true &&
- test_when_finished "git config --unset pull.rebase" &&
+ test_config pull.rebase true &&
git pull . copy &&
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
test new = $(git show HEAD:file2)
@@ -105,8 +104,7 @@ test_expect_success 'pull.rebase' '
test_expect_success 'branch.to-rebase.rebase' '
git reset --hard before-rebase &&
- git config --bool branch.to-rebase.rebase true &&
- test_when_finished "git config --unset branch.to-rebase.rebase" &&
+ test_config branch.to-rebase.rebase true &&
git pull . copy &&
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
test new = $(git show HEAD:file2)
@@ -114,10 +112,8 @@ test_expect_success 'branch.to-rebase.rebase' '
test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
git reset --hard before-rebase &&
- git config --bool pull.rebase true &&
- test_when_finished "git config --unset pull.rebase" &&
- git config --bool branch.to-rebase.rebase false &&
- test_when_finished "git config --unset branch.to-rebase.rebase" &&
+ test_config pull.rebase true &&
+ test_config branch.to-rebase.rebase false &&
git pull . copy &&
test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
test new = $(git show HEAD:file2)
@@ -171,9 +167,9 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
git update-ref refs/remotes/me/copy copy^ &&
COPY=$(git rev-parse --verify me/copy) &&
git rebase --onto $COPY copy &&
- git config branch.to-rebase.remote me &&
- git config branch.to-rebase.merge refs/heads/copy &&
- git config branch.to-rebase.rebase true &&
+ test_config branch.to-rebase.remote me &&
+ test_config branch.to-rebase.merge refs/heads/copy &&
+ test_config branch.to-rebase.rebase true &&
echo dirty >> file &&
git add file &&
test_must_fail git pull &&
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index 1b06691..aa31abe 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -19,6 +19,17 @@ test_expect_success 'git pull -q' '
test ! -s out)
'
+test_expect_success 'git pull -q --rebase' '
+ mkdir clonedqrb &&
+ (cd clonedqrb && git init &&
+ git pull -q --rebase "../parent" >out 2>err &&
+ test ! -s err &&
+ test ! -s out &&
+ git pull -q --rebase "../parent" >out 2>err &&
+ test ! -s err &&
+ test ! -s out)
+'
+
test_expect_success 'git pull' '
mkdir cloned &&
(cd cloned && git init &&
@@ -27,6 +38,14 @@ test_expect_success 'git pull' '
test ! -s out)
'
+test_expect_success 'git pull --rebase' '
+ mkdir clonedrb &&
+ (cd clonedrb && git init &&
+ git pull --rebase "../parent" >out 2>err &&
+ test -s err &&
+ test ! -s out)
+'
+
test_expect_success 'git pull -v' '
mkdir clonedv &&
(cd clonedv && git init &&
@@ -35,6 +54,14 @@ test_expect_success 'git pull -v' '
test ! -s out)
'
+test_expect_success 'git pull -v --rebase' '
+ mkdir clonedvrb &&
+ (cd clonedvrb && git init &&
+ git pull -v --rebase "../parent" >out 2>err &&
+ test -s err &&
+ test ! -s out)
+'
+
test_expect_success 'git pull -v -q' '
mkdir clonedvq &&
(cd clonedvq && git init &&
diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
index 4b4b4a6..4086f02 100755
--- a/t/t5541-http-push.sh
+++ b/t/t5541-http-push.sh
@@ -181,8 +181,7 @@ test_expect_success 'push (chunked)' '
git checkout master &&
test_commit commit path3 &&
HEAD=$(git rev-parse --verify HEAD) &&
- git config http.postbuffer 4 &&
- test_when_finished "git config --unset http.postbuffer" &&
+ test_config http.postbuffer 4 &&
git push -v -v origin $BRANCH 2>err &&
grep "POST git-receive-pack (chunked)" err &&
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh
index c5cd2e3..47eb769 100755
--- a/t/t5551-http-fetch.sh
+++ b/t/t5551-http-fetch.sh
@@ -157,6 +157,11 @@ test_expect_success 'GIT_SMART_HTTP can disable smart http' '
test_must_fail git fetch)
'
+test_expect_success 'invalid Content-Type rejected' '
+ test_must_fail git clone $HTTPD_URL/broken_smart/repo.git 2>actual
+ grep "not valid:" actual
+'
+
test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
index c47d450..60f1552 100755
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -54,11 +54,14 @@ cd "$base_dir"
rm -f "$U.D"
-test_expect_success 'cloning with reference (no -l -s)' \
-'GIT_DEBUG_SEND_PACK=3 git clone --reference B "file://$(pwd)/A" D 3>"$U.D"'
+test_expect_success 'cloning with reference (no -l -s)' '
+ GIT_TRACE_PACKET=$U.D git clone --reference B "file://$(pwd)/A" D
+'
-test_expect_success 'fetched no objects' \
-'! grep "^want" "$U.D"'
+test_expect_success 'fetched no objects' '
+ test -s "$U.D" &&
+ ! grep " want" "$U.D"
+'
cd "$base_dir"
@@ -173,12 +176,13 @@ test_expect_success 'fetch with incomplete alternates' '
(
cd K &&
git remote add J "file://$base_dir/J" &&
- GIT_DEBUG_SEND_PACK=3 git fetch J 3>"$U.K"
+ GIT_TRACE_PACKET=$U.K git fetch J
) &&
master_object=$(cd A && git for-each-ref --format="%(objectname)" refs/heads/master) &&
- ! grep "^want $master_object" "$U.K" &&
+ test -s "$U.K" &&
+ ! grep " want $master_object" "$U.K" &&
tag_object=$(cd A && git for-each-ref --format="%(objectname)" refs/tags/HEAD) &&
- ! grep "^want $tag_object" "$U.K"
+ ! grep " want $tag_object" "$U.K"
'
test_done
diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
index 3050740..66cda17 100755
--- a/t/t6009-rev-list-parent.sh
+++ b/t/t6009-rev-list-parent.sh
@@ -133,4 +133,17 @@ test_expect_success 'dodecapus' '
check_revlist "--min-parents=13" &&
check_revlist "--min-parents=4 --max-parents=11" tetrapus
'
+
+test_expect_success 'ancestors with the same commit time' '
+
+ test_tick_keep=$test_tick &&
+ for i in 1 2 3 4 5 6 7 8; do
+ test_tick=$test_tick_keep
+ test_commit t$i
+ done &&
+ git rev-list t1^! --not t$i >result &&
+ >expect &&
+ test_cmp expect result
+'
+
test_done
diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh
index 839ad97..8e2ff13 100755
--- a/t/t6012-rev-list-simplify.sh
+++ b/t/t6012-rev-list-simplify.sh
@@ -56,7 +56,23 @@ test_expect_success setup '
echo "Final change" >file &&
test_tick && git commit -a -m "Final change" &&
- note I
+ note I &&
+
+ git symbolic-ref HEAD refs/heads/unrelated &&
+ git rm -f "*" &&
+ echo "Unrelated branch" >side &&
+ git add side &&
+ test_tick && git commit -m "Side root" &&
+ note J &&
+
+ git checkout master &&
+ test_tick && git merge -m "Coolest" unrelated &&
+ note K &&
+
+ echo "Immaterial" >elif &&
+ git add elif &&
+ test_tick && git commit -m "Last" &&
+ note L
'
FMT='tformat:%P %H | %s'
@@ -79,10 +95,10 @@ check_result () {
'
}
-check_result 'I H G F E D C B A' --full-history
-check_result 'I H E C B A' --full-history -- file
-check_result 'I H E C B A' --full-history --topo-order -- file
-check_result 'I H E C B A' --full-history --date-order -- file
+check_result 'L K J I H G F E D C B A' --full-history
+check_result 'K I H E C B A' --full-history -- file
+check_result 'K I H E C B A' --full-history --topo-order -- file
+check_result 'K I H E C B A' --full-history --date-order -- file
check_result 'I E C B A' --simplify-merges -- file
check_result 'I B A' -- file
check_result 'I B A' --topo-order -- file
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index f5a79b1..c8d6e9f 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -104,6 +104,18 @@ test_expect_success 'creating a tag using HEAD directly should succeed' '
tag_exists myhead
'
+test_expect_success '--force can create a tag with the name of one existing' '
+ tag_exists mytag &&
+ git tag --force mytag &&
+ tag_exists mytag'
+
+test_expect_success '--force is moot with a non-existing tag name' '
+ git tag newtag >expect &&
+ git tag --force forcetag >actual &&
+ test_cmp expect actual
+'
+git tag -d newtag forcetag
+
# deleting tags:
test_expect_success 'trying to delete an unknown tag should fail' '
diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh
index f4f38a5..52ef06b 100755
--- a/t/t7060-wtstatus.sh
+++ b/t/t7060-wtstatus.sh
@@ -5,6 +5,7 @@ test_description='basic work tree status reporting'
. ./test-lib.sh
test_expect_success setup '
+ git config --global advice.statusuoption false &&
test_commit A &&
test_commit B oneside added &&
git checkout A^0 &&
diff --git a/t/t7062-wtstatus-ignorecase.sh b/t/t7062-wtstatus-ignorecase.sh
new file mode 100755
index 0000000..73709db
--- /dev/null
+++ b/t/t7062-wtstatus-ignorecase.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+test_description='git-status with core.ignorecase=true'
+
+. ./test-lib.sh
+
+test_expect_success 'status with hash collisions' '
+ # note: "V/", "V/XQANY/" and "WURZAUP/" produce the same hash code
+ # in name-hash.c::hash_name
+ mkdir V &&
+ mkdir V/XQANY &&
+ mkdir WURZAUP &&
+ touch V/XQANY/test &&
+ git config core.ignorecase true &&
+ git add . &&
+ # test is successful if git status completes (no endless loop)
+ git status
+'
+
+test_done
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 2683cba..5030f1f 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -757,4 +757,104 @@ test_expect_success 'submodule add with an existing name fails unless forced' '
)
'
+test_expect_success 'set up a second submodule' '
+ git submodule add ./init2 example2 &&
+ git commit -m "submodule example2 added"
+'
+
+test_expect_success 'submodule deinit should remove the whole submodule section from .git/config' '
+ git config submodule.example.foo bar &&
+ git config submodule.example2.frotz nitfol &&
+ git submodule deinit init &&
+ test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ test -n "$(git config --get-regexp "submodule\.example2\.")" &&
+ test -f example2/.git &&
+ rmdir init
+'
+
+test_expect_success 'submodule deinit . deinits all initialized submodules' '
+ git submodule update --init &&
+ git config submodule.example.foo bar &&
+ git config submodule.example2.frotz nitfol &&
+ test_must_fail git submodule deinit &&
+ git submodule deinit . &&
+ test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ test -z "$(git config --get-regexp "submodule\.example2\.")" &&
+ rmdir init example2
+'
+
+test_expect_success 'submodule deinit deinits a submodule when its work tree is missing or empty' '
+ git submodule update --init &&
+ rm -rf init example2/* example2/.git &&
+ git submodule deinit init example2 &&
+ test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ test -z "$(git config --get-regexp "submodule\.example2\.")" &&
+ rmdir init
+'
+
+test_expect_success 'submodule deinit fails when the submodule contains modifications unless forced' '
+ git submodule update --init &&
+ echo X >>init/s &&
+ test_must_fail git submodule deinit init &&
+ test -n "$(git config --get-regexp "submodule\.example\.")" &&
+ test -f example2/.git &&
+ git submodule deinit -f init &&
+ test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ rmdir init
+'
+
+test_expect_success 'submodule deinit fails when the submodule contains untracked files unless forced' '
+ git submodule update --init &&
+ echo X >>init/untracked &&
+ test_must_fail git submodule deinit init &&
+ test -n "$(git config --get-regexp "submodule\.example\.")" &&
+ test -f example2/.git &&
+ git submodule deinit -f init &&
+ test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ rmdir init
+'
+
+test_expect_success 'submodule deinit fails when the submodule HEAD does not match unless forced' '
+ git submodule update --init &&
+ (
+ cd init &&
+ git checkout HEAD^
+ ) &&
+ test_must_fail git submodule deinit init &&
+ test -n "$(git config --get-regexp "submodule\.example\.")" &&
+ test -f example2/.git &&
+ git submodule deinit -f init &&
+ test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ rmdir init
+'
+
+test_expect_success 'submodule deinit is silent when used on an uninitialized submodule' '
+ git submodule update --init &&
+ git submodule deinit init >actual &&
+ test_i18ngrep "Submodule .example. (.*) unregistered for path .init" actual &&
+ git submodule deinit init >actual &&
+ test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
+ git submodule deinit . >actual &&
+ test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
+ test_i18ngrep "Submodule .example2. (.*) unregistered for path .example2" actual &&
+ git submodule deinit . >actual &&
+ test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
+ test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
+ rmdir init example2
+'
+
+test_expect_success 'submodule deinit fails when submodule has a .git directory even when forced' '
+ git submodule update --init &&
+ (
+ cd init &&
+ rm .git &&
+ cp -R ../.git/modules/example .git &&
+ GIT_WORK_TREE=. git config --unset core.worktree
+ ) &&
+ test_must_fail git submodule deinit init &&
+ test_must_fail git submodule deinit -f init &&
+ test -d init/.git &&
+ test -n "$(git config --get-regexp "submodule\.example\.")"
+'
+
test_done
diff --git a/t/t7402-submodule-rebase.sh b/t/t7402-submodule-rebase.sh
index f919c8d..8e32f19 100755
--- a/t/t7402-submodule-rebase.sh
+++ b/t/t7402-submodule-rebase.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2008 Johannes Schindelin
#
-test_description='Test rebasing and stashing with dirty submodules'
+test_description='Test rebasing, stashing, etc. with submodules'
. ./test-lib.sh
@@ -20,7 +20,8 @@ test_expect_success setup '
echo second line >> file &&
(cd submodule && git pull) &&
test_tick &&
- git commit -m file-and-submodule -a
+ git commit -m file-and-submodule -a &&
+ git branch added-submodule
'
@@ -89,4 +90,29 @@ test_expect_success 'stash with a dirty submodule' '
'
+test_expect_success 'rebasing submodule that should conflict' '
+ git reset --hard &&
+ git checkout added-submodule &&
+ git add submodule &&
+ test_tick &&
+ git commit -m third &&
+ (
+ cd submodule &&
+ git commit --allow-empty -m extra
+ ) &&
+ git add submodule &&
+ test_tick &&
+ git commit -m fourth &&
+
+ test_must_fail git rebase --onto HEAD^^ HEAD^ HEAD^0 &&
+ git ls-files -s submodule >actual &&
+ (
+ cd submodule &&
+ echo "160000 $(git rev-parse HEAD^) 1 submodule" &&
+ echo "160000 $(git rev-parse HEAD^^) 2 submodule" &&
+ echo "160000 $(git rev-parse HEAD) 3 submodule"
+ ) >expect &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 50ac020..2a0cfaa 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -643,7 +643,8 @@ test_expect_success 'submodule update places git-dir in superprojects git-dir re
rm -rf super_update_r2 &&
git clone super_update_r super_update_r2 &&
(cd super_update_r2 &&
- git submodule update --init --recursive &&
+ git submodule update --init --recursive >actual &&
+ test_i18ngrep "Submodule path .submodule/subsubmodule.: checked out" actual &&
(cd submodule/subsubmodule &&
git log > ../../expected
) &&
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 1c908f4..436b7b6 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -36,8 +36,7 @@ test_expect_success 'nonexistent template file should return error' '
'
test_expect_success 'nonexistent template file in config should return error' '
- git config commit.template "$PWD"/notexist &&
- test_when_finished "git config --unset commit.template" &&
+ test_config commit.template "$PWD"/notexist &&
(
GIT_EDITOR="echo hello >\"\$1\"" &&
export GIT_EDITOR &&
@@ -93,14 +92,13 @@ test_expect_success '-t option should be short for --template' '
test_expect_success 'config-specified template should commit' '
echo "new template" > "$TEMPLATE" &&
- git config commit.template "$TEMPLATE" &&
+ test_config commit.template "$TEMPLATE" &&
echo "more content" >> foo &&
git add foo &&
(
test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
git commit
) &&
- git config --unset commit.template &&
commit_msg_is "new templatecommit message"
'
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index b1c7648..a4938b1 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -171,18 +171,25 @@ test_expect_success 'verbose' '
test_expect_success 'verbose respects diff config' '
- git config color.diff always &&
+ test_config color.diff always &&
git status -v >actual &&
- grep "\[1mdiff --git" actual &&
- git config --unset color.diff
+ grep "\[1mdiff --git" actual
+'
+
+mesg_with_comment_and_newlines='
+# text
+
+'
+
+test_expect_success 'prepare file with comment line and trailing newlines' '
+ printf "%s" "$mesg_with_comment_and_newlines" >expect
'
test_expect_success 'cleanup commit messages (verbatim option,-t)' '
echo >>negative &&
- { echo;echo "# text";echo; } >expect &&
- git commit --cleanup=verbatim -t expect -a &&
- git cat-file -p HEAD |sed -e "1,/^\$/d" |head -n 3 >actual &&
+ git commit --cleanup=verbatim --no-status -t expect -a &&
+ git cat-file -p HEAD |sed -e "1,/^\$/d" >actual &&
test_cmp expect actual
'
@@ -199,7 +206,7 @@ test_expect_success 'cleanup commit messages (verbatim option,-F)' '
test_expect_success 'cleanup commit messages (verbatim option,-m)' '
echo >>negative &&
- git commit --cleanup=verbatim -m "$(cat expect)" -a &&
+ git commit --cleanup=verbatim -m "$mesg_with_comment_and_newlines" -a &&
git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
test_cmp expect actual
@@ -255,32 +262,40 @@ test_expect_success 'cleanup commit message (fail on invalid cleanup mode config
test_expect_success 'cleanup commit message (no config and no option uses default)' '
echo content >>file &&
git add file &&
- test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
- git commit --no-status &&
+ (
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
+ git commit --no-status
+ ) &&
commit_msg_is "commit message"
'
test_expect_success 'cleanup commit message (option overrides default)' '
echo content >>file &&
git add file &&
- test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
- git commit --cleanup=whitespace --no-status &&
+ (
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
+ git commit --cleanup=whitespace --no-status
+ ) &&
commit_msg_is "commit message # comment"
'
test_expect_success 'cleanup commit message (config overrides default)' '
echo content >>file &&
git add file &&
- test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
- git -c commit.cleanup=whitespace commit --no-status &&
+ (
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
+ git -c commit.cleanup=whitespace commit --no-status
+ ) &&
commit_msg_is "commit message # comment"
'
test_expect_success 'cleanup commit message (option overrides config)' '
echo content >>file &&
git add file &&
- test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
- git -c commit.cleanup=whitespace commit --cleanup=default &&
+ (
+ test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
+ git -c commit.cleanup=whitespace commit --cleanup=default
+ ) &&
commit_msg_is "commit message"
'
@@ -409,6 +424,18 @@ test_expect_success 'A single-liner subject with a token plus colon is not a foo
'
+test_expect_success 'commit -s places sob on third line after two empty lines' '
+ git commit -s --allow-empty --allow-empty-message &&
+ cat <<-EOF >expect &&
+
+
+ Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+
+ EOF
+ sed -e "/^#/d" -e "s/^:.*//" .git/COMMIT_EDITMSG >actual &&
+ test_cmp expect actual
+'
+
write_script .git/FAKE_EDITOR <<\EOF
mv "$1" "$1.orig"
(
@@ -419,16 +446,6 @@ EOF
echo '## Custom template' >template
-clear_config () {
- (
- git config --unset-all "$1"
- case $? in
- 0|5) exit 0 ;;
- *) exit 1 ;;
- esac
- )
-}
-
try_commit () {
git reset --hard &&
echo >>negative &&
@@ -444,67 +461,57 @@ try_commit () {
try_commit_status_combo () {
test_expect_success 'commit' '
- clear_config commit.status &&
try_commit "" &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit' '
- clear_config commit.status &&
try_commit "" &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit --status' '
- clear_config commit.status &&
try_commit --status &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit --no-status' '
- clear_config commit.status &&
try_commit --no-status &&
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit with commit.status = yes' '
- clear_config commit.status &&
- git config commit.status yes &&
+ test_config commit.status yes &&
try_commit "" &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit with commit.status = no' '
- clear_config commit.status &&
- git config commit.status no &&
+ test_config commit.status no &&
try_commit "" &&
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit --status with commit.status = yes' '
- clear_config commit.status &&
- git config commit.status yes &&
+ test_config commit.status yes &&
try_commit --status &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit --no-status with commit.status = yes' '
- clear_config commit.status &&
- git config commit.status yes &&
+ test_config commit.status yes &&
try_commit --no-status &&
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit --status with commit.status = no' '
- clear_config commit.status &&
- git config commit.status no &&
+ test_config commit.status no &&
try_commit --status &&
test_i18ngrep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
test_expect_success 'commit --no-status with commit.status = no' '
- clear_config commit.status &&
- git config commit.status no &&
+ test_config commit.status no &&
try_commit --no-status &&
test_i18ngrep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
@@ -517,4 +524,10 @@ use_template="-t template"
try_commit_status_combo
+test_expect_success 'commit --status with custom comment character' '
+ test_config core.commentchar ";" &&
+ try_commit --status &&
+ test_i18ngrep "^; Changes to be committed:" .git/COMMIT_EDITMSG
+'
+
test_done
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index e313ef1..e2ffdac 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -8,6 +8,7 @@ test_description='git status'
. ./test-lib.sh
test_expect_success 'status -h in broken repository' '
+ git config --global advice.statusuoption false &&
mkdir broken &&
test_when_finished "rm -fr broken" &&
(
@@ -130,8 +131,7 @@ cat >expect <<\EOF
EOF
test_expect_success 'status (advice.statusHints false)' '
- test_when_finished "git config --unset advice.statusHints" &&
- git config advice.statusHints false &&
+ test_config advice.statusHints false &&
git status >output &&
test_i18ncmp expect output
@@ -331,8 +331,7 @@ test_expect_success 'status -uno' '
'
test_expect_success 'status (status.showUntrackedFiles no)' '
- git config status.showuntrackedfiles no
- test_when_finished "git config --unset status.showuntrackedfiles" &&
+ test_config status.showuntrackedfiles no &&
git status >output &&
test_i18ncmp expect output
'
@@ -347,12 +346,11 @@ cat >expect <<EOF
#
# Untracked files not listed
EOF
-git config advice.statusHints false
test_expect_success 'status -uno (advice.statusHints false)' '
+ test_config advice.statusHints false &&
git status -uno >output &&
test_i18ncmp expect output
'
-git config --unset advice.statusHints
cat >expect << EOF
M dir1/modified
@@ -399,8 +397,7 @@ test_expect_success 'status -unormal' '
'
test_expect_success 'status (status.showUntrackedFiles normal)' '
- git config status.showuntrackedfiles normal
- test_when_finished "git config --unset status.showuntrackedfiles" &&
+ test_config status.showuntrackedfiles normal
git status >output &&
test_i18ncmp expect output
'
@@ -458,8 +455,7 @@ test_expect_success 'status -uall' '
'
test_expect_success 'status (status.showUntrackedFiles all)' '
- git config status.showuntrackedfiles all
- test_when_finished "git config --unset status.showuntrackedfiles" &&
+ test_config status.showuntrackedfiles all
git status >output &&
test_i18ncmp expect output
'
@@ -484,10 +480,9 @@ test_expect_success 'status -s -uall' '
test_cmp expect output
'
test_expect_success 'status -s (status.showUntrackedFiles all)' '
- git config status.showuntrackedfiles all
+ test_config status.showuntrackedfiles all &&
git status -s >output &&
rm -rf dir3 &&
- git config --unset status.showuntrackedfiles &&
test_cmp expect output
'
@@ -587,15 +582,13 @@ cat >expect <<\EOF
EOF
test_expect_success 'status with color.ui' '
- git config color.ui always &&
- test_when_finished "git config --unset color.ui" &&
+ test_config color.ui always &&
git status | test_decode_color >output &&
test_i18ncmp expect output
'
test_expect_success 'status with color.status' '
- git config color.status always &&
- test_when_finished "git config --unset color.status" &&
+ test_config color.status always &&
git status | test_decode_color >output &&
test_i18ncmp expect output
'
@@ -719,8 +712,7 @@ EOF
test_expect_success 'status without relative paths' '
- git config status.relativePaths false &&
- test_when_finished "git config --unset status.relativePaths" &&
+ test_config status.relativePaths false &&
(cd dir1 && git status) >output &&
test_i18ncmp expect output
@@ -739,8 +731,7 @@ EOF
test_expect_success 'status -s without relative paths' '
- git config status.relativePaths false &&
- test_when_finished "git config --unset status.relativePaths" &&
+ test_config status.relativePaths false &&
(cd dir1 && git status -s) >output &&
test_cmp expect output
@@ -1037,15 +1028,14 @@ test_expect_success '--ignore-submodules=untracked suppresses submodules with un
'
test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
- git config diff.ignoreSubmodules dirty &&
+ test_config diff.ignoreSubmodules dirty &&
git status >output &&
test_i18ncmp expect output &&
git config --add -f .gitmodules submodule.subname.ignore untracked &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status >output &&
test_i18ncmp expect output &&
- git config -f .gitmodules --remove-section submodule.subname &&
- git config --unset diff.ignoreSubmodules
+ git config -f .gitmodules --remove-section submodule.subname
'
test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
@@ -1065,15 +1055,14 @@ test_expect_success '--ignore-submodules=dirty suppresses submodules with untrac
'
test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
- git config diff.ignoreSubmodules dirty &&
+ test_config diff.ignoreSubmodules dirty &&
git status >output &&
! test -s actual &&
git config --add -f .gitmodules submodule.subname.ignore dirty &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status >output &&
test_i18ncmp expect output &&
- git config -f .gitmodules --remove-section submodule.subname &&
- git config --unset diff.ignoreSubmodules
+ git config -f .gitmodules --remove-section submodule.subname
'
test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
@@ -1254,6 +1243,54 @@ test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary
'
cat > expect << EOF
+; On branch master
+; Changes to be committed:
+; (use "git reset HEAD <file>..." to unstage)
+;
+; modified: sm
+;
+; Changes not staged for commit:
+; (use "git add <file>..." to update what will be committed)
+; (use "git checkout -- <file>..." to discard changes in working directory)
+;
+; modified: dir1/modified
+; modified: sm (new commits)
+;
+; Submodule changes to be committed:
+;
+; * sm $head...$new_head (1):
+; > Add bar
+;
+; Submodules changed but not updated:
+;
+; * sm $new_head...$head2 (1):
+; > 2nd commit
+;
+; Untracked files:
+; (use "git add <file>..." to include in what will be committed)
+;
+; .gitmodules
+; dir1/untracked
+; dir2/modified
+; dir2/untracked
+; expect
+; output
+; untracked
+EOF
+
+test_expect_success "status (core.commentchar with submodule summary)" '
+ test_config core.commentchar ";" &&
+ git status >output &&
+ test_i18ncmp expect output
+'
+
+test_expect_success "status (core.commentchar with two chars with submodule summary)" '
+ test_config core.commentchar ";;" &&
+ git status >output &&
+ test_i18ncmp expect output
+'
+
+cat > expect << EOF
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index c35d01d..06749a6 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -5,7 +5,7 @@
# Grenoble INP Ensimag
#
-test_description='git status advices'
+test_description='git status advice'
. ./test-lib.sh
@@ -14,6 +14,7 @@ test_description='git status advices'
set_fake_editor
test_expect_success 'prepare for conflicts' '
+ git config --global advice.statusuoption false &&
test_commit init main.txt init &&
git branch conflicts &&
test_commit on_master main.txt on_master &&
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index 5e19598..2f70433 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -56,7 +56,8 @@ create_merge_msgs () {
echo &&
git log --no-merges ^HEAD c2 c3
} >squash.1-5-9 &&
- echo >msg.nolog &&
+ : >msg.nologff &&
+ echo >msg.nolognoff &&
{
echo "* tag 'c3':" &&
echo " commit 3" &&
@@ -244,8 +245,7 @@ test_expect_success 'merges with --ff-only' '
test_expect_success 'merges with merge.ff=only' '
git reset --hard c1 &&
test_tick &&
- test_when_finished "git config --unset merge.ff" &&
- git config merge.ff only &&
+ test_config merge.ff "only" &&
test_must_fail git merge c2 &&
test_must_fail git merge c3 &&
test_must_fail git merge c2 c3 &&
@@ -336,7 +336,7 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (no-commit in config)' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "--no-commit" &&
+ test_config branch.master.mergeoptions "--no-commit" &&
git merge c2 &&
verify_merge file result.1-5 &&
verify_head $c1 &&
@@ -346,12 +346,11 @@ test_expect_success 'merge c1 with c2 (no-commit in config)' '
test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (log in config)' '
- git config branch.master.mergeoptions "" &&
git reset --hard c1 &&
git merge --log c2 &&
git show -s --pretty=tformat:%s%n%b >expect &&
- git config branch.master.mergeoptions --log &&
+ test_config branch.master.mergeoptions "--log" &&
git reset --hard c1 &&
git merge c2 &&
git show -s --pretty=tformat:%s%n%b >actual &&
@@ -360,17 +359,12 @@ test_expect_success 'merge c1 with c2 (log in config)' '
'
test_expect_success 'merge c1 with c2 (log in config gets overridden)' '
- test_when_finished "git config --remove-section branch.master" &&
- test_when_finished "git config --remove-section merge" &&
- test_might_fail git config --remove-section branch.master &&
- test_might_fail git config --remove-section merge &&
-
git reset --hard c1 &&
git merge c2 &&
git show -s --pretty=tformat:%s%n%b >expect &&
- git config branch.master.mergeoptions "--no-log" &&
- git config merge.log true &&
+ test_config branch.master.mergeoptions "--no-log" &&
+ test_config merge.log "true" &&
git reset --hard c1 &&
git merge c2 &&
git show -s --pretty=tformat:%s%n%b >actual &&
@@ -380,7 +374,7 @@ test_expect_success 'merge c1 with c2 (log in config gets overridden)' '
test_expect_success 'merge c1 with c2 (squash in config)' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "--squash" &&
+ test_config branch.master.mergeoptions "--squash" &&
git merge c2 &&
verify_merge file result.1-5 &&
verify_head $c1 &&
@@ -392,7 +386,7 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'override config option -n with --summary' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "-n" &&
+ test_config branch.master.mergeoptions "-n" &&
test_tick &&
git merge --summary c2 >diffstat.txt &&
verify_merge file result.1-5 msg.1-5 &&
@@ -406,7 +400,7 @@ test_expect_success 'override config option -n with --summary' '
test_expect_success 'override config option -n with --stat' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "-n" &&
+ test_config branch.master.mergeoptions "-n" &&
test_tick &&
git merge --stat c2 >diffstat.txt &&
verify_merge file result.1-5 msg.1-5 &&
@@ -422,7 +416,7 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'override config option --stat' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "--stat" &&
+ test_config branch.master.mergeoptions "--stat" &&
test_tick &&
git merge -n c2 >diffstat.txt &&
verify_merge file result.1-5 msg.1-5 &&
@@ -438,7 +432,7 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (override --no-commit)' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "--no-commit" &&
+ test_config branch.master.mergeoptions "--no-commit" &&
test_tick &&
git merge --commit c2 &&
verify_merge file result.1-5 msg.1-5 &&
@@ -449,7 +443,7 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (override --squash)' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "--squash" &&
+ test_config branch.master.mergeoptions "--squash" &&
test_tick &&
git merge --no-squash c2 &&
verify_merge file result.1-5 msg.1-5 &&
@@ -460,7 +454,6 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c0 with c1 (no-ff)' '
git reset --hard c0 &&
- git config branch.master.mergeoptions "" &&
test_tick &&
git merge --no-ff c1 &&
verify_merge file result.1 &&
@@ -471,10 +464,9 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c0 with c1 (merge.ff=false)' '
git reset --hard c0 &&
- git config merge.ff false &&
+ test_config merge.ff "false" &&
test_tick &&
git merge c1 &&
- git config --remove-section merge &&
verify_merge file result.1 &&
verify_parents $c0 $c1
'
@@ -482,22 +474,19 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'combine branch.master.mergeoptions with merge.ff' '
git reset --hard c0 &&
- git config branch.master.mergeoptions --ff &&
- git config merge.ff false &&
+ test_config branch.master.mergeoptions "--ff" &&
+ test_config merge.ff "false" &&
test_tick &&
git merge c1 &&
- git config --remove-section "branch.master" &&
- git config --remove-section "merge" &&
verify_merge file result.1 &&
verify_parents "$c0"
'
test_expect_success 'tolerate unknown values for merge.ff' '
git reset --hard c0 &&
- git config merge.ff something-new &&
+ test_config merge.ff "something-new" &&
test_tick &&
git merge c1 2>message &&
- git config --remove-section "merge" &&
verify_head "$c1" &&
test_cmp empty message
'
@@ -515,7 +504,7 @@ test_expect_success 'combining --ff-only and --no-ff is refused' '
test_expect_success 'merge c0 with c1 (ff overrides no-ff)' '
git reset --hard c0 &&
- git config branch.master.mergeoptions "--no-ff" &&
+ test_config branch.master.mergeoptions "--no-ff" &&
git merge --ff c1 &&
verify_merge file result.1 &&
verify_head $c1
@@ -525,14 +514,20 @@ test_expect_success 'merge log message' '
git reset --hard c0 &&
git merge --no-log c2 &&
git show -s --pretty=format:%b HEAD >msg.act &&
- test_cmp msg.nolog msg.act &&
+ test_cmp msg.nologff msg.act &&
+
+ git reset --hard c0 &&
+ test_config branch.master.mergeoptions "--no-ff" &&
+ git merge --no-log c2 &&
+ git show -s --pretty=format:%b HEAD >msg.act &&
+ test_cmp msg.nolognoff msg.act &&
git merge --log c3 &&
git show -s --pretty=format:%b HEAD >msg.act &&
test_cmp msg.log msg.act &&
git reset --hard HEAD^ &&
- git config merge.log yes &&
+ test_config merge.log "yes" &&
git merge c3 &&
git show -s --pretty=format:%b HEAD >msg.act &&
test_cmp msg.log msg.act
@@ -542,7 +537,6 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "" &&
test_tick &&
git merge c0 c2 c0 c1 &&
verify_merge file result.1-5 &&
@@ -553,7 +547,6 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "" &&
test_tick &&
git merge c0 c2 c0 c1 &&
verify_merge file result.1-5 &&
@@ -564,7 +557,6 @@ test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c1 and c2' '
git reset --hard c1 &&
- git config branch.master.mergeoptions "" &&
test_tick &&
git merge c1 c2 &&
verify_merge file result.1-5 &&
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index eb1d3f8..c6d6b1c 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (c) 2009, 2010 David Aguilar
+# Copyright (c) 2009, 2010, 2012, 2013 David Aguilar
#
test_description='git-difftool
@@ -10,43 +10,25 @@ Testing basic diff tool invocation
. ./test-lib.sh
-remove_config_vars()
+difftool_test_setup ()
{
- # Unset all config variables used by git-difftool
- git config --unset diff.tool
- git config --unset diff.guitool
- git config --unset difftool.test-tool.cmd
- git config --unset difftool.prompt
- git config --unset merge.tool
- git config --unset mergetool.test-tool.cmd
- git config --unset mergetool.prompt
- return 0
+ test_config diff.tool test-tool &&
+ test_config difftool.test-tool.cmd 'cat "$LOCAL"' &&
+ test_config difftool.bogus-tool.cmd false
}
-restore_test_defaults()
-{
- # Restores the test defaults used by several tests
- remove_config_vars
- unset GIT_DIFF_TOOL
- unset GIT_DIFFTOOL_PROMPT
- unset GIT_DIFFTOOL_NO_PROMPT
- git config diff.tool test-tool &&
- git config difftool.test-tool.cmd 'cat $LOCAL'
- git config difftool.bogus-tool.cmd false
-}
-
-prompt_given()
+prompt_given ()
{
prompt="$1"
test "$prompt" = "Launch 'test-tool' [Y/n]: branch"
}
-stdin_contains()
+stdin_contains ()
{
grep >/dev/null "$1"
}
-stdin_doesnot_contain()
+stdin_doesnot_contain ()
{
! stdin_contains "$1"
}
@@ -65,249 +47,237 @@ test_expect_success PERL 'setup' '
# Configure a custom difftool.<tool>.cmd and use it
test_expect_success PERL 'custom commands' '
- restore_test_defaults &&
- git config difftool.test-tool.cmd "cat \$REMOTE" &&
+ difftool_test_setup &&
+ test_config difftool.test-tool.cmd "cat \"\$REMOTE\"" &&
+ echo master >expect &&
+ git difftool --no-prompt branch >actual &&
+ test_cmp expect actual &&
- diff=$(git difftool --no-prompt branch) &&
- test "$diff" = "master" &&
-
- restore_test_defaults &&
- diff=$(git difftool --no-prompt branch) &&
- test "$diff" = "branch"
+ test_config difftool.test-tool.cmd "cat \"\$LOCAL\"" &&
+ echo branch >expect &&
+ git difftool --no-prompt branch >actual &&
+ test_cmp expect actual
'
-# Ensures that a custom difftool.<tool>.cmd overrides built-ins
-test_expect_success PERL 'custom commands override built-ins' '
- restore_test_defaults &&
- git config difftool.defaults.cmd "cat \$REMOTE" &&
-
- diff=$(git difftool --tool defaults --no-prompt branch) &&
- test "$diff" = "master" &&
-
- git config --unset difftool.defaults.cmd
+test_expect_success PERL 'custom tool commands override built-ins' '
+ test_config difftool.vimdiff.cmd "cat \"\$REMOTE\"" &&
+ echo master >expect &&
+ git difftool --tool vimdiff --no-prompt branch >actual &&
+ test_cmp expect actual
'
-# Ensures that git-difftool ignores bogus --tool values
test_expect_success PERL 'difftool ignores bad --tool values' '
- diff=$(git difftool --no-prompt --tool=bad-tool branch)
- test "$?" = 1 &&
- test "$diff" = ""
+ : >expect &&
+ test_expect_code 1 \
+ git difftool --no-prompt --tool=bad-tool branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool forwards arguments to diff' '
+ difftool_test_setup &&
>for-diff &&
git add for-diff &&
echo changes>for-diff &&
git add for-diff &&
- diff=$(git difftool --cached --no-prompt -- for-diff) &&
- test "$diff" = "" &&
+ : >expect &&
+ git difftool --cached --no-prompt -- for-diff >actual &&
+ test_cmp expect actual &&
git reset -- for-diff &&
rm for-diff
'
test_expect_success PERL 'difftool honors --gui' '
- git config merge.tool bogus-tool &&
- git config diff.tool bogus-tool &&
- git config diff.guitool test-tool &&
-
- diff=$(git difftool --no-prompt --gui branch) &&
- test "$diff" = "branch" &&
+ difftool_test_setup &&
+ test_config merge.tool bogus-tool &&
+ test_config diff.tool bogus-tool &&
+ test_config diff.guitool test-tool &&
- restore_test_defaults
+ echo branch >expect &&
+ git difftool --no-prompt --gui branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool --gui last setting wins' '
- git config diff.guitool bogus-tool &&
- git difftool --no-prompt --gui --no-gui &&
+ difftool_test_setup &&
+ : >expect &&
+ git difftool --no-prompt --gui --no-gui >actual &&
+ test_cmp expect actual &&
- git config merge.tool bogus-tool &&
- git config diff.tool bogus-tool &&
- git config diff.guitool test-tool &&
- diff=$(git difftool --no-prompt --no-gui --gui branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ test_config merge.tool bogus-tool &&
+ test_config diff.tool bogus-tool &&
+ test_config diff.guitool test-tool &&
+ echo branch >expect &&
+ git difftool --no-prompt --no-gui --gui branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool --gui works without configured diff.guitool' '
- git config diff.tool test-tool &&
-
- diff=$(git difftool --no-prompt --gui branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ difftool_test_setup &&
+ echo branch >expect &&
+ git difftool --no-prompt --gui branch >actual &&
+ test_cmp expect actual
'
# Specify the diff tool using $GIT_DIFF_TOOL
test_expect_success PERL 'GIT_DIFF_TOOL variable' '
- test_might_fail git config --unset diff.tool &&
- GIT_DIFF_TOOL=test-tool &&
- export GIT_DIFF_TOOL &&
-
- diff=$(git difftool --no-prompt branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ difftool_test_setup &&
+ git config --unset diff.tool &&
+ echo branch >expect &&
+ GIT_DIFF_TOOL=test-tool git difftool --no-prompt branch >actual &&
+ test_cmp expect actual
'
# Test the $GIT_*_TOOL variables and ensure
# that $GIT_DIFF_TOOL always wins unless --tool is specified
test_expect_success PERL 'GIT_DIFF_TOOL overrides' '
- git config diff.tool bogus-tool &&
- git config merge.tool bogus-tool &&
-
- GIT_DIFF_TOOL=test-tool &&
- export GIT_DIFF_TOOL &&
-
- diff=$(git difftool --no-prompt branch) &&
- test "$diff" = "branch" &&
+ difftool_test_setup &&
+ test_config diff.tool bogus-tool &&
+ test_config merge.tool bogus-tool &&
- GIT_DIFF_TOOL=bogus-tool &&
- export GIT_DIFF_TOOL &&
+ echo branch >expect &&
+ GIT_DIFF_TOOL=test-tool git difftool --no-prompt branch >actual &&
+ test_cmp expect actual &&
- diff=$(git difftool --no-prompt --tool=test-tool branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ test_config diff.tool bogus-tool &&
+ test_config merge.tool bogus-tool &&
+ GIT_DIFF_TOOL=bogus-tool \
+ git difftool --no-prompt --tool=test-tool branch >actual &&
+ test_cmp expect actual
'
# Test that we don't have to pass --no-prompt to difftool
# when $GIT_DIFFTOOL_NO_PROMPT is true
test_expect_success PERL 'GIT_DIFFTOOL_NO_PROMPT variable' '
- GIT_DIFFTOOL_NO_PROMPT=true &&
- export GIT_DIFFTOOL_NO_PROMPT &&
-
- diff=$(git difftool branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ difftool_test_setup &&
+ echo branch >expect &&
+ GIT_DIFFTOOL_NO_PROMPT=true git difftool branch >actual &&
+ test_cmp expect actual
'
# git-difftool supports the difftool.prompt variable.
# Test that GIT_DIFFTOOL_PROMPT can override difftool.prompt = false
test_expect_success PERL 'GIT_DIFFTOOL_PROMPT variable' '
- git config difftool.prompt false &&
- GIT_DIFFTOOL_PROMPT=true &&
- export GIT_DIFFTOOL_PROMPT &&
-
- prompt=$(echo | git difftool branch | tail -1) &&
- prompt_given "$prompt" &&
-
- restore_test_defaults
+ difftool_test_setup &&
+ test_config difftool.prompt false &&
+ echo >input &&
+ GIT_DIFFTOOL_PROMPT=true git difftool branch <input >output &&
+ prompt=$(tail -1 <output) &&
+ prompt_given "$prompt"
'
# Test that we don't have to pass --no-prompt when difftool.prompt is false
test_expect_success PERL 'difftool.prompt config variable is false' '
- git config difftool.prompt false &&
-
- diff=$(git difftool branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ difftool_test_setup &&
+ test_config difftool.prompt false &&
+ echo branch >expect &&
+ git difftool branch >actual &&
+ test_cmp expect actual
'
# Test that we don't have to pass --no-prompt when mergetool.prompt is false
test_expect_success PERL 'difftool merge.prompt = false' '
+ difftool_test_setup &&
test_might_fail git config --unset difftool.prompt &&
- git config mergetool.prompt false &&
-
- diff=$(git difftool branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ test_config mergetool.prompt false &&
+ echo branch >expect &&
+ git difftool branch >actual &&
+ test_cmp expect actual
'
# Test that the -y flag can override difftool.prompt = true
test_expect_success PERL 'difftool.prompt can overridden with -y' '
- git config difftool.prompt true &&
-
- diff=$(git difftool -y branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ difftool_test_setup &&
+ test_config difftool.prompt true &&
+ echo branch >expect &&
+ git difftool -y branch >actual &&
+ test_cmp expect actual
'
# Test that the --prompt flag can override difftool.prompt = false
test_expect_success PERL 'difftool.prompt can overridden with --prompt' '
- git config difftool.prompt false &&
-
- prompt=$(echo | git difftool --prompt branch | tail -1) &&
- prompt_given "$prompt" &&
-
- restore_test_defaults
+ difftool_test_setup &&
+ test_config difftool.prompt false &&
+ echo >input &&
+ git difftool --prompt branch <input >output &&
+ prompt=$(tail -1 <output) &&
+ prompt_given "$prompt"
'
# Test that the last flag passed on the command-line wins
test_expect_success PERL 'difftool last flag wins' '
- diff=$(git difftool --prompt --no-prompt branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults &&
-
- prompt=$(echo | git difftool --no-prompt --prompt branch | tail -1) &&
- prompt_given "$prompt" &&
-
- restore_test_defaults
+ difftool_test_setup &&
+ echo branch >expect &&
+ git difftool --prompt --no-prompt branch >actual &&
+ test_cmp expect actual &&
+ echo >input &&
+ git difftool --no-prompt --prompt branch <input >output &&
+ prompt=$(tail -1 <output) &&
+ prompt_given "$prompt"
'
# git-difftool falls back to git-mergetool config variables
# so test that behavior here
test_expect_success PERL 'difftool + mergetool config variables' '
- remove_config_vars &&
- git config merge.tool test-tool &&
- git config mergetool.test-tool.cmd "cat \$LOCAL" &&
-
- diff=$(git difftool --no-prompt branch) &&
- test "$diff" = "branch" &&
+ test_config merge.tool test-tool &&
+ test_config mergetool.test-tool.cmd "cat \$LOCAL" &&
+ echo branch >expect &&
+ git difftool --no-prompt branch >actual &&
+ test_cmp expect actual &&
# set merge.tool to something bogus, diff.tool to test-tool
- git config merge.tool bogus-tool &&
- git config diff.tool test-tool &&
-
- diff=$(git difftool --no-prompt branch) &&
- test "$diff" = "branch" &&
-
- restore_test_defaults
+ test_config merge.tool bogus-tool &&
+ test_config diff.tool test-tool &&
+ git difftool --no-prompt branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool.<tool>.path' '
- git config difftool.tkdiff.path echo &&
- diff=$(git difftool --tool=tkdiff --no-prompt branch) &&
- git config --unset difftool.tkdiff.path &&
- lines=$(echo "$diff" | grep file | wc -l) &&
- test "$lines" -eq 1 &&
-
- restore_test_defaults
+ test_config difftool.tkdiff.path echo &&
+ git difftool --tool=tkdiff --no-prompt branch >output &&
+ lines=$(grep file output | wc -l) &&
+ test "$lines" -eq 1
'
test_expect_success PERL 'difftool --extcmd=cat' '
- diff=$(git difftool --no-prompt --extcmd=cat branch) &&
- test "$diff" = branch"$LF"master
+ echo branch >expect &&
+ echo master >>expect &&
+ git difftool --no-prompt --extcmd=cat branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool --extcmd cat' '
- diff=$(git difftool --no-prompt --extcmd cat branch) &&
- test "$diff" = branch"$LF"master
+ echo branch >expect &&
+ echo master >>expect &&
+ git difftool --no-prompt --extcmd=cat branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool -x cat' '
- diff=$(git difftool --no-prompt -x cat branch) &&
- test "$diff" = branch"$LF"master
+ echo branch >expect &&
+ echo master >>expect &&
+ git difftool --no-prompt -x cat branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool --extcmd echo arg1' '
- diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"echo\ \$1\" branch) &&
- test "$diff" = file
+ echo file >expect &&
+ git difftool --no-prompt \
+ --extcmd sh\ -c\ \"echo\ \$1\" branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool --extcmd cat arg1' '
- diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"cat\ \$1\" branch) &&
- test "$diff" = master
+ echo master >expect &&
+ git difftool --no-prompt \
+ --extcmd sh\ -c\ \"cat\ \$1\" branch >actual &&
+ test_cmp expect actual
'
test_expect_success PERL 'difftool --extcmd cat arg2' '
- diff=$(git difftool --no-prompt --extcmd sh\ -c\ \"cat\ \$2\" branch) &&
- test "$diff" = branch
+ echo branch >expect &&
+ git difftool --no-prompt \
+ --extcmd sh\ -c\ \"cat\ \$2\" branch >actual &&
+ test_cmp expect actual
'
# Create a second file on master and a different version on branch
@@ -324,26 +294,26 @@ test_expect_success PERL 'setup with 2 files different' '
'
test_expect_success PERL 'say no to the first file' '
- diff=$( (echo n; echo) | git difftool -x cat branch ) &&
-
- echo "$diff" | stdin_contains m2 &&
- echo "$diff" | stdin_contains br2 &&
- echo "$diff" | stdin_doesnot_contain master &&
- echo "$diff" | stdin_doesnot_contain branch
+ (echo n && echo) >input &&
+ git difftool -x cat branch <input >output &&
+ stdin_contains m2 <output &&
+ stdin_contains br2 <output &&
+ stdin_doesnot_contain master <output &&
+ stdin_doesnot_contain branch <output
'
test_expect_success PERL 'say no to the second file' '
- diff=$( (echo; echo n) | git difftool -x cat branch ) &&
-
- echo "$diff" | stdin_contains master &&
- echo "$diff" | stdin_contains branch &&
- echo "$diff" | stdin_doesnot_contain m2 &&
- echo "$diff" | stdin_doesnot_contain br2
+ (echo && echo n) >input &&
+ git difftool -x cat branch <input >output &&
+ stdin_contains master <output &&
+ stdin_contains branch <output &&
+ stdin_doesnot_contain m2 <output &&
+ stdin_doesnot_contain br2 <output
'
test_expect_success PERL 'difftool --tool-help' '
- tool_help=$(git difftool --tool-help) &&
- echo "$tool_help" | stdin_contains tool
+ git difftool --tool-help >output &&
+ stdin_contains tool <output
'
test_expect_success PERL 'setup change in subdirectory' '
@@ -359,29 +329,51 @@ test_expect_success PERL 'setup change in subdirectory' '
'
test_expect_success PERL 'difftool -d' '
- diff=$(git difftool -d --extcmd ls branch) &&
- echo "$diff" | stdin_contains sub &&
- echo "$diff" | stdin_contains file
+ git difftool -d --extcmd ls branch >output &&
+ stdin_contains sub <output &&
+ stdin_contains file <output
'
test_expect_success PERL 'difftool --dir-diff' '
- diff=$(git difftool --dir-diff --extcmd ls branch) &&
- echo "$diff" | stdin_contains sub &&
- echo "$diff" | stdin_contains file
+ git difftool --dir-diff --extcmd ls branch >output &&
+ stdin_contains sub <output &&
+ stdin_contains file <output
+'
+
+write_script .git/CHECK_SYMLINKS <<\EOF
+for f in file file2 sub/sub
+do
+ echo "$f"
+ readlink "$2/$f"
+done >actual
+EOF
+
+test_expect_success PERL,SYMLINKS 'difftool --dir-diff --symlink without unstaged changes' '
+ cat >expect <<-EOF &&
+ file
+ $(pwd)/file
+ file2
+ $(pwd)/file2
+ sub/sub
+ $(pwd)/sub/sub
+ EOF
+ git difftool --dir-diff --symlink \
+ --extcmd "./.git/CHECK_SYMLINKS" branch HEAD &&
+ test_cmp actual expect
'
test_expect_success PERL 'difftool --dir-diff ignores --prompt' '
- diff=$(git difftool --dir-diff --prompt --extcmd ls branch) &&
- echo "$diff" | stdin_contains sub &&
- echo "$diff" | stdin_contains file
+ git difftool --dir-diff --prompt --extcmd ls branch >output &&
+ stdin_contains sub <output &&
+ stdin_contains file <output
'
test_expect_success PERL 'difftool --dir-diff from subdirectory' '
(
cd sub &&
- diff=$(git difftool --dir-diff --extcmd ls branch) &&
- echo "$diff" | stdin_contains sub &&
- echo "$diff" | stdin_contains file
+ git difftool --dir-diff --extcmd ls branch >output &&
+ stdin_contains sub <output &&
+ stdin_contains file <output
)
'
diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh
index a895778..e1951a5 100755
--- a/t/t7811-grep-open.sh
+++ b/t/t7811-grep-open.sh
@@ -125,11 +125,6 @@ test_expect_success 'modified file' '
test_cmp empty out
'
-test_config() {
- git config "$1" "$2" &&
- test_when_finished "git config --unset $1"
-}
-
test_expect_success 'copes with color settings' '
rm -f actual &&
echo grep.h >expect &&
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 90bb605..6783c14 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -539,8 +539,7 @@ test_expect_success \
test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
echo "ISO-8859-1" >> file &&
git add file &&
- git config i18n.commitencoding ISO-8859-1 &&
- test_when_finished "git config --unset i18n.commitencoding" &&
+ test_config i18n.commitencoding ISO-8859-1 &&
git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
gitweb_run "p=.git;a=commit"'
diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh
index 166e752..665607c 100755
--- a/t/t9800-git-p4-basic.sh
+++ b/t/t9800-git-p4-basic.sh
@@ -30,6 +30,11 @@ test_expect_success 'basic git p4 clone' '
)
'
+test_expect_success 'depot typo error' '
+ test_must_fail git p4 clone --dest="$git" /depot 2>errs &&
+ grep "Depot paths must start with" errs
+'
+
test_expect_success 'git p4 clone @all' '
git p4 clone --dest="$git" //depot@all &&
test_when_finished cleanup_git &&
diff --git a/t/t9802-git-p4-filetype.sh b/t/t9802-git-p4-filetype.sh
index aae1a3f..eeefa67 100755
--- a/t/t9802-git-p4-filetype.sh
+++ b/t/t9802-git-p4-filetype.sh
@@ -8,6 +8,123 @@ test_expect_success 'start p4d' '
start_p4d
'
+#
+# This series of tests checks newline handling Both p4 and
+# git store newlines as \n, and have options to choose how
+# newlines appear in checked-out files.
+#
+test_expect_success 'p4 client newlines, unix' '
+ (
+ cd "$cli" &&
+ p4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i &&
+ printf "unix\ncrlf\n" >f-unix &&
+ printf "unix\r\ncrlf\r\n" >f-unix-as-crlf &&
+ p4 add -t text f-unix &&
+ p4 submit -d f-unix &&
+
+ # LineEnd: unix; should be no change after sync
+ cp f-unix f-unix-orig &&
+ p4 sync -f &&
+ test_cmp f-unix-orig f-unix &&
+
+ # make sure stored in repo as unix newlines
+ # use sed to eat python-appened newline
+ p4 -G print //depot/f-unix | marshal_dump data 2 |\
+ sed \$d >f-unix-p4-print &&
+ test_cmp f-unix-orig f-unix-p4-print &&
+
+ # switch to win, make sure lf -> crlf
+ p4 client -o | sed "/LineEnd/s/:.*/:win/" | p4 client -i &&
+ p4 sync -f &&
+ test_cmp f-unix-as-crlf f-unix
+ )
+'
+
+test_expect_success 'p4 client newlines, win' '
+ (
+ cd "$cli" &&
+ p4 client -o | sed "/LineEnd/s/:.*/:win/" | p4 client -i &&
+ printf "win\r\ncrlf\r\n" >f-win &&
+ printf "win\ncrlf\n" >f-win-as-lf &&
+ p4 add -t text f-win &&
+ p4 submit -d f-win &&
+
+ # LineEnd: win; should be no change after sync
+ cp f-win f-win-orig &&
+ p4 sync -f &&
+ test_cmp f-win-orig f-win &&
+
+ # make sure stored in repo as unix newlines
+ # use sed to eat python-appened newline
+ p4 -G print //depot/f-win | marshal_dump data 2 |\
+ sed \$d >f-win-p4-print &&
+ test_cmp f-win-as-lf f-win-p4-print &&
+
+ # switch to unix, make sure lf -> crlf
+ p4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i &&
+ p4 sync -f &&
+ test_cmp f-win-as-lf f-win
+ )
+'
+
+test_expect_success 'ensure blobs store only lf newlines' '
+ test_when_finished cleanup_git &&
+ (
+ cd "$git" &&
+ git init &&
+ git p4 sync //depot@all &&
+
+ # verify the files in .git are stored only with newlines
+ o=$(git ls-tree p4/master -- f-unix | cut -f1 | cut -d\ -f3) &&
+ git cat-file blob $o >f-unix-blob &&
+ test_cmp "$cli"/f-unix-orig f-unix-blob &&
+
+ o=$(git ls-tree p4/master -- f-win | cut -f1 | cut -d\ -f3) &&
+ git cat-file blob $o >f-win-blob &&
+ test_cmp "$cli"/f-win-as-lf f-win-blob &&
+
+ rm f-unix-blob f-win-blob
+ )
+'
+
+test_expect_success 'gitattributes setting eol=lf produces lf newlines' '
+ test_when_finished cleanup_git &&
+ (
+ # checkout the files and make sure core.eol works as planned
+ cd "$git" &&
+ git init &&
+ echo "* eol=lf" >.gitattributes &&
+ git p4 sync //depot@all &&
+ git checkout master &&
+ test_cmp "$cli"/f-unix-orig f-unix &&
+ test_cmp "$cli"/f-win-as-lf f-win
+ )
+'
+
+test_expect_success 'gitattributes setting eol=crlf produces crlf newlines' '
+ test_when_finished cleanup_git &&
+ (
+ # checkout the files and make sure core.eol works as planned
+ cd "$git" &&
+ git init &&
+ echo "* eol=crlf" >.gitattributes &&
+ git p4 sync //depot@all &&
+ git checkout master &&
+ test_cmp "$cli"/f-unix-as-crlf f-unix &&
+ test_cmp "$cli"/f-win-orig f-win
+ )
+'
+
+test_expect_success 'crlf cleanup' '
+ (
+ cd "$cli" &&
+ rm f-unix-orig f-unix-as-crlf &&
+ rm f-win-orig f-win-as-lf &&
+ p4 client -o | sed "/LineEnd/s/:.*/:unix/" | p4 client -i &&
+ p4 sync -f
+ )
+'
+
test_expect_success 'utf-16 file create' '
(
cd "$cli" &&
diff --git a/t/t9806-git-p4-options.sh b/t/t9806-git-p4-options.sh
index 4f077ee..254d428 100755
--- a/t/t9806-git-p4-options.sh
+++ b/t/t9806-git-p4-options.sh
@@ -214,40 +214,33 @@ test_expect_success 'clone --use-client-spec' '
exec >/dev/null &&
test_must_fail git p4 clone --dest="$git" --use-client-spec
) &&
- cli2=$(test-path-utils real_path "$TRASH_DIRECTORY/cli2") &&
+ # build a different client
+ cli2="$TRASH_DIRECTORY/cli2" &&
mkdir -p "$cli2" &&
test_when_finished "rmdir \"$cli2\"" &&
- (
- cd "$cli2" &&
- p4 client -i <<-EOF
- Client: client2
- Description: client2
- Root: $cli2
- View: //depot/sub/... //client2/bus/...
- EOF
- ) &&
test_when_finished cleanup_git &&
(
+ # group P4CLIENT and cli changes in a sub-shell
P4CLIENT=client2 &&
- git p4 clone --dest="$git" --use-client-spec //depot/...
- ) &&
- (
- cd "$git" &&
- test_path_is_file bus/dir/f4 &&
- test_path_is_missing file1
- ) &&
- cleanup_git &&
-
- # same thing again, this time with variable instead of option
- (
- cd "$git" &&
- git init &&
- git config git-p4.useClientSpec true &&
- P4CLIENT=client2 &&
- git p4 sync //depot/... &&
- git checkout -b master p4/master &&
- test_path_is_file bus/dir/f4 &&
- test_path_is_missing file1
+ cli="$cli2" &&
+ client_view "//depot/sub/... //client2/bus/..." &&
+ git p4 clone --dest="$git" --use-client-spec //depot/... &&
+ (
+ cd "$git" &&
+ test_path_is_file bus/dir/f4 &&
+ test_path_is_missing file1
+ ) &&
+ cleanup_git &&
+ # same thing again, this time with variable instead of option
+ (
+ cd "$git" &&
+ git init &&
+ git config git-p4.useClientSpec true &&
+ git p4 sync //depot/... &&
+ git checkout -b master p4/master &&
+ test_path_is_file bus/dir/f4 &&
+ test_path_is_missing file1
+ )
)
'
diff --git a/t/t9807-git-p4-submit.sh b/t/t9807-git-p4-submit.sh
index 0ae048f..1fb7bc7 100755
--- a/t/t9807-git-p4-submit.sh
+++ b/t/t9807-git-p4-submit.sh
@@ -17,6 +17,16 @@ test_expect_success 'init depot' '
)
'
+test_expect_failure 'is_cli_file_writeable function' '
+ (
+ cd "$cli" &&
+ echo a >a &&
+ is_cli_file_writeable a &&
+ ! is_cli_file_writeable file1 &&
+ rm a
+ )
+'
+
test_expect_success 'submit with no client dir' '
test_when_finished cleanup_git &&
git p4 clone --dest="$git" //depot &&
@@ -200,7 +210,7 @@ test_expect_success 'submit copy' '
(
cd "$cli" &&
test_path_is_file file5.ta &&
- test ! -w file5.ta
+ ! is_cli_file_writeable file5.ta
)
'
@@ -219,7 +229,7 @@ test_expect_success 'submit rename' '
cd "$cli" &&
test_path_is_missing file6.t &&
test_path_is_file file6.ta &&
- test ! -w file6.ta
+ ! is_cli_file_writeable file6.ta
)
'
diff --git a/t/t9808-git-p4-chdir.sh b/t/t9808-git-p4-chdir.sh
index dc92e60..11d2b51 100755
--- a/t/t9808-git-p4-chdir.sh
+++ b/t/t9808-git-p4-chdir.sh
@@ -42,6 +42,47 @@ test_expect_success 'P4CONFIG and relative dir clone' '
)
'
+# Common setup using .p4config to set P4CLIENT and P4PORT breaks
+# if clone destination is relative. Make sure that chdir() expands
+# the relative path in --dest to absolute.
+test_expect_success 'p4 client root would be relative due to clone --dest' '
+ test_when_finished cleanup_git &&
+ (
+ echo P4PORT=$P4PORT >git/.p4config &&
+ P4CONFIG=.p4config &&
+ export P4CONFIG &&
+ unset P4PORT &&
+ git p4 clone --dest="git" //depot
+ )
+'
+
+# When the p4 client Root is a symlink, make sure chdir() does not use
+# getcwd() to convert it to a physical path.
+test_expect_success SYMLINKS 'p4 client root symlink should stay symbolic' '
+ physical="$TRASH_DIRECTORY/physical" &&
+ symbolic="$TRASH_DIRECTORY/symbolic" &&
+ test_when_finished "rm -rf \"$physical\"" &&
+ test_when_finished "rm \"$symbolic\"" &&
+ mkdir -p "$physical" &&
+ ln -s "$physical" "$symbolic" &&
+ test_when_finished cleanup_git &&
+ (
+ P4CLIENT=client-sym &&
+ p4 client -i <<-EOF &&
+ Client: $P4CLIENT
+ Description: $P4CLIENT
+ Root: $symbolic
+ LineEnd: unix
+ View: //depot/... //$P4CLIENT/...
+ EOF
+ git p4 clone --dest="$git" //depot &&
+ cd "$git" &&
+ test_commit file2 &&
+ git config git-p4.skipSubmitEdit true &&
+ git p4 submit
+ )
+'
+
test_expect_success 'kill p4d' '
kill_p4d
'
diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh
index 281be29..77f6349 100755
--- a/t/t9809-git-p4-client-view.sh
+++ b/t/t9809-git-p4-client-view.sh
@@ -196,7 +196,7 @@ test_expect_success 'exclusion single file' '
test_expect_success 'overlay wildcard' '
client_view "//depot/dir1/... //client/cli/..." \
- "+//depot/dir2/... //client/cli/...\n" &&
+ "+//depot/dir2/... //client/cli/..." &&
files="cli/file11 cli/file12 cli/file21 cli/file22" &&
client_verify $files &&
test_when_finished cleanup_git &&
@@ -333,7 +333,7 @@ test_expect_success 'subdir clone, submit copy' '
(
cd "$cli" &&
test_path_is_file dir1/file11a &&
- test ! -w dir1/file11a
+ ! is_cli_file_writeable dir1/file11a
)
'
@@ -353,7 +353,7 @@ test_expect_success 'subdir clone, submit rename' '
cd "$cli" &&
test_path_is_missing dir1/file13 &&
test_path_is_file dir1/file13a &&
- test ! -w dir1/file13a
+ ! is_cli_file_writeable dir1/file13a
)
'
@@ -365,7 +365,10 @@ test_expect_success 'wildcard files submit back to p4, client-spec case' '
(
cd "$git" &&
echo git-wild-hash >dir1/git-wild#hash &&
- echo git-wild-star >dir1/git-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ echo git-wild-star >dir1/git-wild\*star
+ fi &&
echo git-wild-at >dir1/git-wild@at &&
echo git-wild-percent >dir1/git-wild%percent &&
git add dir1/git-wild* &&
@@ -376,7 +379,10 @@ test_expect_success 'wildcard files submit back to p4, client-spec case' '
(
cd "$cli" &&
test_path_is_file dir1/git-wild#hash &&
- test_path_is_file dir1/git-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ test_path_is_file dir1/git-wild\*star
+ fi &&
test_path_is_file dir1/git-wild@at &&
test_path_is_file dir1/git-wild%percent
) &&
diff --git a/t/t9812-git-p4-wildcards.sh b/t/t9812-git-p4-wildcards.sh
index 143d413..6763325 100755
--- a/t/t9812-git-p4-wildcards.sh
+++ b/t/t9812-git-p4-wildcards.sh
@@ -14,7 +14,10 @@ test_expect_success 'add p4 files with wildcards in the names' '
printf "file2\nhas\nsome\nrandom\ntext\n" >file2 &&
p4 add file2 &&
echo file-wild-hash >file-wild#hash &&
- echo file-wild-star >file-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ echo file-wild-star >file-wild\*star
+ fi &&
echo file-wild-at >file-wild@at &&
echo file-wild-percent >file-wild%percent &&
p4 add -f file-wild* &&
@@ -28,7 +31,10 @@ test_expect_success 'wildcard files git p4 clone' '
(
cd "$git" &&
test -f file-wild#hash &&
- test -f file-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ test -f file-wild\*star
+ fi &&
test -f file-wild@at &&
test -f file-wild%percent
)
@@ -40,7 +46,10 @@ test_expect_success 'wildcard files submit back to p4, add' '
(
cd "$git" &&
echo git-wild-hash >git-wild#hash &&
- echo git-wild-star >git-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ echo git-wild-star >git-wild\*star
+ fi &&
echo git-wild-at >git-wild@at &&
echo git-wild-percent >git-wild%percent &&
git add git-wild* &&
@@ -51,7 +60,10 @@ test_expect_success 'wildcard files submit back to p4, add' '
(
cd "$cli" &&
test_path_is_file git-wild#hash &&
- test_path_is_file git-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ test_path_is_file git-wild\*star
+ fi &&
test_path_is_file git-wild@at &&
test_path_is_file git-wild%percent
)
@@ -63,7 +75,10 @@ test_expect_success 'wildcard files submit back to p4, modify' '
(
cd "$git" &&
echo new-line >>git-wild#hash &&
- echo new-line >>git-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ echo new-line >>git-wild\*star
+ fi &&
echo new-line >>git-wild@at &&
echo new-line >>git-wild%percent &&
git add git-wild* &&
@@ -74,7 +89,10 @@ test_expect_success 'wildcard files submit back to p4, modify' '
(
cd "$cli" &&
test_line_count = 2 git-wild#hash &&
- test_line_count = 2 git-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ test_line_count = 2 git-wild\*star
+ fi &&
test_line_count = 2 git-wild@at &&
test_line_count = 2 git-wild%percent
)
@@ -87,7 +105,7 @@ test_expect_success 'wildcard files submit back to p4, copy' '
cd "$git" &&
cp file2 git-wild-cp#hash &&
git add git-wild-cp#hash &&
- cp git-wild\*star file-wild-3 &&
+ cp git-wild#hash file-wild-3 &&
git add file-wild-3 &&
git commit -m "wildcard copies" &&
git config git-p4.detectCopies true &&
@@ -134,7 +152,10 @@ test_expect_success 'wildcard files submit back to p4, delete' '
(
cd "$cli" &&
test_path_is_missing git-wild#hash &&
- test_path_is_missing git-wild\*star &&
+ if test_have_prereq NOT_MINGW NOT_CYGWIN
+ then
+ test_path_is_missing git-wild\*star
+ fi &&
test_path_is_missing git-wild@at &&
test_path_is_missing git-wild%percent
)
diff --git a/t/t9815-git-p4-submit-fail.sh b/t/t9815-git-p4-submit-fail.sh
index d2b7b3d..1243d96 100755
--- a/t/t9815-git-p4-submit-fail.sh
+++ b/t/t9815-git-p4-submit-fail.sh
@@ -405,8 +405,8 @@ test_expect_success 'cleanup chmod after submit cancel' '
git p4 clone --dest="$git" //depot &&
(
cd "$git" &&
- chmod u+x text &&
- chmod u-x text+x &&
+ test_chmod +x text &&
+ test_chmod -x text+x &&
git add text text+x &&
git commit -m "chmod texts" &&
echo n | test_expect_code 1 git p4 submit
@@ -415,10 +415,13 @@ test_expect_success 'cleanup chmod after submit cancel' '
cd "$cli" &&
test_path_is_file text &&
! p4 fstat -T action text &&
- stat --format=%A text | egrep ^-r-- &&
test_path_is_file text+x &&
! p4 fstat -T action text+x &&
- stat --format=%A text+x | egrep ^-r-x
+ if test_have_prereq NOT_CYGWIN
+ then
+ stat --format=%A text | egrep ^-r-- &&
+ stat --format=%A text+x | egrep ^-r-x
+ fi
)
'
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index f17c1f8..2101d91 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -360,7 +360,31 @@ test_expect_success 'prompt - dirty status indicator - before root commit' '
test_cmp expected "$actual"
'
-test_expect_success 'prompt - dirty status indicator - disabled by config' '
+test_expect_success 'prompt - dirty status indicator - shell variable unset with config disabled' '
+ printf " (master)" > expected &&
+ echo "dirty" > file &&
+ test_when_finished "git reset --hard" &&
+ test_config bash.showDirtyState false &&
+ (
+ sane_unset GIT_PS1_SHOWDIRTYSTATE &&
+ __git_ps1 > "$actual"
+ ) &&
+ test_cmp expected "$actual"
+'
+
+test_expect_success 'prompt - dirty status indicator - shell variable unset with config enabled' '
+ printf " (master)" > expected &&
+ echo "dirty" > file &&
+ test_when_finished "git reset --hard" &&
+ test_config bash.showDirtyState true &&
+ (
+ sane_unset GIT_PS1_SHOWDIRTYSTATE &&
+ __git_ps1 > "$actual"
+ ) &&
+ test_cmp expected "$actual"
+'
+
+test_expect_success 'prompt - dirty status indicator - shell variable set with config disabled' '
printf " (master)" > expected &&
echo "dirty" > file &&
test_when_finished "git reset --hard" &&
@@ -372,6 +396,18 @@ test_expect_success 'prompt - dirty status indicator - disabled by config' '
test_cmp expected "$actual"
'
+test_expect_success 'prompt - dirty status indicator - shell variable set with config enabled' '
+ printf " (master *)" > expected &&
+ echo "dirty" > file &&
+ test_when_finished "git reset --hard" &&
+ test_config bash.showDirtyState true &&
+ (
+ GIT_PS1_SHOWDIRTYSTATE=y &&
+ __git_ps1 > "$actual"
+ ) &&
+ test_cmp expected "$actual"
+'
+
test_expect_success 'prompt - dirty status indicator - not shown inside .git directory' '
printf " (GIT_DIR!)" > expected &&
echo "dirty" > file &&
@@ -437,6 +473,46 @@ test_expect_success 'prompt - untracked files status indicator - untracked files
test_cmp expected "$actual"
'
+test_expect_success 'prompt - untracked files status indicator - shell variable unset with config disabled' '
+ printf " (master)" > expected &&
+ test_config bash.showUntrackedFiles false &&
+ (
+ sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
+ __git_ps1 > "$actual"
+ ) &&
+ test_cmp expected "$actual"
+'
+
+test_expect_success 'prompt - untracked files status indicator - shell variable unset with config enabled' '
+ printf " (master)" > expected &&
+ test_config bash.showUntrackedFiles true &&
+ (
+ sane_unset GIT_PS1_SHOWUNTRACKEDFILES &&
+ __git_ps1 > "$actual"
+ ) &&
+ test_cmp expected "$actual"
+'
+
+test_expect_success 'prompt - untracked files status indicator - shell variable set with config disabled' '
+ printf " (master)" > expected &&
+ test_config bash.showUntrackedFiles false &&
+ (
+ GIT_PS1_SHOWUNTRACKEDFILES=y &&
+ __git_ps1 > "$actual"
+ ) &&
+ test_cmp expected "$actual"
+'
+
+test_expect_success 'prompt - untracked files status indicator - shell variable set with config enabled' '
+ printf " (master %%)" > expected &&
+ test_config bash.showUntrackedFiles true &&
+ (
+ GIT_PS1_SHOWUNTRACKEDFILES=y &&
+ __git_ps1 > "$actual"
+ ) &&
+ test_cmp expected "$actual"
+'
+
test_expect_success 'prompt - untracked files status indicator - not shown inside .git directory' '
printf " (GIT_DIR!)" > expected &&
(
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index fa62d01..61d0804 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -135,12 +135,12 @@ test_pause () {
fi
}
-# Call test_commit with the arguments "<message> [<file> [<contents>]]"
+# Call test_commit with the arguments "<message> [<file> [<contents> [<tag>]]]"
#
# This will commit a file with the given contents and the given commit
-# message. It will also add a tag with <message> as name.
+# message, and tag the resulting commit with the given tag name.
#
-# Both <file> and <contents> default to <message>.
+# <file>, <contents>, and <tag> all default to <message>.
test_commit () {
notick= &&
@@ -168,7 +168,7 @@ test_commit () {
test_tick
fi &&
git commit $signoff -m "$1" &&
- git tag "$1"
+ git tag "${4:-$1}"
}
# Call test_merge with the arguments "<message> <commit>", where <commit>
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 1a6c4ab..1f51025 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -666,12 +666,14 @@ case $(uname -s) in
# backslashes in pathspec are converted to '/'
# exec does not inherit the PID
test_set_prereq MINGW
+ test_set_prereq NOT_CYGWIN
test_set_prereq SED_STRIPS_CR
;;
*CYGWIN*)
test_set_prereq POSIXPERM
test_set_prereq EXECKEEPSPID
test_set_prereq NOT_MINGW
+ test_set_prereq CYGWIN
test_set_prereq SED_STRIPS_CR
;;
*)
@@ -679,6 +681,7 @@ case $(uname -s) in
test_set_prereq BSLASHPSPEC
test_set_prereq EXECKEEPSPID
test_set_prereq NOT_MINGW
+ test_set_prereq NOT_CYGWIN
;;
esac
@@ -757,3 +760,9 @@ test_lazy_prereq AUTOIDENT '
# When the tests are run as root, permission tests will report that
# things are writable when they shouldn't be.
test -w / || test_set_prereq SANITY
+
+GIT_UNZIP=${GIT_UNZIP:-unzip}
+test_lazy_prereq UNZIP '
+ "$GIT_UNZIP" -v
+ test $? -ne 127
+'