summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/Makefile4
-rwxr-xr-xt/lib-credential.sh2
-rw-r--r--t/lib-cvs.sh2
-rw-r--r--t/lib-git-daemon.sh10
-rwxr-xr-xt/lib-gpg.sh2
-rw-r--r--t/lib-httpd.sh22
-rwxr-xr-xt/perf/p5302-pack-index.sh2
-rwxr-xr-xt/perf/p5310-pack-bitmaps.sh57
-rwxr-xr-xt/t0001-init.sh223
-rwxr-xr-xt/t0008-ignores.sh31
-rwxr-xr-xt/t0010-racy-git.sh4
-rwxr-xr-xt/t0011-hashmap.sh240
-rwxr-xr-xt/t0020-crlf.sh42
-rwxr-xr-xt/t0025-crlf-auto.sh38
-rwxr-xr-xt/t0026-eol-config.sh20
-rwxr-xr-xt/t0030-stripspace.sh20
-rwxr-xr-xt/t0040-parse-options.sh7
-rwxr-xr-xt/t0060-path-utils.sh21
-rwxr-xr-xt/t0300-credentials.sh2
-rwxr-xr-xt/t1000-read-tree-m-3way.sh4
-rwxr-xr-xt/t1001-read-tree-m-2way.sh18
-rwxr-xr-xt/t1002-read-tree-m-u-2way.sh10
-rwxr-xr-xt/t1003-read-tree-prefix.sh2
-rwxr-xr-xt/t1004-read-tree-m-u-wf.sh8
-rwxr-xr-xt/t1020-subdirectory.sh24
-rwxr-xr-xt/t1050-large.sh4
-rwxr-xr-xt/t1300-repo-config.sh64
-rwxr-xr-xt/t1302-repo-version.sh2
-rwxr-xr-xt/t1305-config-include.sh32
-rwxr-xr-xt/t1400-update-ref.sh100
-rwxr-xr-xt/t1502-rev-parse-parseopt.sh92
-rwxr-xr-xt/t1510-repo-setup.sh4
-rwxr-xr-xt/t1600-index.sh76
-rwxr-xr-xt/t2104-update-index-skip-worktree.sh2
-rwxr-xr-xt/t2107-update-index-basic.sh13
-rwxr-xr-xt/t2200-add-update.sh9
-rwxr-xr-xt/t3004-ls-files-basic.sh17
-rwxr-xr-xt/t3070-wildmatch.sh13
-rwxr-xr-xt/t3200-branch.sh22
-rwxr-xr-xt/t3301-notes.sh49
-rwxr-xr-xt/t3400-rebase.sh17
-rwxr-xr-xt/t3404-rebase-interactive.sh69
-rwxr-xr-xt/t3413-rebase-hook.sh6
-rwxr-xr-xt/t3508-cherry-pick-many-commits.sh6
-rwxr-xr-xt/t3600-rm.sh3
-rwxr-xr-xt/t3905-stash-include-untracked.sh4
-rwxr-xr-xt/t3910-mac-os-precompose.sh26
-rwxr-xr-xt/t4006-diff-mode.sh2
-rwxr-xr-xt/t4010-diff-pathspec.sh4
-rwxr-xr-xt/t4012-diff-binary.sh16
-rwxr-xr-xt/t4013-diff-various.sh6
-rwxr-xr-xt/t4014-format-patch.sh24
-rwxr-xr-xt/t4018-diff-funcname.sh230
-rw-r--r--t/t4018/README18
-rw-r--r--t/t4018/cpp-c++-function4
-rw-r--r--t/t4018/cpp-class-constructor4
-rw-r--r--t/t4018/cpp-class-constructor-mem-init5
-rw-r--r--t/t4018/cpp-class-definition4
-rw-r--r--t/t4018/cpp-class-definition-derived5
-rw-r--r--t/t4018/cpp-class-destructor4
-rw-r--r--t/t4018/cpp-function-returning-global-type4
-rw-r--r--t/t4018/cpp-function-returning-nested5
-rw-r--r--t/t4018/cpp-function-returning-pointer4
-rw-r--r--t/t4018/cpp-function-returning-reference4
-rw-r--r--t/t4018/cpp-gnu-style-function5
-rw-r--r--t/t4018/cpp-namespace-definition4
-rw-r--r--t/t4018/cpp-operator-definition4
-rw-r--r--t/t4018/cpp-skip-access-specifiers8
-rw-r--r--t/t4018/cpp-skip-comment-block9
-rw-r--r--t/t4018/cpp-skip-labels8
-rw-r--r--t/t4018/cpp-struct-definition9
-rw-r--r--t/t4018/cpp-struct-single-line7
-rw-r--r--t/t4018/cpp-template-function-definition4
-rw-r--r--t/t4018/cpp-union-definition4
-rw-r--r--t/t4018/cpp-void-c-function4
-rw-r--r--t/t4018/custom1-pattern17
-rw-r--r--t/t4018/custom2-match-to-end-of-line8
-rw-r--r--t/t4018/custom3-alternation-in-pattern17
-rw-r--r--t/t4018/java-class-member-function8
-rw-r--r--t/t4018/perl-skip-end-of-heredoc8
-rw-r--r--t/t4018/perl-skip-forward-decl10
-rw-r--r--t/t4018/perl-skip-sub-in-pod18
-rw-r--r--t/t4018/perl-sub-definition4
-rw-r--r--t/t4018/perl-sub-definition-kr-brace4
-rwxr-xr-xt/t4036-format-patch-signer-mime.sh2
-rwxr-xr-xt/t4038-diff-combined.sh2
-rwxr-xr-xt/t4056-diff-order.sh21
-rwxr-xr-xt/t4057-diff-combined-paths.sh106
-rwxr-xr-xt/t4107-apply-ignore-whitespace.sh12
-rwxr-xr-xt/t4116-apply-reverse.sh12
-rwxr-xr-xt/t4119-apply-config.sh2
-rwxr-xr-xt/t4204-patch-id.sh4
-rwxr-xr-xt/t4209-log-pickaxe.sh166
-rwxr-xr-xt/t5000-tar-tree.sh13
-rwxr-xr-xt/t5150-request-pull.sh30
-rwxr-xr-xt/t5305-include-tag.sh4
-rwxr-xr-xt/t5310-pack-bitmaps.sh173
-rwxr-xr-xt/t5400-send-pack.sh1
-rwxr-xr-xt/t5510-fetch.sh6
-rwxr-xr-xt/t5529-push-errors.sh48
-rwxr-xr-xt/t5537-fetch-shallow.sh13
-rwxr-xr-xt/t5560-http-backend-noserver.sh4
-rwxr-xr-xt/t5570-git-daemon.sh1
-rwxr-xr-xt/t5602-clone-remote-exec.sh13
-rwxr-xr-xt/t5701-clone-local.sh6
-rwxr-xr-xt/t5801-remote-helpers.sh48
-rwxr-xr-xt/t6006-rev-list-format.sh9
-rwxr-xr-xt/t7001-mv.sh7
-rwxr-xr-xt/t7004-tag.sh69
-rwxr-xr-xt/t7006-pager.sh18
-rwxr-xr-xt/t7101-reset-empty-subdirs.sh (renamed from t/t7101-reset.sh)0
-rwxr-xr-xt/t7102-reset.sh15
-rwxr-xr-xt/t7104-reset-hard.sh (renamed from t/t7104-reset.sh)0
-rwxr-xr-xt/t7400-submodule-basic.sh5
-rwxr-xr-xt/t7406-submodule-update.sh1
-rwxr-xr-xt/t7500-commit.sh11
-rwxr-xr-xt/t7501-commit.sh53
-rwxr-xr-xt/t7502-commit.sh23
-rwxr-xr-xt/t7510-signed-commit.sh25
-rwxr-xr-xt/t7601-merge-pull-config.sh21
-rwxr-xr-xt/t7700-repack.sh18
-rwxr-xr-xt/t7800-difftool.sh2
-rwxr-xr-xt/t7810-grep.sh70
-rwxr-xr-xt/t9001-send-email.sh2
-rwxr-xr-xt/t9107-git-svn-migrate.sh54
-rwxr-xr-xt/t9114-git-svn-dcommit-merge.sh4
-rwxr-xr-xt/t9116-git-svn-log.sh46
-rwxr-xr-xt/t9117-git-svn-init-clone.sh20
-rwxr-xr-xt/t9118-git-svn-funky-branch-names.sh20
-rwxr-xr-xt/t9120-git-svn-clone-with-percent-escapes.sh14
-rwxr-xr-xt/t9125-git-svn-multi-glob-branch-names.sh6
-rwxr-xr-xt/t9128-git-svn-cmd-branch.sh18
-rwxr-xr-xt/t9130-git-svn-authors-file.sh3
-rwxr-xr-xt/t9135-git-svn-moved-branch-empty-file.sh2
-rwxr-xr-xt/t9141-git-svn-multiple-branches.sh28
-rwxr-xr-xt/t9145-git-svn-master-branch.sh2
-rwxr-xr-xt/t9154-git-svn-fancy-glob.sh6
-rwxr-xr-xt/t9155-git-svn-fetch-deleted-tag.sh4
-rwxr-xr-xt/t9156-git-svn-fetch-deleted-tag-2.sh6
-rwxr-xr-xt/t9161-git-svn-mergeinfo-push.sh22
-rwxr-xr-xt/t9163-git-svn-reset-clears-caches.sh4
-rwxr-xr-xt/t9165-git-svn-fetch-merge-branch-of-branch.sh2
-rwxr-xr-xt/t9166-git-svn-fetch-merge-branch-of-branch2.sh2
-rwxr-xr-xt/t9167-git-svn-cmd-branch-subproject.sh2
-rwxr-xr-xt/t9400-git-cvsserver-server.sh1
-rwxr-xr-xt/t9903-bash-prompt.sh42
-rw-r--r--t/test-lib-functions.sh63
-rw-r--r--t/test-lib.sh7
148 files changed, 2295 insertions, 1067 deletions
diff --git a/t/Makefile b/t/Makefile
index 2373a04..8fd1a72 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -36,11 +36,11 @@ test: pre-clean $(TEST_LINT)
$(MAKE) aggregate-results-and-cleanup
prove: pre-clean $(TEST_LINT)
- @echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
+ @echo "*** prove ***"; $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)
$(MAKE) clean-except-prove-cache
$(T):
- @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
+ @echo "*** $@ ***"; '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
pre-clean:
$(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
diff --git a/t/lib-credential.sh b/t/lib-credential.sh
index 957ae93..9e7d796 100755
--- a/t/lib-credential.sh
+++ b/t/lib-credential.sh
@@ -281,7 +281,7 @@ helper_test_timeout() {
cat >askpass <<\EOF
#!/bin/sh
echo >&2 askpass: $*
-what=`echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z`
+what=$(echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z)
echo "askpass-$what"
EOF
chmod +x askpass
diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh
index 5076718..9b2bcfb 100644
--- a/t/lib-cvs.sh
+++ b/t/lib-cvs.sh
@@ -13,7 +13,7 @@ fi
CVS="cvs -f"
export CVS
-cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
+cvsps_version=$(cvsps -h 2>&1 | sed -ne 's/cvsps version //p')
case "$cvsps_version" in
2.1 | 2.2*)
;;
diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh
index 394b06b..bc4b341 100644
--- a/t/lib-git-daemon.sh
+++ b/t/lib-git-daemon.sh
@@ -16,13 +16,14 @@
# stop_git_daemon
# test_done
-if test -z "$GIT_TEST_GIT_DAEMON"
+test_tristate GIT_TEST_GIT_DAEMON
+if test "$GIT_TEST_GIT_DAEMON" = false
then
- skip_all="git-daemon testing disabled (define GIT_TEST_GIT_DAEMON to enable)"
+ skip_all="git-daemon testing disabled (unset GIT_TEST_GIT_DAEMON to enable)"
test_done
fi
-LIB_GIT_DAEMON_PORT=${LIB_GIT_DAEMON_PORT-'8121'}
+LIB_GIT_DAEMON_PORT=${LIB_GIT_DAEMON_PORT-${this_test#t}}
GIT_DAEMON_PID=
GIT_DAEMON_DOCUMENT_ROOT_PATH="$PWD"/repo
@@ -58,7 +59,8 @@ start_git_daemon() {
kill "$GIT_DAEMON_PID"
wait "$GIT_DAEMON_PID"
trap 'die' EXIT
- error "git daemon failed to start"
+ test_skip_or_die $GIT_TEST_GIT_DAEMON \
+ "git daemon failed to start"
fi
}
diff --git a/t/lib-gpg.sh b/t/lib-gpg.sh
index 05824fa..fd499e7 100755
--- a/t/lib-gpg.sh
+++ b/t/lib-gpg.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-gpg_version=`gpg --version 2>&1`
+gpg_version=$(gpg --version 2>&1)
if test $? = 127; then
say "You do not seem to have gpg installed"
else
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index b43162e..252cbf1 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -30,9 +30,10 @@
# Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
#
-if test -z "$GIT_TEST_HTTPD"
+test_tristate GIT_TEST_HTTPD
+if test "$GIT_TEST_HTTPD" = false
then
- skip_all="Network testing disabled (define GIT_TEST_HTTPD to enable)"
+ skip_all="Network testing disabled (unset GIT_TEST_HTTPD to enable)"
test_done
fi
@@ -76,8 +77,7 @@ GIT_VALGRIND_OPTIONS=$GIT_VALGRIND_OPTIONS; export GIT_VALGRIND_OPTIONS
if ! test -x "$LIB_HTTPD_PATH"
then
- skip_all="skipping test, no web server found at '$LIB_HTTPD_PATH'"
- test_done
+ test_skip_or_die $GIT_TEST_HTTPD "no web server found at '$LIB_HTTPD_PATH'"
fi
HTTPD_VERSION=`$LIB_HTTPD_PATH -v | \
@@ -89,19 +89,20 @@ then
then
if ! test $HTTPD_VERSION -ge 2
then
- skip_all="skipping test, at least Apache version 2 is required"
- test_done
+ test_skip_or_die $GIT_TEST_HTTPD \
+ "at least Apache version 2 is required"
fi
if ! test -d "$DEFAULT_HTTPD_MODULE_PATH"
then
- skip_all="Apache module directory not found. Skipping tests."
- test_done
+ test_skip_or_die $GIT_TEST_HTTPD \
+ "Apache module directory not found"
fi
LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH"
fi
else
- error "Could not identify web server at '$LIB_HTTPD_PATH'"
+ test_skip_or_die $GIT_TEST_HTTPD \
+ "Could not identify web server at '$LIB_HTTPD_PATH'"
fi
prepare_httpd() {
@@ -155,9 +156,8 @@ start_httpd() {
>&3 2>&4
if test $? -ne 0
then
- skip_all="skipping test, web server setup failed"
trap 'die' EXIT
- test_done
+ test_skip_or_die $GIT_TEST_HTTPD "web server setup failed"
fi
}
diff --git a/t/perf/p5302-pack-index.sh b/t/perf/p5302-pack-index.sh
index 6cb5b0d..5ee9211 100755
--- a/t/perf/p5302-pack-index.sh
+++ b/t/perf/p5302-pack-index.sh
@@ -8,7 +8,7 @@ test_perf_large_repo
test_expect_success 'repack' '
git repack -ad &&
- PACK=`ls .git/objects/pack/*.pack | head -n1` &&
+ PACK=$(ls .git/objects/pack/*.pack | head -n1) &&
test -f "$PACK" &&
export PACK
'
diff --git a/t/perf/p5310-pack-bitmaps.sh b/t/perf/p5310-pack-bitmaps.sh
new file mode 100755
index 0000000..685d46f
--- /dev/null
+++ b/t/perf/p5310-pack-bitmaps.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+test_description='Tests pack performance using bitmaps'
+. ./perf-lib.sh
+
+test_perf_large_repo
+
+# note that we do everything through config,
+# since we want to be able to compare bitmap-aware
+# git versus non-bitmap git
+test_expect_success 'setup bitmap config' '
+ git config pack.writebitmaps true &&
+ git config pack.writebitmaphashcache true
+'
+
+test_perf 'repack to disk' '
+ git repack -ad
+'
+
+test_perf 'simulated clone' '
+ git pack-objects --stdout --all </dev/null >/dev/null
+'
+
+test_perf 'simulated fetch' '
+ have=$(git rev-list HEAD~100 -1) &&
+ {
+ echo HEAD &&
+ echo ^$have
+ } | git pack-objects --revs --stdout >/dev/null
+'
+
+test_expect_success 'create partial bitmap state' '
+ # pick a commit to represent the repo tip in the past
+ cutoff=$(git rev-list HEAD~100 -1) &&
+ orig_tip=$(git rev-parse HEAD) &&
+
+ # now kill off all of the refs and pretend we had
+ # just the one tip
+ rm -rf .git/logs .git/refs/* .git/packed-refs
+ git update-ref HEAD $cutoff
+
+ # and then repack, which will leave us with a nice
+ # big bitmap pack of the "old" history, and all of
+ # the new history will be loose, as if it had been pushed
+ # up incrementally and exploded via unpack-objects
+ git repack -Ad
+
+ # and now restore our original tip, as if the pushes
+ # had happened
+ git update-ref HEAD $orig_tip
+'
+
+test_perf 'partial bitmap' '
+ git pack-objects --stdout --all </dev/null >/dev/null
+'
+
+test_done
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 9fb582b..2f30203 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -12,8 +12,8 @@ check_config () {
echo "expected a directory $1, a file $1/config and $1/refs"
return 1
fi
- bare=$(GIT_CONFIG="$1/config" git config --bool core.bare)
- worktree=$(GIT_CONFIG="$1/config" git config core.worktree) ||
+ bare=$(cd "$1" && git config --bool core.bare)
+ worktree=$(cd "$1" && git config core.worktree) ||
worktree=unset
test "$bare" = "$2" && test "$worktree" = "$3" || {
@@ -24,18 +24,12 @@ check_config () {
}
test_expect_success 'plain' '
- (
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir plain &&
- cd plain &&
- git init
- ) &&
+ git init plain &&
check_config plain/.git false unset
'
test_expect_success 'plain nested in bare' '
(
- sane_unset GIT_DIR GIT_WORK_TREE &&
git init --bare bare-ancestor.git &&
cd bare-ancestor.git &&
mkdir plain-nested &&
@@ -47,7 +41,6 @@ test_expect_success 'plain nested in bare' '
test_expect_success 'plain through aliased command, outside any git repo' '
(
- sane_unset GIT_DIR GIT_WORK_TREE &&
HOME=$(pwd)/alias-config &&
export HOME &&
mkdir alias-config &&
@@ -65,7 +58,6 @@ test_expect_success 'plain through aliased command, outside any git repo' '
test_expect_failure 'plain nested through aliased command' '
(
- sane_unset GIT_DIR GIT_WORK_TREE &&
git init plain-ancestor-aliased &&
cd plain-ancestor-aliased &&
echo "[alias] aliasedinit = init" >>.git/config &&
@@ -78,7 +70,6 @@ test_expect_failure 'plain nested through aliased command' '
test_expect_failure 'plain nested in bare through aliased command' '
(
- sane_unset GIT_DIR GIT_WORK_TREE &&
git init --bare bare-ancestor-aliased.git &&
cd bare-ancestor-aliased.git &&
echo "[alias] aliasedinit = init" >>config &&
@@ -90,66 +81,36 @@ test_expect_failure 'plain nested in bare through aliased command' '
'
test_expect_success 'plain with GIT_WORK_TREE' '
- if (
- sane_unset GIT_DIR &&
- mkdir plain-wt &&
- cd plain-wt &&
- GIT_WORK_TREE=$(pwd) git init
- )
- then
- echo Should have failed -- GIT_WORK_TREE should not be used
- false
- fi
+ mkdir plain-wt &&
+ test_must_fail env GIT_WORK_TREE="$(pwd)/plain-wt" git init plain-wt
'
test_expect_success 'plain bare' '
- (
- sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
- mkdir plain-bare-1 &&
- cd plain-bare-1 &&
- git --bare init
- ) &&
+ git --bare init plain-bare-1 &&
check_config plain-bare-1 true unset
'
test_expect_success 'plain bare with GIT_WORK_TREE' '
- if (
- sane_unset GIT_DIR GIT_CONFIG &&
- mkdir plain-bare-2 &&
- cd plain-bare-2 &&
- GIT_WORK_TREE=$(pwd) git --bare init
- )
- then
- echo Should have failed -- GIT_WORK_TREE should not be used
- false
- fi
+ mkdir plain-bare-2 &&
+ test_must_fail \
+ env GIT_WORK_TREE="$(pwd)/plain-bare-2" \
+ git --bare init plain-bare-2
'
test_expect_success 'GIT_DIR bare' '
-
- (
- sane_unset GIT_CONFIG &&
- mkdir git-dir-bare.git &&
- GIT_DIR=git-dir-bare.git git init
- ) &&
+ mkdir git-dir-bare.git &&
+ GIT_DIR=git-dir-bare.git git init &&
check_config git-dir-bare.git true unset
'
test_expect_success 'init --bare' '
-
- (
- sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
- mkdir init-bare.git &&
- cd init-bare.git &&
- git init --bare
- ) &&
+ git init --bare init-bare.git &&
check_config init-bare.git true unset
'
test_expect_success 'GIT_DIR non-bare' '
(
- sane_unset GIT_CONFIG &&
mkdir non-bare &&
cd non-bare &&
GIT_DIR=.git git init
@@ -160,7 +121,6 @@ test_expect_success 'GIT_DIR non-bare' '
test_expect_success 'GIT_DIR & GIT_WORK_TREE (1)' '
(
- sane_unset GIT_CONFIG &&
mkdir git-dir-wt-1.git &&
GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-1.git git init
) &&
@@ -168,23 +128,16 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (1)' '
'
test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
-
- if (
- sane_unset GIT_CONFIG &&
- mkdir git-dir-wt-2.git &&
- GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-2.git git --bare init
- )
- then
- echo Should have failed -- --bare should not be used
- false
- fi
+ mkdir git-dir-wt-2.git &&
+ test_must_fail env \
+ GIT_WORK_TREE="$(pwd)" \
+ GIT_DIR=git-dir-wt-2.git \
+ git --bare init
'
test_expect_success 'reinit' '
(
- sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
-
mkdir again &&
cd again &&
git init >out1 2>err1 &&
@@ -200,35 +153,22 @@ test_expect_success 'reinit' '
test_expect_success 'init with --template' '
mkdir template-source &&
echo content >template-source/file &&
- (
- mkdir template-custom &&
- cd template-custom &&
- git init --template=../template-source
- ) &&
+ git init --template=../template-source template-custom &&
test_cmp template-source/file template-custom/.git/file
'
test_expect_success 'init with --template (blank)' '
- (
- mkdir template-plain &&
- cd template-plain &&
- git init
- ) &&
- test -f template-plain/.git/info/exclude &&
- (
- mkdir template-blank &&
- cd template-blank &&
- git init --template=
- ) &&
- ! test -f template-blank/.git/info/exclude
+ git init template-plain &&
+ test_path_is_file template-plain/.git/info/exclude &&
+ git init --template= template-blank &&
+ test_path_is_missing template-blank/.git/info/exclude
'
test_expect_success 'init with init.templatedir set' '
mkdir templatedir-source &&
echo Content >templatedir-source/file &&
+ test_config_global init.templatedir "${HOME}/templatedir-source" &&
(
- test_config="${HOME}/.gitconfig" &&
- git config -f "$test_config" init.templatedir "${HOME}/templatedir-source" &&
mkdir templatedir-set &&
cd templatedir-set &&
sane_unset GIT_TEMPLATE_DIR &&
@@ -240,78 +180,55 @@ test_expect_success 'init with init.templatedir set' '
'
test_expect_success 'init --bare/--shared overrides system/global config' '
- (
- test_config="$HOME"/.gitconfig &&
- git config -f "$test_config" core.bare false &&
- git config -f "$test_config" core.sharedRepository 0640 &&
- mkdir init-bare-shared-override &&
- cd init-bare-shared-override &&
- git init --bare --shared=0666
- ) &&
+ test_config_global core.bare false &&
+ test_config_global core.sharedRepository 0640 &&
+ git init --bare --shared=0666 init-bare-shared-override &&
check_config init-bare-shared-override true unset &&
test x0666 = \
- x`git config -f init-bare-shared-override/config core.sharedRepository`
+ x$(git config -f init-bare-shared-override/config core.sharedRepository)
'
test_expect_success 'init honors global core.sharedRepository' '
- (
- test_config="$HOME"/.gitconfig &&
- git config -f "$test_config" core.sharedRepository 0666 &&
- mkdir shared-honor-global &&
- cd shared-honor-global &&
- git init
- ) &&
+ test_config_global core.sharedRepository 0666 &&
+ git init shared-honor-global &&
test x0666 = \
- x`git config -f shared-honor-global/.git/config core.sharedRepository`
+ x$(git config -f shared-honor-global/.git/config core.sharedRepository)
'
test_expect_success 'init rejects insanely long --template' '
- (
- insane=$(printf "x%09999dx" 1) &&
- mkdir test &&
- cd test &&
- test_must_fail git init --template=$insane
- )
+ test_must_fail git init --template=$(printf "x%09999dx" 1) test
'
test_expect_success 'init creates a new directory' '
rm -fr newdir &&
- (
- git init newdir &&
- test -d newdir/.git/refs
- )
+ git init newdir &&
+ test_path_is_dir newdir/.git/refs
'
test_expect_success 'init creates a new bare directory' '
rm -fr newdir &&
- (
- git init --bare newdir &&
- test -d newdir/refs
- )
+ git init --bare newdir &&
+ test_path_is_dir newdir/refs
'
test_expect_success 'init recreates a directory' '
rm -fr newdir &&
- (
- mkdir newdir &&
- git init newdir &&
- test -d newdir/.git/refs
- )
+ mkdir newdir &&
+ git init newdir &&
+ test_path_is_dir newdir/.git/refs
'
test_expect_success 'init recreates a new bare directory' '
rm -fr newdir &&
- (
- mkdir newdir &&
- git init --bare newdir &&
- test -d newdir/refs
- )
+ mkdir newdir &&
+ git init --bare newdir &&
+ test_path_is_dir newdir/refs
'
test_expect_success 'init creates a new deep directory' '
rm -fr newdir &&
git init newdir/a/b/c &&
- test -d newdir/a/b/c/.git/refs
+ test_path_is_dir newdir/a/b/c/.git/refs
'
test_expect_success POSIXPERM 'init creates a new deep directory (umask vs. shared)' '
@@ -321,7 +238,7 @@ test_expect_success POSIXPERM 'init creates a new deep directory (umask vs. shar
# the repository itself should follow "shared"
umask 002 &&
git init --bare --shared=0660 newdir/a/b/c &&
- test -d newdir/a/b/c/refs &&
+ test_path_is_dir newdir/a/b/c/refs &&
ls -ld newdir/a newdir/a/b > lsab.out &&
! grep -v "^drwxrw[sx]r-x" lsab.out &&
ls -ld newdir/a/b/c > lsc.out &&
@@ -331,52 +248,46 @@ test_expect_success POSIXPERM 'init creates a new deep directory (umask vs. shar
test_expect_success 'init notices EEXIST (1)' '
rm -fr newdir &&
- (
- >newdir &&
- test_must_fail git init newdir &&
- test -f newdir
- )
+ >newdir &&
+ test_must_fail git init newdir &&
+ test_path_is_file newdir
'
test_expect_success 'init notices EEXIST (2)' '
rm -fr newdir &&
- (
- mkdir newdir &&
- >newdir/a
- test_must_fail git init newdir/a/b &&
- test -f newdir/a
- )
+ mkdir newdir &&
+ >newdir/a &&
+ test_must_fail git init newdir/a/b &&
+ test_path_is_file newdir/a
'
test_expect_success POSIXPERM,SANITY 'init notices EPERM' '
rm -fr newdir &&
- (
- mkdir newdir &&
- chmod -w newdir &&
- test_must_fail git init newdir/a/b
- )
+ mkdir newdir &&
+ chmod -w newdir &&
+ test_must_fail git init newdir/a/b
'
test_expect_success 'init creates a new bare directory with global --bare' '
rm -rf newdir &&
git --bare init newdir &&
- test -d newdir/refs
+ test_path_is_dir newdir/refs
'
test_expect_success 'init prefers command line to GIT_DIR' '
rm -rf newdir &&
mkdir otherdir &&
GIT_DIR=otherdir git --bare init newdir &&
- test -d newdir/refs &&
- ! test -d otherdir/refs
+ test_path_is_dir newdir/refs &&
+ test_path_is_missing otherdir/refs
'
test_expect_success 'init with separate gitdir' '
rm -rf newdir &&
git init --separate-git-dir realgitdir newdir &&
- echo "gitdir: `pwd`/realgitdir" >expected &&
+ echo "gitdir: $(pwd)/realgitdir" >expected &&
test_cmp expected newdir/.git &&
- test -d realgitdir/refs
+ test_path_is_dir realgitdir/refs
'
test_expect_success 're-init on .git file' '
@@ -388,10 +299,10 @@ test_expect_success 're-init to update git link' '
cd newdir &&
git init --separate-git-dir ../surrealgitdir
) &&
- echo "gitdir: `pwd`/surrealgitdir" >expected &&
+ echo "gitdir: $(pwd)/surrealgitdir" >expected &&
test_cmp expected newdir/.git &&
- test -d surrealgitdir/refs &&
- ! test -d realgitdir/refs
+ test_path_is_dir surrealgitdir/refs &&
+ test_path_is_missing realgitdir/refs
'
test_expect_success 're-init to move gitdir' '
@@ -401,9 +312,9 @@ test_expect_success 're-init to move gitdir' '
cd newdir &&
git init --separate-git-dir ../realgitdir
) &&
- echo "gitdir: `pwd`/realgitdir" >expected &&
+ echo "gitdir: $(pwd)/realgitdir" >expected &&
test_cmp expected newdir/.git &&
- test -d realgitdir/refs
+ test_path_is_dir realgitdir/refs
'
test_expect_success SYMLINKS 're-init to move gitdir symlink' '
@@ -415,10 +326,10 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
ln -s here .git &&
git init --separate-git-dir ../realgitdir
) &&
- echo "gitdir: `pwd`/realgitdir" >expected &&
+ echo "gitdir: $(pwd)/realgitdir" >expected &&
test_cmp expected newdir/.git &&
- test -d realgitdir/refs &&
- ! test -d newdir/here
+ test_cmp expected newdir/here &&
+ test_path_is_dir realgitdir/refs
'
test_done
diff --git a/t/t0008-ignores.sh b/t/t0008-ignores.sh
index b4d98e6..63beb99 100755
--- a/t/t0008-ignores.sh
+++ b/t/t0008-ignores.sh
@@ -775,4 +775,35 @@ test_expect_success PIPE 'streaming support for --stdin' '
echo "$response" | grep "^:: two"
'
+############################################################################
+#
+# test whitespace handling
+
+test_expect_success 'trailing whitespace is ignored' '
+ mkdir whitespace &&
+ >whitespace/trailing &&
+ >whitespace/untracked &&
+ echo "whitespace/trailing " >ignore &&
+ cat >expect <<EOF &&
+whitespace/untracked
+EOF
+ : >err.expect &&
+ git ls-files -o -X ignore whitespace >actual 2>err &&
+ test_cmp expect actual &&
+ test_cmp err.expect err
+'
+
+test_expect_success !MINGW 'quoting allows trailing whitespace' '
+ rm -rf whitespace &&
+ mkdir whitespace &&
+ >"whitespace/trailing " &&
+ >whitespace/untracked &&
+ echo "whitespace/trailing\\ \\ " >ignore &&
+ echo whitespace/untracked >expect &&
+ : >err.expect &&
+ git ls-files -o -X ignore whitespace >actual 2>err &&
+ test_cmp expect actual &&
+ test_cmp err.expect err
+'
+
test_done
diff --git a/t/t0010-racy-git.sh b/t/t0010-racy-git.sh
index e45a9e4..5657c5a 100755
--- a/t/t0010-racy-git.sh
+++ b/t/t0010-racy-git.sh
@@ -14,7 +14,7 @@ do
git update-index --add infocom
echo xyzzy >infocom
- files=`git diff-files -p`
+ files=$(git diff-files -p)
test_expect_success \
"Racy GIT trial #$trial part A" \
'test "" != "$files"'
@@ -23,7 +23,7 @@ do
echo xyzzy >cornerstone
git update-index --add cornerstone
- files=`git diff-files -p`
+ files=$(git diff-files -p)
test_expect_success \
"Racy GIT trial #$trial part B" \
'test "" != "$files"'
diff --git a/t/t0011-hashmap.sh b/t/t0011-hashmap.sh
new file mode 100755
index 0000000..391e2b6
--- /dev/null
+++ b/t/t0011-hashmap.sh
@@ -0,0 +1,240 @@
+#!/bin/sh
+
+test_description='test hashmap and string hash functions'
+. ./test-lib.sh
+
+test_hashmap() {
+ echo "$1" | test-hashmap $3 > actual &&
+ echo "$2" > expect &&
+ test_cmp expect actual
+}
+
+test_expect_success 'hash functions' '
+
+test_hashmap "hash key1" "2215982743 2215982743 116372151 116372151" &&
+test_hashmap "hash key2" "2215982740 2215982740 116372148 116372148" &&
+test_hashmap "hash fooBarFrotz" "1383912807 1383912807 3189766727 3189766727" &&
+test_hashmap "hash foobarfrotz" "2862305959 2862305959 3189766727 3189766727"
+
+'
+
+test_expect_success 'put' '
+
+test_hashmap "put key1 value1
+put key2 value2
+put fooBarFrotz value3
+put foobarfrotz value4
+size" "NULL
+NULL
+NULL
+NULL
+64 4"
+
+'
+
+test_expect_success 'put (case insensitive)' '
+
+test_hashmap "put key1 value1
+put key2 value2
+put fooBarFrotz value3
+size" "NULL
+NULL
+NULL
+64 3" ignorecase
+
+'
+
+test_expect_success 'replace' '
+
+test_hashmap "put key1 value1
+put key1 value2
+put fooBarFrotz value3
+put fooBarFrotz value4
+size" "NULL
+value1
+NULL
+value3
+64 2"
+
+'
+
+test_expect_success 'replace (case insensitive)' '
+
+test_hashmap "put key1 value1
+put Key1 value2
+put fooBarFrotz value3
+put foobarfrotz value4
+size" "NULL
+value1
+NULL
+value3
+64 2" ignorecase
+
+'
+
+test_expect_success 'get' '
+
+test_hashmap "put key1 value1
+put key2 value2
+put fooBarFrotz value3
+put foobarfrotz value4
+get key1
+get key2
+get fooBarFrotz
+get notInMap" "NULL
+NULL
+NULL
+NULL
+value1
+value2
+value3
+NULL"
+
+'
+
+test_expect_success 'get (case insensitive)' '
+
+test_hashmap "put key1 value1
+put key2 value2
+put fooBarFrotz value3
+get Key1
+get keY2
+get foobarfrotz
+get notInMap" "NULL
+NULL
+NULL
+value1
+value2
+value3
+NULL" ignorecase
+
+'
+
+test_expect_success 'add' '
+
+test_hashmap "add key1 value1
+add key1 value2
+add fooBarFrotz value3
+add fooBarFrotz value4
+get key1
+get fooBarFrotz
+get notInMap" "value2
+value1
+value4
+value3
+NULL"
+
+'
+
+test_expect_success 'add (case insensitive)' '
+
+test_hashmap "add key1 value1
+add Key1 value2
+add fooBarFrotz value3
+add foobarfrotz value4
+get key1
+get Foobarfrotz
+get notInMap" "value2
+value1
+value4
+value3
+NULL" ignorecase
+
+'
+
+test_expect_success 'remove' '
+
+test_hashmap "put key1 value1
+put key2 value2
+put fooBarFrotz value3
+remove key1
+remove key2
+remove notInMap
+size" "NULL
+NULL
+NULL
+value1
+value2
+NULL
+64 1"
+
+'
+
+test_expect_success 'remove (case insensitive)' '
+
+test_hashmap "put key1 value1
+put key2 value2
+put fooBarFrotz value3
+remove Key1
+remove keY2
+remove notInMap
+size" "NULL
+NULL
+NULL
+value1
+value2
+NULL
+64 1" ignorecase
+
+'
+
+test_expect_success 'iterate' '
+
+test_hashmap "put key1 value1
+put key2 value2
+put fooBarFrotz value3
+iterate" "NULL
+NULL
+NULL
+key2 value2
+key1 value1
+fooBarFrotz value3"
+
+'
+
+test_expect_success 'iterate (case insensitive)' '
+
+test_hashmap "put key1 value1
+put key2 value2
+put fooBarFrotz value3
+iterate" "NULL
+NULL
+NULL
+fooBarFrotz value3
+key2 value2
+key1 value1" ignorecase
+
+'
+
+test_expect_success 'grow / shrink' '
+
+ rm -f in &&
+ rm -f expect &&
+ for n in $(test_seq 51)
+ do
+ echo put key$n value$n >> in &&
+ echo NULL >> expect
+ done &&
+ echo size >> in &&
+ echo 64 51 >> expect &&
+ echo put key52 value52 >> in &&
+ echo NULL >> expect
+ echo size >> in &&
+ echo 256 52 >> expect &&
+ for n in $(test_seq 12)
+ do
+ echo remove key$n >> in &&
+ echo value$n >> expect
+ done &&
+ echo size >> in &&
+ echo 256 40 >> expect &&
+ echo remove key40 >> in &&
+ echo value40 >> expect &&
+ echo size >> in &&
+ echo 64 39 >> expect &&
+ cat in | test-hashmap > out &&
+ test_cmp expect out
+
+'
+
+test_done
diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
index e526184..d2e51a8 100755
--- a/t/t0020-crlf.sh
+++ b/t/t0020-crlf.sh
@@ -20,14 +20,14 @@ test_expect_success setup '
git commit -m initial &&
- one=`git rev-parse HEAD:one` &&
- dir=`git rev-parse HEAD:dir` &&
- two=`git rev-parse HEAD:dir/two` &&
- three=`git rev-parse HEAD:three` &&
+ one=$(git rev-parse HEAD:one) &&
+ dir=$(git rev-parse HEAD:dir) &&
+ two=$(git rev-parse HEAD:dir/two) &&
+ three=$(git rev-parse HEAD:three) &&
for w in Some extra lines here; do echo $w; done >>one &&
git diff >patch.file &&
- patched=`git hash-object --stdin <one` &&
+ patched=$(git hash-object --stdin <one) &&
git read-tree --reset -u HEAD &&
echo happy.
@@ -111,7 +111,7 @@ test_expect_success 'update with autocrlf=input' '
}
done &&
- differs=`git diff-index --cached HEAD` &&
+ differs=$(git diff-index --cached HEAD) &&
test -z "$differs" || {
echo Oops "$differs"
false
@@ -135,7 +135,7 @@ test_expect_success 'update with autocrlf=true' '
}
done &&
- differs=`git diff-index --cached HEAD` &&
+ differs=$(git diff-index --cached HEAD) &&
test -z "$differs" || {
echo Oops "$differs"
false
@@ -158,9 +158,9 @@ test_expect_success 'checkout with autocrlf=true' '
break
}
done &&
- test "$one" = `git hash-object --stdin <one` &&
- test "$two" = `git hash-object --stdin <dir/two` &&
- differs=`git diff-index --cached HEAD` &&
+ test "$one" = $(git hash-object --stdin <one) &&
+ test "$two" = $(git hash-object --stdin <dir/two) &&
+ differs=$(git diff-index --cached HEAD) &&
test -z "$differs" || {
echo Oops "$differs"
false
@@ -184,9 +184,9 @@ test_expect_success 'checkout with autocrlf=input' '
git update-index -- $f
fi
done &&
- test "$one" = `git hash-object --stdin <one` &&
- test "$two" = `git hash-object --stdin <dir/two` &&
- differs=`git diff-index --cached HEAD` &&
+ test "$one" = $(git hash-object --stdin <one) &&
+ test "$two" = $(git hash-object --stdin <dir/two) &&
+ differs=$(git diff-index --cached HEAD) &&
test -z "$differs" || {
echo Oops "$differs"
false
@@ -200,7 +200,7 @@ test_expect_success 'apply patch (autocrlf=input)' '
git read-tree --reset -u HEAD &&
git apply patch.file &&
- test "$patched" = "`git hash-object --stdin <one`" || {
+ test "$patched" = "$(git hash-object --stdin <one)" || {
echo "Eh? apply without index"
false
}
@@ -213,7 +213,7 @@ test_expect_success 'apply patch --cached (autocrlf=input)' '
git read-tree --reset -u HEAD &&
git apply --cached patch.file &&
- test "$patched" = `git rev-parse :one` || {
+ test "$patched" = $(git rev-parse :one) || {
echo "Eh? apply with --cached"
false
}
@@ -226,8 +226,8 @@ test_expect_success 'apply patch --index (autocrlf=input)' '
git read-tree --reset -u HEAD &&
git apply --index patch.file &&
- test "$patched" = `git rev-parse :one` &&
- test "$patched" = `git hash-object --stdin <one` || {
+ test "$patched" = $(git rev-parse :one) &&
+ test "$patched" = $(git hash-object --stdin <one) || {
echo "Eh? apply with --index"
false
}
@@ -240,7 +240,7 @@ test_expect_success 'apply patch (autocrlf=true)' '
git read-tree --reset -u HEAD &&
git apply patch.file &&
- test "$patched" = "`remove_cr <one | git hash-object --stdin`" || {
+ test "$patched" = "$(remove_cr <one | git hash-object --stdin)" || {
echo "Eh? apply without index"
false
}
@@ -253,7 +253,7 @@ test_expect_success 'apply patch --cached (autocrlf=true)' '
git read-tree --reset -u HEAD &&
git apply --cached patch.file &&
- test "$patched" = `git rev-parse :one` || {
+ test "$patched" = $(git rev-parse :one) || {
echo "Eh? apply without index"
false
}
@@ -266,8 +266,8 @@ test_expect_success 'apply patch --index (autocrlf=true)' '
git read-tree --reset -u HEAD &&
git apply --index patch.file &&
- test "$patched" = `git rev-parse :one` &&
- test "$patched" = "`remove_cr <one | git hash-object --stdin`" || {
+ test "$patched" = $(git rev-parse :one) &&
+ test "$patched" = "$(remove_cr <one | git hash-object --stdin)" || {
echo "Eh? apply with --index"
false
}
diff --git a/t/t0025-crlf-auto.sh b/t/t0025-crlf-auto.sh
index f5f67a6..b0e5694 100755
--- a/t/t0025-crlf-auto.sh
+++ b/t/t0025-crlf-auto.sh
@@ -19,9 +19,9 @@ test_expect_success setup '
git commit -m initial &&
- one=`git rev-parse HEAD:one` &&
- two=`git rev-parse HEAD:two` &&
- three=`git rev-parse HEAD:three` &&
+ one=$(git rev-parse HEAD:one) &&
+ two=$(git rev-parse HEAD:two) &&
+ three=$(git rev-parse HEAD:three) &&
echo happy.
'
@@ -33,9 +33,9 @@ test_expect_success 'default settings cause no changes' '
! has_cr one &&
has_cr two &&
- onediff=`git diff one` &&
- twodiff=`git diff two` &&
- threediff=`git diff three` &&
+ onediff=$(git diff one) &&
+ twodiff=$(git diff two) &&
+ threediff=$(git diff three) &&
test -z "$onediff" -a -z "$twodiff" -a -z "$threediff"
'
@@ -48,7 +48,7 @@ test_expect_success 'crlf=true causes a CRLF file to be normalized' '
# Note, "normalized" means that git will normalize it if added
has_cr two &&
- twodiff=`git diff two` &&
+ twodiff=$(git diff two) &&
test -n "$twodiff"
'
@@ -60,7 +60,7 @@ test_expect_success 'text=true causes a CRLF file to be normalized' '
# Note, "normalized" means that git will normalize it if added
has_cr two &&
- twodiff=`git diff two` &&
+ twodiff=$(git diff two) &&
test -n "$twodiff"
'
@@ -72,7 +72,7 @@ test_expect_success 'eol=crlf gives a normalized file CRLFs with autocrlf=false'
git read-tree --reset -u HEAD &&
has_cr one &&
- onediff=`git diff one` &&
+ onediff=$(git diff one) &&
test -z "$onediff"
'
@@ -84,7 +84,7 @@ test_expect_success 'eol=crlf gives a normalized file CRLFs with autocrlf=input'
git read-tree --reset -u HEAD &&
has_cr one &&
- onediff=`git diff one` &&
+ onediff=$(git diff one) &&
test -z "$onediff"
'
@@ -96,7 +96,7 @@ test_expect_success 'eol=lf gives a normalized file LFs with autocrlf=true' '
git read-tree --reset -u HEAD &&
! has_cr one &&
- onediff=`git diff one` &&
+ onediff=$(git diff one) &&
test -z "$onediff"
'
@@ -108,9 +108,9 @@ test_expect_success 'autocrlf=true does not normalize CRLF files' '
has_cr one &&
has_cr two &&
- onediff=`git diff one` &&
- twodiff=`git diff two` &&
- threediff=`git diff three` &&
+ onediff=$(git diff one) &&
+ twodiff=$(git diff two) &&
+ threediff=$(git diff three) &&
test -z "$onediff" -a -z "$twodiff" -a -z "$threediff"
'
@@ -123,9 +123,9 @@ test_expect_success 'text=auto, autocrlf=true _does_ normalize CRLF files' '
has_cr one &&
has_cr two &&
- onediff=`git diff one` &&
- twodiff=`git diff two` &&
- threediff=`git diff three` &&
+ onediff=$(git diff one) &&
+ twodiff=$(git diff two) &&
+ threediff=$(git diff three) &&
test -z "$onediff" -a -n "$twodiff" -a -z "$threediff"
'
@@ -137,7 +137,7 @@ test_expect_success 'text=auto, autocrlf=true does not normalize binary files' '
git read-tree --reset -u HEAD &&
! has_cr three &&
- threediff=`git diff three` &&
+ threediff=$(git diff three) &&
test -z "$threediff"
'
@@ -148,7 +148,7 @@ test_expect_success 'eol=crlf _does_ normalize binary files' '
git read-tree --reset -u HEAD &&
has_cr three &&
- threediff=`git diff three` &&
+ threediff=$(git diff three) &&
test -z "$threediff"
'
diff --git a/t/t0026-eol-config.sh b/t/t0026-eol-config.sh
index fe0164b..e1126aa 100755
--- a/t/t0026-eol-config.sh
+++ b/t/t0026-eol-config.sh
@@ -20,8 +20,8 @@ test_expect_success setup '
git commit -m initial &&
- one=`git rev-parse HEAD:one` &&
- two=`git rev-parse HEAD:two` &&
+ one=$(git rev-parse HEAD:one) &&
+ two=$(git rev-parse HEAD:two) &&
echo happy.
'
@@ -34,8 +34,8 @@ test_expect_success 'eol=lf puts LFs in normalized file' '
! has_cr one &&
! has_cr two &&
- onediff=`git diff one` &&
- twodiff=`git diff two` &&
+ onediff=$(git diff one) &&
+ twodiff=$(git diff two) &&
test -z "$onediff" -a -z "$twodiff"
'
@@ -47,8 +47,8 @@ test_expect_success 'eol=crlf puts CRLFs in normalized file' '
has_cr one &&
! has_cr two &&
- onediff=`git diff one` &&
- twodiff=`git diff two` &&
+ onediff=$(git diff one) &&
+ twodiff=$(git diff two) &&
test -z "$onediff" -a -z "$twodiff"
'
@@ -61,8 +61,8 @@ test_expect_success 'autocrlf=true overrides eol=lf' '
has_cr one &&
has_cr two &&
- onediff=`git diff one` &&
- twodiff=`git diff two` &&
+ onediff=$(git diff one) &&
+ twodiff=$(git diff two) &&
test -z "$onediff" -a -z "$twodiff"
'
@@ -75,8 +75,8 @@ test_expect_success 'autocrlf=true overrides unset eol' '
has_cr one &&
has_cr two &&
- onediff=`git diff one` &&
- twodiff=`git diff two` &&
+ onediff=$(git diff one) &&
+ twodiff=$(git diff two) &&
test -z "$onediff" -a -z "$twodiff"
'
diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
index a8e84d8..0333dd9 100755
--- a/t/t0030-stripspace.sh
+++ b/t/t0030-stripspace.sh
@@ -225,22 +225,22 @@ test_expect_success \
test_expect_success \
'text without newline at end should end with newline' '
- test `printf "$ttt" | git stripspace | wc -l` -gt 0 &&
- test `printf "$ttt$ttt" | git stripspace | wc -l` -gt 0 &&
- test `printf "$ttt$ttt$ttt" | git stripspace | wc -l` -gt 0 &&
- test `printf "$ttt$ttt$ttt$ttt" | git stripspace | wc -l` -gt 0
+ test $(printf "$ttt" | git stripspace | wc -l) -gt 0 &&
+ test $(printf "$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
+ test $(printf "$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0 &&
+ test $(printf "$ttt$ttt$ttt$ttt" | git stripspace | wc -l) -gt 0
'
# text plus spaces at the end:
test_expect_success \
'text plus spaces without newline at end should end with newline' '
- test `printf "$ttt$sss" | git stripspace | wc -l` -gt 0 &&
- test `printf "$ttt$ttt$sss" | git stripspace | wc -l` -gt 0 &&
- test `printf "$ttt$ttt$ttt$sss" | git stripspace | wc -l` -gt 0 &&
- test `printf "$ttt$sss$sss" | git stripspace | wc -l` -gt 0 &&
- test `printf "$ttt$ttt$sss$sss" | git stripspace | wc -l` -gt 0 &&
- test `printf "$ttt$sss$sss$sss" | git stripspace | wc -l` -gt 0
+ test $(printf "$ttt$sss" | git stripspace | wc -l) -gt 0 &&
+ test $(printf "$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
+ test $(printf "$ttt$ttt$ttt$sss" | git stripspace | wc -l) -gt 0 &&
+ test $(printf "$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
+ test $(printf "$ttt$ttt$sss$sss" | git stripspace | wc -l) -gt 0 &&
+ test $(printf "$ttt$sss$sss$sss" | git stripspace | wc -l) -gt 0
'
test_expect_success \
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 65606df..a90c86b 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -30,7 +30,6 @@ String options
--string2 <str> get another string
--st <st> get another string (pervert ordering)
-o <str> get another string
- --default-string set string to default
--list <str> add str to list
Magic arguments
@@ -293,7 +292,7 @@ cat > expect <<EOF
boolean: 0
integer: 0
timestamp: 1
-string: default
+string: (not set)
abbrev: 7
verbose: 0
quiet: yes
@@ -302,8 +301,8 @@ file: (not set)
arg 00: foo
EOF
-test_expect_success 'OPT_DATE() and OPT_SET_PTR() work' '
- test-parse-options -t "1970-01-01 00:00:01 +0000" --default-string \
+test_expect_success 'OPT_DATE() works' '
+ test-parse-options -t "1970-01-01 00:00:01 +0000" \
foo -q > output 2> output.err &&
test_must_be_empty output.err &&
test_cmp expect output
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 07c10c8..c0143a0 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -190,6 +190,27 @@ test_expect_success SYMLINKS 'real path works on symlinks' '
test "$sym" = "$(test-path-utils real_path "$dir2/syml")"
'
+test_expect_success SYMLINKS 'prefix_path works with absolute paths to work tree symlinks' '
+ ln -s target symlink &&
+ test "$(test-path-utils prefix_path prefix "$(pwd)/symlink")" = "symlink"
+'
+
+test_expect_success 'prefix_path works with only absolute path to work tree' '
+ echo "" >expected &&
+ test-path-utils prefix_path prefix "$(pwd)" >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'prefix_path rejects absolute path to dir with same beginning as work tree' '
+ test_must_fail test-path-utils prefix_path prefix "$(pwd)a"
+'
+
+test_expect_success SYMLINKS 'prefix_path works with absolute path to a symlink to work tree having same beginning as work tree' '
+ git init repo &&
+ ln -s repo repolink &&
+ test "a" = "$(cd repo && test-path-utils prefix_path prefix "$(pwd)/../repolink/a")"
+'
+
relative_path /foo/a/b/c/ /foo/a/b/ c/
relative_path /foo/a/b/c/ /foo/a/b c/
relative_path /foo/a//b//c/ ///foo/a/b// c/ POSIX
diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh
index 538ea5f..57ea5a1 100755
--- a/t/t0300-credentials.sh
+++ b/t/t0300-credentials.sh
@@ -6,7 +6,7 @@ test_description='basic credential helper tests'
test_expect_success 'setup helper scripts' '
cat >dump <<-\EOF &&
- whoami=`echo $0 | sed s/.*git-credential-//`
+ whoami=$(echo $0 | sed s/.*git-credential-//)
echo >&2 "$whoami: $*"
OIFS=$IFS
IFS==
diff --git a/t/t1000-read-tree-m-3way.sh b/t/t1000-read-tree-m-3way.sh
index babcdd2..a0b79b4 100755
--- a/t/t1000-read-tree-m-3way.sh
+++ b/t/t1000-read-tree-m-3way.sh
@@ -519,10 +519,10 @@ test_expect_success \
'rm -f .git/index F16 &&
echo F16 >F16 &&
git update-index --add F16 &&
- tree0=`git write-tree` &&
+ tree0=$(git write-tree) &&
echo E16 >F16 &&
git update-index F16 &&
- tree1=`git write-tree` &&
+ tree1=$(git write-tree) &&
read_tree_must_succeed -m $tree0 $tree1 $tree1 $tree0 &&
git ls-files --stage'
diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
index 3a24abf..db1b6f5 100755
--- a/t/t1001-read-tree-m-2way.sh
+++ b/t/t1001-read-tree-m-2way.sh
@@ -36,7 +36,7 @@ compare_change () {
}
check_cache_at () {
- clean_if_empty=`git diff-files -- "$1"`
+ clean_if_empty=$(git diff-files -- "$1")
case "$clean_if_empty" in
'') echo "$1: clean" ;;
?*) echo "$1: dirty" ;;
@@ -68,14 +68,14 @@ test_expect_success \
echo rezrov >rezrov &&
echo yomin >yomin &&
git update-index --add nitfol bozbar rezrov &&
- treeH=`git write-tree` &&
+ treeH=$(git write-tree) &&
echo treeH $treeH &&
git ls-tree $treeH &&
cat bozbar-new >bozbar &&
git update-index --add frotz bozbar --force-remove rezrov &&
git ls-files --stage >M.out &&
- treeM=`git write-tree` &&
+ treeM=$(git write-tree) &&
echo treeM $treeM &&
git ls-tree $treeM &&
git diff-tree $treeH $treeM'
@@ -315,7 +315,7 @@ test_expect_success \
'rm -f .git/index &&
echo DF >DF &&
git update-index --add DF &&
- treeDF=`git write-tree` &&
+ treeDF=$(git write-tree) &&
echo treeDF $treeDF &&
git ls-tree $treeDF &&
@@ -323,7 +323,7 @@ test_expect_success \
mkdir DF &&
echo DF/DF >DF/DF &&
git update-index --add --remove DF DF/DF &&
- treeDFDF=`git write-tree` &&
+ treeDFDF=$(git write-tree) &&
echo treeDFDF $treeDFDF &&
git ls-tree $treeDFDF &&
git ls-files --stage >DFDF.out'
@@ -345,7 +345,7 @@ test_expect_success \
'rm -f .git/index &&
: >a &&
git update-index --add a &&
- treeM=`git write-tree` &&
+ treeM=$(git write-tree) &&
echo treeM $treeM &&
git ls-tree $treeM &&
git ls-files --stage >treeM.out &&
@@ -354,7 +354,7 @@ test_expect_success \
git update-index --remove a &&
mkdir a &&
: >a/b &&
- treeH=`git write-tree` &&
+ treeH=$(git write-tree) &&
echo treeH $treeH &&
git ls-tree $treeH'
@@ -372,7 +372,7 @@ test_expect_success \
mkdir c &&
: >c/d &&
git update-index --add a c/d &&
- treeM=`git write-tree` &&
+ treeM=$(git write-tree) &&
echo treeM $treeM &&
git ls-tree $treeM &&
git ls-files --stage >treeM.out &&
@@ -381,7 +381,7 @@ test_expect_success \
mkdir a &&
: >a/b &&
git update-index --add --remove a a/b &&
- treeH=`git write-tree` &&
+ treeH=$(git write-tree) &&
echo treeH $treeH &&
git ls-tree $treeH'
diff --git a/t/t1002-read-tree-m-u-2way.sh b/t/t1002-read-tree-m-u-2way.sh
index a847709..fed877b 100755
--- a/t/t1002-read-tree-m-u-2way.sh
+++ b/t/t1002-read-tree-m-u-2way.sh
@@ -21,7 +21,7 @@ compare_change () {
}
check_cache_at () {
- clean_if_empty=`git diff-files -- "$1"`
+ clean_if_empty=$(git diff-files -- "$1")
case "$clean_if_empty" in
'') echo "$1: clean" ;;
?*) echo "$1: dirty" ;;
@@ -41,14 +41,14 @@ test_expect_success \
echo bozbar >bozbar &&
echo rezrov >rezrov &&
git update-index --add nitfol bozbar rezrov &&
- treeH=`git write-tree` &&
+ treeH=$(git write-tree) &&
echo treeH $treeH &&
git ls-tree $treeH &&
echo gnusto >bozbar &&
git update-index --add frotz bozbar --force-remove rezrov &&
git ls-files --stage >M.out &&
- treeM=`git write-tree` &&
+ treeM=$(git write-tree) &&
echo treeM $treeM &&
git ls-tree $treeM &&
sum bozbar frotz nitfol >M.sum &&
@@ -318,7 +318,7 @@ test_expect_success \
'rm -f .git/index &&
echo DF >DF &&
git update-index --add DF &&
- treeDF=`git write-tree` &&
+ treeDF=$(git write-tree) &&
echo treeDF $treeDF &&
git ls-tree $treeDF &&
@@ -326,7 +326,7 @@ test_expect_success \
mkdir DF &&
echo DF/DF >DF/DF &&
git update-index --add --remove DF DF/DF &&
- treeDFDF=`git write-tree` &&
+ treeDFDF=$(git write-tree) &&
echo treeDFDF $treeDFDF &&
git ls-tree $treeDFDF &&
git ls-files --stage >DFDF.out'
diff --git a/t/t1003-read-tree-prefix.sh b/t/t1003-read-tree-prefix.sh
index 8c6d67e..b6111cd 100755
--- a/t/t1003-read-tree-prefix.sh
+++ b/t/t1003-read-tree-prefix.sh
@@ -11,7 +11,7 @@ test_description='git read-tree --prefix test.
test_expect_success setup '
echo hello >one &&
git update-index --add one &&
- tree=`git write-tree` &&
+ tree=$(git write-tree) &&
echo tree is $tree
'
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
index 3e72aff..c70cf42 100755
--- a/t/t1004-read-tree-m-u-wf.sh
+++ b/t/t1004-read-tree-m-u-wf.sh
@@ -30,7 +30,7 @@ test_expect_success 'two-way not clobbering' '
echo >file2 master creates untracked file2 &&
echo >subdir/file2 master creates untracked subdir/file2 &&
- if err=`read_tree_u_must_succeed -m -u master side 2>&1`
+ if err=$(read_tree_u_must_succeed -m -u master side 2>&1)
then
echo should have complained
false
@@ -43,7 +43,7 @@ echo file2 >.gitignore
test_expect_success 'two-way with incorrect --exclude-per-directory (1)' '
- if err=`read_tree_u_must_succeed -m --exclude-per-directory=.gitignore master side 2>&1`
+ if err=$(read_tree_u_must_succeed -m --exclude-per-directory=.gitignore master side 2>&1)
then
echo should have complained
false
@@ -54,7 +54,7 @@ test_expect_success 'two-way with incorrect --exclude-per-directory (1)' '
test_expect_success 'two-way with incorrect --exclude-per-directory (2)' '
- if err=`read_tree_u_must_succeed -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore master side 2>&1`
+ if err=$(read_tree_u_must_succeed -m -u --exclude-per-directory=foo --exclude-per-directory=.gitignore master side 2>&1)
then
echo should have complained
false
@@ -95,7 +95,7 @@ test_expect_success 'three-way not clobbering a working tree file' '
git checkout master &&
echo >file3 file three created in master, untracked &&
echo >subdir/file3 file three created in master, untracked &&
- if err=`read_tree_u_must_succeed -m -u branch-point master side 2>&1`
+ if err=$(read_tree_u_must_succeed -m -u branch-point master side 2>&1)
then
echo should have complained
false
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
index 1e2945e..62c0d25 100755
--- a/t/t1020-subdirectory.sh
+++ b/t/t1020-subdirectory.sh
@@ -20,27 +20,27 @@ test_expect_success setup '
test_expect_success 'update-index and ls-files' '
git update-index --add one &&
- case "`git ls-files`" in
+ case "$(git ls-files)" in
one) echo pass one ;;
*) echo bad one; exit 1 ;;
esac &&
(
cd dir &&
git update-index --add two &&
- case "`git ls-files`" in
+ case "$(git ls-files)" in
two) echo pass two ;;
*) echo bad two; exit 1 ;;
esac
) &&
- case "`git ls-files`" in
+ case "$(git ls-files)" in
dir/two"$LF"one) echo pass both ;;
*) echo bad; exit 1 ;;
esac
'
test_expect_success 'cat-file' '
- two=`git ls-files -s dir/two` &&
- two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
+ two=$(git ls-files -s dir/two) &&
+ two=$(expr "$two" : "[0-7]* \\([0-9a-f]*\\)") &&
echo "$two" &&
git cat-file -p "$two" >actual &&
cmp dir/two actual &&
@@ -55,18 +55,18 @@ rm -f actual dir/actual
test_expect_success 'diff-files' '
echo a >>one &&
echo d >>dir/two &&
- case "`git diff-files --name-only`" in
+ case "$(git diff-files --name-only)" in
dir/two"$LF"one) echo pass top ;;
*) echo bad top; exit 1 ;;
esac &&
# diff should not omit leading paths
(
cd dir &&
- case "`git diff-files --name-only`" in
+ case "$(git diff-files --name-only)" in
dir/two"$LF"one) echo pass subdir ;;
*) echo bad subdir; exit 1 ;;
esac &&
- case "`git diff-files --name-only .`" in
+ case "$(git diff-files --name-only .)" in
dir/two) echo pass subdir limited ;;
*) echo bad subdir limited; exit 1 ;;
esac
@@ -74,11 +74,11 @@ test_expect_success 'diff-files' '
'
test_expect_success 'write-tree' '
- top=`git write-tree` &&
+ top=$(git write-tree) &&
echo $top &&
(
cd dir &&
- sub=`git write-tree` &&
+ sub=$(git write-tree) &&
echo $sub &&
test "z$top" = "z$sub"
)
@@ -96,7 +96,7 @@ test_expect_success 'checkout-index' '
test_expect_success 'read-tree' '
rm -f one dir/two &&
- tree=`git write-tree` &&
+ tree=$(git write-tree) &&
read_tree_u_must_succeed --reset -u "$tree" &&
cmp one original.one &&
cmp dir/two original.two &&
@@ -148,7 +148,7 @@ test_expect_success 'GIT_PREFIX for built-ins' '
(
cd dir &&
printf "change" >two &&
- env GIT_EXTERNAL_DIFF=./diff git diff >../actual
+ GIT_EXTERNAL_DIFF=./diff git diff >../actual
git checkout -- two
) &&
test_cmp expect actual
diff --git a/t/t1050-large.sh b/t/t1050-large.sh
index fd10528..aea4936 100755
--- a/t/t1050-large.sh
+++ b/t/t1050-large.sh
@@ -131,7 +131,7 @@ test_expect_success 'git-show a large file' '
'
test_expect_success 'index-pack' '
- git clone file://"`pwd`"/.git foo &&
+ git clone file://"$(pwd)"/.git foo &&
GIT_DIR=non-existent git index-pack --strict --verify foo/.git/objects/pack/*.pack
'
@@ -140,7 +140,7 @@ test_expect_success 'repack' '
'
test_expect_success 'pack-objects with large loose object' '
- SHA1=`git hash-object huge` &&
+ SHA1=$(git hash-object huge) &&
test_create_repo loose &&
echo $SHA1 | git pack-objects --stdout |
GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 9673593..3f80ff0 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -461,7 +461,7 @@ test_expect_success 'new variable inserts into proper section' '
test_cmp expect .git/config
'
-test_expect_success 'alternative GIT_CONFIG (non-existing file should fail)' '
+test_expect_success 'alternative --file (non-existing file should fail)' '
test_must_fail git config --file non-existing-config -l
'
@@ -475,15 +475,28 @@ ein.bahn=strasse
EOF
test_expect_success 'alternative GIT_CONFIG' '
- GIT_CONFIG=other-config git config -l >output &&
+ GIT_CONFIG=other-config git config --list >output &&
test_cmp expect output
'
test_expect_success 'alternative GIT_CONFIG (--file)' '
- git config --file other-config -l > output &&
+ git config --file other-config --list >output &&
test_cmp expect output
'
+test_expect_success 'alternative GIT_CONFIG (--file=-)' '
+ git config --file - --list <other-config >output &&
+ test_cmp expect output
+'
+
+test_expect_success 'setting a value in stdin is an error' '
+ test_must_fail git config --file - some.value foo
+'
+
+test_expect_success 'editing stdin is an error' '
+ test_must_fail git config --file - --edit
+'
+
test_expect_success 'refer config from subdirectory' '
mkdir x &&
(
@@ -495,10 +508,10 @@ test_expect_success 'refer config from subdirectory' '
'
-test_expect_success 'refer config from subdirectory via GIT_CONFIG' '
+test_expect_success 'refer config from subdirectory via --file' '
(
cd x &&
- GIT_CONFIG=../other-config git config --get ein.bahn >actual &&
+ git config --file=../other-config --get ein.bahn >actual &&
test_cmp expect actual
)
'
@@ -510,8 +523,8 @@ cat > expect << EOF
park = ausweis
EOF
-test_expect_success '--set in alternative GIT_CONFIG' '
- GIT_CONFIG=other-config git config anwohner.park ausweis &&
+test_expect_success '--set in alternative file' '
+ git config --file=other-config anwohner.park ausweis &&
test_cmp expect other-config
'
@@ -942,11 +955,11 @@ test_expect_success 'inner whitespace kept verbatim' '
test_expect_success SYMLINKS 'symlinked configuration' '
ln -s notyet myconfig &&
- GIT_CONFIG=myconfig git config test.frotz nitfol &&
+ git config --file=myconfig test.frotz nitfol &&
test -h myconfig &&
test -f notyet &&
- test "z$(GIT_CONFIG=notyet git config test.frotz)" = znitfol &&
- GIT_CONFIG=myconfig git config test.xyzzy rezrov &&
+ test "z$(git config --file=notyet test.frotz)" = znitfol &&
+ git config --file=myconfig test.xyzzy rezrov &&
test -h myconfig &&
test -f notyet &&
cat >expect <<-\EOF &&
@@ -954,31 +967,22 @@ test_expect_success SYMLINKS 'symlinked configuration' '
rezrov
EOF
{
- GIT_CONFIG=notyet git config test.frotz &&
- GIT_CONFIG=notyet git config test.xyzzy
+ git config --file=notyet test.frotz &&
+ git config --file=notyet test.xyzzy
} >actual &&
test_cmp expect actual
'
test_expect_success 'nonexistent configuration' '
- (
- GIT_CONFIG=doesnotexist &&
- export GIT_CONFIG &&
- test_must_fail git config --list &&
- test_must_fail git config test.xyzzy
- )
+ test_must_fail git config --file=doesnotexist --list &&
+ test_must_fail git config --file=doesnotexist test.xyzzy
'
test_expect_success SYMLINKS 'symlink to nonexistent configuration' '
ln -s doesnotexist linktonada &&
ln -s linktonada linktolinktonada &&
- (
- GIT_CONFIG=linktonada &&
- export GIT_CONFIG &&
- test_must_fail git config --list &&
- GIT_CONFIG=linktolinktonada &&
- test_must_fail git config --list
- )
+ test_must_fail git config --file=linktonada --list &&
+ test_must_fail git config --file=linktolinktonada --list
'
test_expect_success 'check split_cmdline return' "
@@ -1154,4 +1158,14 @@ test_expect_failure 'adding a key into an empty section reuses header' '
test_cmp expect .git/config
'
+test_expect_success POSIXPERM,PERL 'preserves existing permissions' '
+ chmod 0600 .git/config &&
+ git config imap.pass Hunter2 &&
+ perl -e \
+ "die q(badset) if ((stat(q(.git/config)))[2] & 07777) != 0600" &&
+ git config --rename-section imap pop &&
+ perl -e \
+ "die q(badrename) if ((stat(q(.git/config)))[2] & 07777) != 0600"
+'
+
test_done
diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh
index 0e47662..0d9388a 100755
--- a/t/t1302-repo-version.sh
+++ b/t/t1302-repo-version.sh
@@ -19,7 +19,7 @@ test_expect_success 'setup' '
test_create_repo "test" &&
test_create_repo "test2" &&
- GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99
+ git config --file=test2/.git/config core.repositoryformatversion 99
'
test_expect_success 'gitdir selection on normal repos' '
diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index a707076..9ba2ba1 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -113,7 +113,7 @@ test_expect_success 'missing include files are ignored' '
test_expect_success 'absolute includes from command line work' '
echo "[test]one = 1" >one &&
echo 1 >expect &&
- git -c include.path="$PWD/one" config test.one >actual &&
+ git -c include.path="$(pwd)/one" config test.one >actual &&
test_cmp expect actual
'
@@ -122,6 +122,36 @@ test_expect_success 'relative includes from command line fail' '
test_must_fail git -c include.path=one config test.one
'
+test_expect_success 'absolute includes from blobs work' '
+ echo "[test]one = 1" >one &&
+ echo "[include]path=$(pwd)/one" >blob &&
+ blob=$(git hash-object -w blob) &&
+ echo 1 >expect &&
+ git config --blob=$blob test.one >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'relative includes from blobs fail' '
+ echo "[test]one = 1" >one &&
+ echo "[include]path=one" >blob &&
+ blob=$(git hash-object -w blob) &&
+ test_must_fail git config --blob=$blob test.one
+'
+
+test_expect_success 'absolute includes from stdin work' '
+ echo "[test]one = 1" >one &&
+ echo 1 >expect &&
+ echo "[include]path=\"$(pwd)/one\"" |
+ git config --file - test.one >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'relative includes from stdin line fail' '
+ echo "[test]one = 1" >one &&
+ echo "[include]path=one" |
+ test_must_fail git config --file - test.one
+'
+
test_expect_success 'include cycles are detected' '
cat >.gitconfig <<-\EOF &&
[test]value = gitconfig
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index e130c52..4e2459a 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -350,22 +350,28 @@ test_expect_success 'stdin fails on unknown command' '
grep "fatal: unknown command: unknown $a" err
'
-test_expect_success 'stdin fails on badly quoted input' '
+test_expect_success 'stdin fails on unbalanced quotes' '
echo "create $a \"master" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
grep "fatal: badly quoted argument: \\\"master" err
'
-test_expect_success 'stdin fails on arguments not separated by space' '
+test_expect_success 'stdin fails on invalid escape' '
+ echo "create $a \"ma\zter\"" >stdin &&
+ test_must_fail git update-ref --stdin <stdin 2>err &&
+ grep "fatal: badly quoted argument: \\\"ma\\\\zter\\\"" err
+'
+
+test_expect_success 'stdin fails on junk after quoted argument' '
echo "create \"$a\"master" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: expected SP but got: master" err
+ grep "fatal: unexpected character after quoted argument: \\\"$a\\\"master" err
'
test_expect_success 'stdin fails create with no ref' '
echo "create " >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: create line missing <ref>" err
+ grep "fatal: create: missing <ref>" err
'
test_expect_success 'stdin fails create with bad ref name' '
@@ -377,19 +383,19 @@ test_expect_success 'stdin fails create with bad ref name' '
test_expect_success 'stdin fails create with no new value' '
echo "create $a" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: create $a missing <newvalue>" err
+ grep "fatal: create $a: missing <newvalue>" err
'
test_expect_success 'stdin fails create with too many arguments' '
echo "create $a $m $m" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: create $a has extra input: $m" err
+ grep "fatal: create $a: extra input: $m" err
'
test_expect_success 'stdin fails update with no ref' '
echo "update " >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: update line missing <ref>" err
+ grep "fatal: update: missing <ref>" err
'
test_expect_success 'stdin fails update with bad ref name' '
@@ -401,19 +407,19 @@ test_expect_success 'stdin fails update with bad ref name' '
test_expect_success 'stdin fails update with no new value' '
echo "update $a" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: update $a missing <newvalue>" err
+ grep "fatal: update $a: missing <newvalue>" err
'
test_expect_success 'stdin fails update with too many arguments' '
echo "update $a $m $m $m" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: update $a has extra input: $m" err
+ grep "fatal: update $a: extra input: $m" err
'
test_expect_success 'stdin fails delete with no ref' '
echo "delete " >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: delete line missing <ref>" err
+ grep "fatal: delete: missing <ref>" err
'
test_expect_success 'stdin fails delete with bad ref name' '
@@ -425,13 +431,13 @@ test_expect_success 'stdin fails delete with bad ref name' '
test_expect_success 'stdin fails delete with too many arguments' '
echo "delete $a $m $m" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: delete $a has extra input: $m" err
+ grep "fatal: delete $a: extra input: $m" err
'
test_expect_success 'stdin fails verify with too many arguments' '
echo "verify $a $m $m" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: verify $a has extra input: $m" err
+ grep "fatal: verify $a: extra input: $m" err
'
test_expect_success 'stdin fails option with unknown name' '
@@ -458,6 +464,24 @@ test_expect_success 'stdin create ref works' '
test_cmp expect actual
'
+test_expect_success 'stdin succeeds with quoted argument' '
+ git update-ref -d $a &&
+ echo "create $a \"$m\"" >stdin &&
+ git update-ref --stdin <stdin &&
+ git rev-parse $m >expect &&
+ git rev-parse $a >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'stdin succeeds with escaped character' '
+ git update-ref -d $a &&
+ echo "create $a \"ma\\163ter\"" >stdin &&
+ git update-ref --stdin <stdin &&
+ git rev-parse $m >expect &&
+ git rev-parse $a >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'stdin update ref creates with zero old value' '
echo "update $b $m $Z" >stdin &&
git update-ref --stdin <stdin &&
@@ -494,21 +518,21 @@ test_expect_success 'stdin update ref fails with wrong old value' '
test_expect_success 'stdin update ref fails with bad old value' '
echo "update $c $m does-not-exist" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: invalid old value for ref $c: does-not-exist" err &&
+ grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
test_must_fail git rev-parse --verify -q $c
'
test_expect_success 'stdin create ref fails with bad new value' '
echo "create $c does-not-exist" >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: invalid new value for ref $c: does-not-exist" err &&
+ grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
test_must_fail git rev-parse --verify -q $c
'
test_expect_success 'stdin create ref fails with zero new value' '
echo "create $c " >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: create $c given zero new value" err &&
+ grep "fatal: create $c: zero <newvalue>" err &&
test_must_fail git rev-parse --verify -q $c
'
@@ -532,7 +556,7 @@ test_expect_success 'stdin delete ref fails with wrong old value' '
test_expect_success 'stdin delete ref fails with zero old value' '
echo "delete $a " >stdin &&
test_must_fail git update-ref --stdin <stdin 2>err &&
- grep "fatal: delete $a given zero old value" err &&
+ grep "fatal: delete $a: zero <oldvalue>" err &&
git rev-parse $m >expect &&
git rev-parse $a >actual &&
test_cmp expect actual
@@ -673,7 +697,7 @@ test_expect_success 'stdin -z fails on unknown command' '
test_expect_success 'stdin -z fails create with no ref' '
printf $F "create " >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: create line missing <ref>" err
+ grep "fatal: create: missing <ref>" err
'
test_expect_success 'stdin -z fails create with bad ref name' '
@@ -685,7 +709,7 @@ test_expect_success 'stdin -z fails create with bad ref name' '
test_expect_success 'stdin -z fails create with no new value' '
printf $F "create $a" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: create $a missing <newvalue>" err
+ grep "fatal: create $a: unexpected end of input when reading <newvalue>" err
'
test_expect_success 'stdin -z fails create with too many arguments' '
@@ -697,25 +721,39 @@ test_expect_success 'stdin -z fails create with too many arguments' '
test_expect_success 'stdin -z fails update with no ref' '
printf $F "update " >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: update line missing <ref>" err
+ grep "fatal: update: missing <ref>" err
+'
+
+test_expect_success 'stdin -z fails update with too few args' '
+ printf $F "update $a" "$m" >stdin &&
+ test_must_fail git update-ref -z --stdin <stdin 2>err &&
+ grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
'
test_expect_success 'stdin -z fails update with bad ref name' '
- printf $F "update ~a" "$m" >stdin &&
+ printf $F "update ~a" "$m" "" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
grep "fatal: invalid ref format: ~a" err
'
+test_expect_success 'stdin -z emits warning with empty new value' '
+ git update-ref $a $m &&
+ printf $F "update $a" "" "" >stdin &&
+ git update-ref -z --stdin <stdin 2>err &&
+ grep "warning: update $a: missing <newvalue>, treating as zero" err &&
+ test_must_fail git rev-parse --verify -q $a
+'
+
test_expect_success 'stdin -z fails update with no new value' '
printf $F "update $a" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: update $a missing <newvalue>" err
+ grep "fatal: update $a: unexpected end of input when reading <newvalue>" err
'
test_expect_success 'stdin -z fails update with no old value' '
printf $F "update $a" "$m" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: update $a missing \\[<oldvalue>\\] NUL" err
+ grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
'
test_expect_success 'stdin -z fails update with too many arguments' '
@@ -727,7 +765,7 @@ test_expect_success 'stdin -z fails update with too many arguments' '
test_expect_success 'stdin -z fails delete with no ref' '
printf $F "delete " >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: delete line missing <ref>" err
+ grep "fatal: delete: missing <ref>" err
'
test_expect_success 'stdin -z fails delete with bad ref name' '
@@ -739,7 +777,7 @@ test_expect_success 'stdin -z fails delete with bad ref name' '
test_expect_success 'stdin -z fails delete with no old value' '
printf $F "delete $a" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: delete $a missing \\[<oldvalue>\\] NUL" err
+ grep "fatal: delete $a: unexpected end of input when reading <oldvalue>" err
'
test_expect_success 'stdin -z fails delete with too many arguments' '
@@ -757,7 +795,7 @@ test_expect_success 'stdin -z fails verify with too many arguments' '
test_expect_success 'stdin -z fails verify with no old value' '
printf $F "verify $a" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: verify $a missing \\[<oldvalue>\\] NUL" err
+ grep "fatal: verify $a: unexpected end of input when reading <oldvalue>" err
'
test_expect_success 'stdin -z fails option with unknown name' '
@@ -816,7 +854,7 @@ test_expect_success 'stdin -z update ref fails with wrong old value' '
test_expect_success 'stdin -z update ref fails with bad old value' '
printf $F "update $c" "$m" "does-not-exist" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: invalid old value for ref $c: does-not-exist" err &&
+ grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
test_must_fail git rev-parse --verify -q $c
'
@@ -834,14 +872,14 @@ test_expect_success 'stdin -z create ref fails with bad new value' '
git update-ref -d "$c" &&
printf $F "create $c" "does-not-exist" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: invalid new value for ref $c: does-not-exist" err &&
+ grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
test_must_fail git rev-parse --verify -q $c
'
-test_expect_success 'stdin -z create ref fails with zero new value' '
+test_expect_success 'stdin -z create ref fails with empty new value' '
printf $F "create $c" "" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: create $c given zero new value" err &&
+ grep "fatal: create $c: missing <newvalue>" err &&
test_must_fail git rev-parse --verify -q $c
'
@@ -865,7 +903,7 @@ test_expect_success 'stdin -z delete ref fails with wrong old value' '
test_expect_success 'stdin -z delete ref fails with zero old value' '
printf $F "delete $a" "$Z" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
- grep "fatal: delete $a given zero old value" err &&
+ grep "fatal: delete $a: zero <oldvalue>" err &&
git rev-parse $m >expect &&
git rev-parse $a >actual &&
test_cmp expect actual
@@ -923,7 +961,7 @@ test_expect_success 'stdin -z update refs works with identity updates' '
test_expect_success 'stdin -z update refs fails with wrong old value' '
git update-ref $c $m &&
- printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "" "$Z" >stdin &&
+ printf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$m" "$Z" >stdin &&
test_must_fail git update-ref -z --stdin <stdin 2>err &&
grep "fatal: Cannot lock the ref '"'"'$c'"'"'" err &&
git rev-parse $m >expect &&
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
index 83b1300..922423e 100755
--- a/t/t1502-rev-parse-parseopt.sh
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -3,44 +3,64 @@
test_description='test git rev-parse --parseopt'
. ./test-lib.sh
-cat > expect <<\END_EXPECT
-cat <<\EOF
-usage: some-command [options] <args>...
-
- some-command does foo and bar!
-
- -h, --help show the help
- --foo some nifty option --foo
- --bar ... some cool option --bar with an argument
- -b, --baz a short and long option
-
-An option group Header
- -C[...] option C with an optional argument
- -d, --data[=...] short and long option with an optional argument
-
-Extras
- --extra1 line above used to cause a segfault but no longer does
-
-EOF
+sed -e 's/^|//' >expect <<\END_EXPECT
+|cat <<\EOF
+|usage: some-command [options] <args>...
+|
+| some-command does foo and bar!
+|
+| -h, --help show the help
+| --foo some nifty option --foo
+| --bar ... some cool option --bar with an argument
+| -b, --baz a short and long option
+|
+|An option group Header
+| -C[...] option C with an optional argument
+| -d, --data[=...] short and long option with an optional argument
+|
+|Argument hints
+| -b <arg> short option required argument
+| --bar2 <arg> long option required argument
+| -e, --fuz <with-space>
+| short and long option required argument
+| -s[<some>] short option optional argument
+| --long[=<data>] long option optional argument
+| -g, --fluf[=<path>] short and long option optional argument
+| --longest <very-long-argument-hint>
+| a very long argument hint
+|
+|Extras
+| --extra1 line above used to cause a segfault but no longer does
+|
+|EOF
END_EXPECT
-cat > optionspec << EOF
-some-command [options] <args>...
-
-some-command does foo and bar!
---
-h,help show the help
-
-foo some nifty option --foo
-bar= some cool option --bar with an argument
-b,baz a short and long option
-
- An option group Header
-C? option C with an optional argument
-d,data? short and long option with an optional argument
-
-Extras
-extra1 line above used to cause a segfault but no longer does
+sed -e 's/^|//' >optionspec <<\EOF
+|some-command [options] <args>...
+|
+|some-command does foo and bar!
+|--
+|h,help show the help
+|
+|foo some nifty option --foo
+|bar= some cool option --bar with an argument
+|b,baz a short and long option
+|
+| An option group Header
+|C? option C with an optional argument
+|d,data? short and long option with an optional argument
+|
+| Argument hints
+|b=arg short option required argument
+|bar2=arg long option required argument
+|e,fuz=with-space short and long option required argument
+|s?some short option optional argument
+|long?data long option optional argument
+|g,fluf?path short and long option optional argument
+|longest=very-long-argument-hint a very long argument hint
+|
+|Extras
+|extra1 line above used to cause a segfault but no longer does
EOF
test_expect_success 'test --parseopt help output' '
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index cf2ee78..e1b2a99 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -777,9 +777,7 @@ test_expect_success '#30: core.worktree and core.bare conflict (gitfile version)
setup_repo 30 "$here/30" gitfile true &&
(
cd 30 &&
- GIT_DIR=.git &&
- export GIT_DIR &&
- test_must_fail git symbolic-ref HEAD 2>result
+ test_must_fail env GIT_DIR=.git git symbolic-ref HEAD 2>result
) &&
grep "core.bare and core.worktree" 30/result
'
diff --git a/t/t1600-index.sh b/t/t1600-index.sh
new file mode 100755
index 0000000..079d241
--- /dev/null
+++ b/t/t1600-index.sh
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+test_description='index file specific tests'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ echo 1 >a
+'
+
+test_expect_success 'bogus GIT_INDEX_VERSION issues warning' '
+ (
+ rm -f .git/index &&
+ GIT_INDEX_VERSION=2bogus &&
+ export GIT_INDEX_VERSION &&
+ git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
+ sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
+ warning: GIT_INDEX_VERSION set, but the value is invalid.
+ Using version Z
+ EOF
+ test_i18ncmp expect.err actual.err
+ )
+'
+
+test_expect_success 'out of bounds GIT_INDEX_VERSION issues warning' '
+ (
+ rm -f .git/index &&
+ GIT_INDEX_VERSION=1 &&
+ export GIT_INDEX_VERSION &&
+ git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
+ sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
+ warning: GIT_INDEX_VERSION set, but the value is invalid.
+ Using version Z
+ EOF
+ test_i18ncmp expect.err actual.err
+ )
+'
+
+test_expect_success 'no warning with bogus GIT_INDEX_VERSION and existing index' '
+ (
+ GIT_INDEX_VERSION=1 &&
+ export GIT_INDEX_VERSION &&
+ git add a 2>actual.err &&
+ >expect.err &&
+ test_i18ncmp expect.err actual.err
+ )
+'
+
+test_expect_success 'out of bounds index.version issues warning' '
+ (
+ sane_unset GIT_INDEX_VERSION &&
+ rm -f .git/index &&
+ git config --add index.version 1 &&
+ git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
+ sed -e "s/ Z$/ /" <<-\EOF >expect.err &&
+ warning: index.version set, but the value is invalid.
+ Using version Z
+ EOF
+ test_i18ncmp expect.err actual.err
+ )
+'
+
+test_expect_success 'GIT_INDEX_VERSION takes precedence over config' '
+ (
+ rm -f .git/index &&
+ GIT_INDEX_VERSION=4 &&
+ export GIT_INDEX_VERSION &&
+ git config --add index.version 2 &&
+ git add a 2>&1 &&
+ echo 4 >expect &&
+ test-index-version <.git/index >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_done
diff --git a/t/t2104-update-index-skip-worktree.sh b/t/t2104-update-index-skip-worktree.sh
index 1d0879b..29c1fb1 100755
--- a/t/t2104-update-index-skip-worktree.sh
+++ b/t/t2104-update-index-skip-worktree.sh
@@ -7,6 +7,8 @@ test_description='skip-worktree bit test'
. ./test-lib.sh
+test_set_index_version 3
+
cat >expect.full <<EOF
H 1
H 2
diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh
index a6405d3..fe2fb17 100755
--- a/t/t2107-update-index-basic.sh
+++ b/t/t2107-update-index-basic.sh
@@ -48,4 +48,17 @@ test_expect_success '--cacheinfo does not accept gitlink null sha1' '
test_cmp expect actual
'
+test_expect_success '--cacheinfo mode,sha1,path (new syntax)' '
+ echo content >file &&
+ git hash-object -w --stdin <file >expect &&
+
+ git update-index --add --cacheinfo 100644 "$(cat expect)" file &&
+ git rev-parse :file >actual &&
+ test_cmp expect actual &&
+
+ git update-index --add --cacheinfo "100644,$(cat expect),elif" &&
+ git rev-parse :elif >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 9bf2bdf..e16b15d 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -80,18 +80,13 @@ 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' '
+test_expect_success 'non-qualified update in subdir updates from the root' '
(
cd dir1 &&
echo even more >>sub2 &&
git add -u
) &&
- cat >expect <<-\EOF &&
- check
- top
- EOF
+ : >expect &&
git diff-files --name-only >actual &&
test_cmp expect actual
'
diff --git a/t/t3004-ls-files-basic.sh b/t/t3004-ls-files-basic.sh
index 8d9bc3c..9c7adbd 100755
--- a/t/t3004-ls-files-basic.sh
+++ b/t/t3004-ls-files-basic.sh
@@ -36,4 +36,21 @@ test_expect_success 'ls-files -h in corrupt repository' '
test_i18ngrep "[Uu]sage: git ls-files " broken/usage
'
+test_expect_success SYMLINKS 'ls-files with absolute paths to symlinks' '
+ mkdir subs &&
+ ln -s nosuch link &&
+ ln -s ../nosuch subs/link &&
+ git add link subs/link &&
+ git ls-files -s link subs/link >expect &&
+ git ls-files -s "$(pwd)/link" "$(pwd)/subs/link" >actual &&
+ test_cmp expect actual &&
+
+ (
+ cd subs &&
+ git ls-files -s link >../expect &&
+ git ls-files -s "$(pwd)/link" >../actual
+ ) &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index 38446a0..ef509df 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -14,19 +14,6 @@ match() {
! test-wildmatch wildmatch '$3' '$4'
"
fi
- if [ $2 = 1 ]; then
- test_expect_success "fnmatch: match '$3' '$4'" "
- test-wildmatch fnmatch '$3' '$4'
- "
- elif [ $2 = 0 ]; then
- test_expect_success "fnmatch: no match '$3' '$4'" "
- ! test-wildmatch fnmatch '$3' '$4'
- "
-# else
-# test_expect_success BROKEN_FNMATCH "fnmatch: '$3' '$4'" "
-# ! test-wildmatch fnmatch '$3' '$4'
-# "
- fi
}
imatch() {
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index fcdb867..ac31b71 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -507,6 +507,16 @@ EOF
test_cmp expected actual
'
+test_expect_success '--set-upstream-to notices an error to set branch as own upstream' '
+ git branch --set-upstream-to refs/heads/my13 my13 2>actual &&
+ cat >expected <<-\EOF &&
+ warning: Not setting branch my13 as its own upstream.
+ EOF
+ test_expect_code 1 git config branch.my13.remote &&
+ test_expect_code 1 git config branch.my13.merge &&
+ test_i18ncmp 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
@@ -849,11 +859,7 @@ test_expect_success 'detect typo in branch name when using --edit-description' '
write_script editor <<-\EOF &&
echo "New contents" >"$1"
EOF
- (
- EDITOR=./editor &&
- export EDITOR &&
- test_must_fail git branch --edit-description no-such-branch
- )
+ test_must_fail env EDITOR=./editor git branch --edit-description no-such-branch
'
test_expect_success 'refuse --edit-description on unborn branch for now' '
@@ -861,11 +867,7 @@ test_expect_success 'refuse --edit-description on unborn branch for now' '
echo "New contents" >"$1"
EOF
git checkout --orphan unborn &&
- (
- EDITOR=./editor &&
- export EDITOR &&
- test_must_fail git branch --edit-description
- )
+ test_must_fail env EDITOR=./editor git branch --edit-description
'
test_expect_success '--merged catches invalid object names' '
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 16de05a..cfd67ff 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -17,7 +17,7 @@ GIT_EDITOR=./fake_editor.sh
export GIT_EDITOR
test_expect_success 'cannot annotate non-existing HEAD' '
- (MSG=3 && export MSG && test_must_fail git notes add)
+ test_must_fail env MSG=3 git notes add
'
test_expect_success setup '
@@ -32,22 +32,16 @@ test_expect_success setup '
'
test_expect_success 'need valid notes ref' '
- (MSG=1 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
- test_must_fail git notes add) &&
- (MSG=2 GIT_NOTES_REF=/ && export MSG GIT_NOTES_REF &&
- test_must_fail git notes show)
+ test_must_fail env MSG=1 GIT_NOTES_REF=/ git notes show &&
+ test_must_fail env MSG=2 GIT_NOTES_REF=/ git notes show
'
test_expect_success 'refusing to add notes in refs/heads/' '
- (MSG=1 GIT_NOTES_REF=refs/heads/bogus &&
- export MSG GIT_NOTES_REF &&
- test_must_fail git notes add)
+ test_must_fail env MSG=1 GIT_NOTES_REF=refs/heads/bogus git notes add
'
test_expect_success 'refusing to edit notes in refs/remotes/' '
- (MSG=1 GIT_NOTES_REF=refs/remotes/bogus &&
- export MSG GIT_NOTES_REF &&
- test_must_fail git notes edit)
+ test_must_fail env MSG=1 GIT_NOTES_REF=refs/heads/bogus git notes edit
'
# 1 indicates caught gracefully by die, 128 means git-show barked
@@ -812,6 +806,33 @@ test_expect_success 'create note from non-existing note with "git notes add -C"
test_must_fail git notes list HEAD
'
+test_expect_success 'create note from non-blob with "git notes add -C" fails' '
+ commit=$(git rev-parse --verify HEAD) &&
+ tree=$(git rev-parse --verify HEAD:) &&
+ test_must_fail git notes add -C $commit &&
+ test_must_fail git notes add -C $tree &&
+ test_must_fail git notes list HEAD
+'
+
+cat > expect << EOF
+commit 80d796defacd5db327b7a4e50099663902fbdc5c
+Author: A U Thor <author@example.com>
+Date: Thu Apr 7 15:20:13 2005 -0700
+
+ 8th
+
+Notes (other):
+ This is a blob object
+EOF
+
+test_expect_success 'create note from blob with "git notes add -C" reuses blob id' '
+ blob=$(echo "This is a blob object" | git hash-object -w --stdin) &&
+ git notes add -C $blob &&
+ git log -1 > actual &&
+ test_cmp expect actual &&
+ test "$(git notes list HEAD)" = "$blob"
+'
+
cat > expect << EOF
commit 016e982bad97eacdbda0fcbd7ce5b0ba87c81f1b
Author: A U Thor <author@example.com>
@@ -838,11 +859,7 @@ test_expect_success 'create note from non-existing note with "git notes add -c"
git add a10 &&
test_tick &&
git commit -m 10th &&
- (
- MSG="yet another note" &&
- export MSG &&
- test_must_fail git notes add -c deadbeef
- ) &&
+ test_must_fail env MSG="yet another note" git notes add -c deadbeef &&
test_must_fail git notes list HEAD
'
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index 6d94b1f..80e0a95 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -88,6 +88,23 @@ test_expect_success 'rebase from ambiguous branch name' '
git rebase master
'
+test_expect_success 'rebase off of the previous branch using "-"' '
+ git checkout master &&
+ git checkout HEAD^ &&
+ git rebase @{-1} >expect.messages &&
+ git merge-base master HEAD >expect.forkpoint &&
+
+ git checkout master &&
+ git checkout HEAD^ &&
+ git rebase - >actual.messages &&
+ git merge-base master HEAD >actual.forkpoint &&
+
+ test_cmp expect.forkpoint actual.forkpoint &&
+ # the next one is dubious---we may want to say "-",
+ # instead of @{-1}, in the message
+ test_i18ncmp expect.messages actual.messages
+'
+
test_expect_success 'rebase a single mode change' '
git checkout master &&
git branch -D topic &&
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 50e22b1..c0023a5 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -102,12 +102,8 @@ test_expect_success 'rebase -i with the exec command runs from tree root' '
test_expect_success 'rebase -i with the exec command checks tree cleanness' '
git checkout master &&
- (
set_fake_editor &&
- FAKE_LINES="exec_echo_foo_>file1 1" &&
- export FAKE_LINES &&
- test_must_fail git rebase -i HEAD^
- ) &&
+ test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" git rebase -i HEAD^ &&
test_cmp_rev master^ HEAD &&
git reset --hard &&
git rebase --continue
@@ -116,12 +112,9 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
test_expect_success 'rebase -i with exec of inexistent command' '
git checkout master &&
test_when_finished "git rebase --abort" &&
- (
set_fake_editor &&
- FAKE_LINES="exec_this-command-does-not-exist 1" &&
- export FAKE_LINES &&
- test_must_fail git rebase -i HEAD^ >actual 2>&1
- ) &&
+ test_must_fail env FAKE_LINES="exec_this-command-does-not-exist 1" \
+ git rebase -i HEAD^ >actual 2>&1 &&
! grep "Maybe git-rebase is broken" actual
'
@@ -375,11 +368,7 @@ test_expect_success 'commit message used after conflict' '
git checkout -b conflict-fixup conflict-branch &&
base=$(git rev-parse HEAD~4) &&
set_fake_editor &&
- (
- FAKE_LINES="1 fixup 3 fixup 4" &&
- export FAKE_LINES &&
- test_must_fail git rebase -i $base
- ) &&
+ test_must_fail env FAKE_LINES="1 fixup 3 fixup 4" git rebase -i $base &&
echo three > conflict &&
git add conflict &&
FAKE_COMMIT_AMEND="ONCE" EXPECT_HEADER_COUNT=2 \
@@ -394,11 +383,7 @@ test_expect_success 'commit message retained after conflict' '
git checkout -b conflict-squash conflict-branch &&
base=$(git rev-parse HEAD~4) &&
set_fake_editor &&
- (
- FAKE_LINES="1 fixup 3 squash 4" &&
- export FAKE_LINES &&
- test_must_fail git rebase -i $base
- ) &&
+ test_must_fail env FAKE_LINES="1 fixup 3 squash 4" git rebase -i $base &&
echo three > conflict &&
git add conflict &&
FAKE_COMMIT_AMEND="TWICE" EXPECT_HEADER_COUNT=2 \
@@ -469,11 +454,7 @@ test_expect_success 'interrupted squash works as expected' '
git checkout -b interrupted-squash conflict-branch &&
one=$(git rev-parse HEAD~3) &&
set_fake_editor &&
- (
- FAKE_LINES="1 squash 3 2" &&
- export FAKE_LINES &&
- test_must_fail git rebase -i HEAD~3
- ) &&
+ test_must_fail env FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
(echo one; echo two; echo four) > conflict &&
git add conflict &&
test_must_fail git rebase --continue &&
@@ -487,11 +468,7 @@ test_expect_success 'interrupted squash works as expected (case 2)' '
git checkout -b interrupted-squash2 conflict-branch &&
one=$(git rev-parse HEAD~3) &&
set_fake_editor &&
- (
- FAKE_LINES="3 squash 1 2" &&
- export FAKE_LINES &&
- test_must_fail git rebase -i HEAD~3
- ) &&
+ test_must_fail env FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 &&
(echo one; echo four) > conflict &&
git add conflict &&
test_must_fail git rebase --continue &&
@@ -528,11 +505,7 @@ test_expect_success 'aborted --continue does not squash commits after "edit"' '
FAKE_LINES="edit 1" git rebase -i HEAD^ &&
echo "edited again" > file7 &&
git add file7 &&
- (
- FAKE_COMMIT_MESSAGE=" " &&
- export FAKE_COMMIT_MESSAGE &&
- test_must_fail git rebase --continue
- ) &&
+ test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue &&
test $old = $(git rev-parse HEAD) &&
git rebase --abort
'
@@ -547,11 +520,7 @@ test_expect_success 'auto-amend only edited commits after "edit"' '
echo "and again" > file7 &&
git add file7 &&
test_tick &&
- (
- FAKE_COMMIT_MESSAGE="and again" &&
- export FAKE_COMMIT_MESSAGE &&
- test_must_fail git rebase --continue
- ) &&
+ test_must_fail env FAKE_COMMIT_MESSAGE="and again" git rebase --continue &&
git rebase --abort
'
@@ -559,11 +528,7 @@ test_expect_success 'clean error after failed "exec"' '
test_tick &&
test_when_finished "git rebase --abort || :" &&
set_fake_editor &&
- (
- FAKE_LINES="1 exec_false" &&
- export FAKE_LINES &&
- test_must_fail git rebase -i HEAD^
- ) &&
+ test_must_fail env FAKE_LINES="1 exec_false" git rebase -i HEAD^ &&
echo "edited again" > file7 &&
git add file7 &&
test_must_fail git rebase --continue 2>error &&
@@ -947,12 +912,8 @@ test_expect_success 'rebase -i --root retain root commit author and message' '
test_expect_success 'rebase -i --root temporary sentinel commit' '
git checkout B &&
- (
- set_fake_editor &&
- FAKE_LINES="2" &&
- export FAKE_LINES &&
- test_must_fail git rebase -i --root
- ) &&
+ set_fake_editor &&
+ test_must_fail env FAKE_LINES="2" git rebase -i --root &&
git cat-file commit HEAD | grep "^tree 4b825dc642cb" &&
git rebase --abort
'
@@ -1042,11 +1003,7 @@ test_expect_success 'rebase -i error on commits with \ in message' '
test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" &&
test_commit TO-REMOVE will-conflict old-content &&
test_commit "\temp" will-conflict new-content dummy &&
- (
- EDITOR=true &&
- export EDITOR &&
- test_must_fail git rebase -i HEAD^ --onto HEAD^^ 2>error
- ) &&
+ test_must_fail env EDITOR=true git rebase -i HEAD^ --onto HEAD^^ 2>error &&
test_expect_code 1 grep " emp" error
'
diff --git a/t/t3413-rebase-hook.sh b/t/t3413-rebase-hook.sh
index 098b755..b6833e9 100755
--- a/t/t3413-rebase-hook.sh
+++ b/t/t3413-rebase-hook.sh
@@ -118,11 +118,7 @@ test_expect_success 'pre-rebase hook stops rebase (1)' '
test_expect_success 'pre-rebase hook stops rebase (2)' '
git checkout test &&
git reset --hard side &&
- (
- EDITOR=:
- export EDITOR
- test_must_fail git rebase -i master
- ) &&
+ test_must_fail env EDITOR=: git rebase -i master &&
test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
test 0 = $(git rev-list HEAD...side | wc -l)
'
diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh
index 19c99d7..b457333 100755
--- a/t/t3508-cherry-pick-many-commits.sh
+++ b/t/t3508-cherry-pick-many-commits.sh
@@ -65,12 +65,15 @@ test_expect_success 'output to keep user entertained during multi-pick' '
cat <<-\EOF >expected &&
[master OBJID] second
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:14:13 2005 -0700
1 file changed, 1 insertion(+)
[master OBJID] third
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:15:13 2005 -0700
1 file changed, 1 insertion(+)
[master OBJID] fourth
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:16:13 2005 -0700
1 file changed, 1 insertion(+)
EOF
@@ -98,14 +101,17 @@ test_expect_success 'output during multi-pick indicates merge strategy' '
Trying simple merge.
[master OBJID] second
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:14:13 2005 -0700
1 file changed, 1 insertion(+)
Trying simple merge.
[master OBJID] third
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:15:13 2005 -0700
1 file changed, 1 insertion(+)
Trying simple merge.
[master OBJID] fourth
Author: A U Thor <author@example.com>
+ Date: Thu Apr 7 15:16:13 2005 -0700
1 file changed, 1 insertion(+)
EOF
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index 3d30581..e00d7d2 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -711,8 +711,7 @@ test_expect_success 'checking out a commit after submodule removal needs manual
git submodule update &&
git checkout -q HEAD^ 2>actual &&
git checkout -q master 2>actual &&
- echo "warning: unable to rmdir submod: Directory not empty" >expected &&
- test_i18ncmp expected actual &&
+ test_i18ngrep "^warning: unable to rmdir submod:" actual &&
git status -s submod >actual &&
echo "?? submod/" >expected &&
test_cmp expected actual &&
diff --git a/t/t3905-stash-include-untracked.sh b/t/t3905-stash-include-untracked.sh
index a5e7e6b..f372fc8 100755
--- a/t/t3905-stash-include-untracked.sh
+++ b/t/t3905-stash-include-untracked.sh
@@ -96,8 +96,8 @@ test_expect_success 'stash pop after save --include-untracked leaves files untra
git stash pop &&
git status --porcelain >actual &&
test_cmp expect actual &&
- test "1" = "`cat file2`" &&
- test untracked = "`cat untracked/untracked`"
+ test "1" = "$(cat file2)" &&
+ test untracked = "$(cat untracked/untracked)"
'
git clean --force --quiet -d
diff --git a/t/t3910-mac-os-precompose.sh b/t/t3910-mac-os-precompose.sh
index e4ba601..8319356 100755
--- a/t/t3910-mac-os-precompose.sh
+++ b/t/t3910-mac-os-precompose.sh
@@ -14,13 +14,13 @@ then
fi
# create utf-8 variables
-Adiarnfc=`printf '\303\204'`
-Adiarnfd=`printf 'A\314\210'`
+Adiarnfc=$(printf '\303\204')
+Adiarnfd=$(printf 'A\314\210')
-Odiarnfc=`printf '\303\226'`
-Odiarnfd=`printf 'O\314\210'`
-AEligatu=`printf '\303\206'`
-Invalidu=`printf '\303\377'`
+Odiarnfc=$(printf '\303\226')
+Odiarnfd=$(printf 'O\314\210')
+AEligatu=$(printf '\303\206')
+Invalidu=$(printf '\303\377')
#Create a string with 255 bytes (decomposed)
@@ -35,7 +35,7 @@ Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #250 Byte
Alongc=$Alongc$AEligatu$AEligatu #254 Byte
test_expect_success "detect if nfd needed" '
- precomposeunicode=`git config core.precomposeunicode` &&
+ precomposeunicode=$(git config core.precomposeunicode) &&
test "$precomposeunicode" = true &&
git config core.precomposeunicode true
'
@@ -140,13 +140,23 @@ test_expect_success "Add long precomposed filename" '
git add * &&
git commit -m "Long filename"
'
+
+test_expect_failure 'handle existing decomposed filenames' '
+ echo content >"verbatim.$Adiarnfd" &&
+ git -c core.precomposeunicode=false add "verbatim.$Adiarnfd" &&
+ git commit -m "existing decomposed file" &&
+ >expect &&
+ git ls-files --exclude-standard -o "verbatim*" >untracked &&
+ test_cmp expect untracked
+'
+
# Test if the global core.precomposeunicode stops autosensing
# Must be the last test case
test_expect_success "respect git config --global core.precomposeunicode" '
git config --global core.precomposeunicode true &&
rm -rf .git &&
git init &&
- precomposeunicode=`git config core.precomposeunicode` &&
+ precomposeunicode=$(git config core.precomposeunicode) &&
test "$precomposeunicode" = "true"
'
diff --git a/t/t4006-diff-mode.sh b/t/t4006-diff-mode.sh
index 0591149..76f643b 100755
--- a/t/t4006-diff-mode.sh
+++ b/t/t4006-diff-mode.sh
@@ -13,7 +13,7 @@ sed_script='s/\(:100644 100755\) \('"$_x40"'\) \2 /\1 X X /'
test_expect_success 'setup' '
echo frotz >rezrov &&
git update-index --add rezrov &&
- tree=`git write-tree` &&
+ tree=$(git write-tree) &&
echo $tree
'
diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh
index 2bb9736..bf07841 100755
--- a/t/t4010-diff-pathspec.sh
+++ b/t/t4010-diff-pathspec.sh
@@ -18,7 +18,7 @@ test_expect_success \
mkdir path1 &&
echo rezrov >path1/file1 &&
git update-index --add file0 path1/file1 &&
- tree=`git write-tree` &&
+ tree=$(git write-tree) &&
echo "$tree" &&
echo nitfol >file0 &&
echo yomin >path1/file1 &&
@@ -131,7 +131,7 @@ test_expect_success 'diff multiple wildcard pathspecs' '
mkdir path2 &&
echo rezrov >path2/file1 &&
git update-index --add path2/file1 &&
- tree3=`git write-tree` &&
+ tree3=$(git write-tree) &&
git diff --name-only $tree $tree3 -- "path2*1" "path1*1" >actual &&
cat <<-\EOF >expect &&
path1/file1
diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh
index 1215ae5..643d729 100755
--- a/t/t4012-diff-binary.sh
+++ b/t/t4012-diff-binary.sh
@@ -67,18 +67,18 @@ test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' '
git diff >output &&
sed -e "s/-CIT/xCIT/" <output >broken &&
test_must_fail git apply --stat --summary broken 2>detected &&
- detected=`cat detected` &&
- detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
- detected=`sed -ne "${detected}p" broken` &&
+ detected=$(cat detected) &&
+ detected=$(expr "$detected" : "fatal.*at line \\([0-9]*\\)\$") &&
+ detected=$(sed -ne "${detected}p" broken) &&
test "$detected" = xCIT
'
test_expect_success C_LOCALE_OUTPUT 'apply detecting corrupt patch correctly' '
git diff --binary | sed -e "s/-CIT/xCIT/" >broken &&
test_must_fail git apply --stat --summary broken 2>detected &&
- detected=`cat detected` &&
- detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` &&
- detected=`sed -ne "${detected}p" broken` &&
+ detected=$(cat detected) &&
+ detected=$(expr "$detected" : "fatal.*at line \\([0-9]*\\)\$") &&
+ detected=$(sed -ne "${detected}p" broken) &&
test "$detected" = xCIT
'
@@ -88,7 +88,7 @@ test_expect_success 'initial commit' 'git commit -a -m initial'
test_expect_success 'diff-index with --binary' '
echo AIT >a && mv b e && echo CIT >c && cat e >d &&
git update-index --add --remove a b c d e &&
- tree0=`git write-tree` &&
+ tree0=$(git write-tree) &&
git diff --cached --binary >current &&
git apply --stat --summary current
'
@@ -96,7 +96,7 @@ test_expect_success 'diff-index with --binary' '
test_expect_success 'apply binary patch' '
git reset --hard &&
git apply --binary --index <current &&
- tree1=`git write-tree` &&
+ tree1=$(git write-tree) &&
test "$tree1" = "$tree0"
'
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index e77c09c..805b055 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -107,14 +107,14 @@ test_expect_success setup '
+*++ [initial] Initial
EOF
-V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
+V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
while read cmd
do
case "$cmd" in
'' | '#'*) continue ;;
esac
- test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
- pfx=`printf "%04d" $test_count`
+ test=$(echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g')
+ pfx=$(printf "%04d" $test_count)
expect="$TEST_DIRECTORY/t4013/diff.$test"
actual="$pfx-diff.$test"
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 73194b2..282bee4 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -43,7 +43,7 @@ test_expect_success setup '
test_expect_success "format-patch --ignore-if-in-upstream" '
git format-patch --stdout master..side >patch0 &&
- cnt=`grep "^From " patch0 | wc -l` &&
+ cnt=$(grep "^From " patch0 | wc -l) &&
test $cnt = 3
'
@@ -52,7 +52,7 @@ test_expect_success "format-patch --ignore-if-in-upstream" '
git format-patch --stdout \
--ignore-if-in-upstream master..side >patch1 &&
- cnt=`grep "^From " patch1 | wc -l` &&
+ cnt=$(grep "^From " patch1 | wc -l) &&
test $cnt = 2
'
@@ -69,7 +69,7 @@ test_expect_success "format-patch doesn't consider merge commits" '
git checkout -b merger master &&
test_tick &&
git merge --no-ff slave &&
- cnt=`git format-patch -3 --stdout | grep "^From " | wc -l` &&
+ cnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) &&
test $cnt = 3
'
@@ -77,7 +77,7 @@ test_expect_success "format-patch result applies" '
git checkout -b rebuild-0 master &&
git am -3 patch0 &&
- cnt=`git rev-list master.. | wc -l` &&
+ cnt=$(git rev-list master.. | wc -l) &&
test $cnt = 2
'
@@ -85,7 +85,7 @@ test_expect_success "format-patch --ignore-if-in-upstream result applies" '
git checkout -b rebuild-1 master &&
git am -3 patch1 &&
- cnt=`git rev-list master.. | wc -l` &&
+ cnt=$(git rev-list master.. | wc -l) &&
test $cnt = 2
'
@@ -764,22 +764,14 @@ test_expect_success 'format-patch --signature="" suppresses signatures' '
test_expect_success TTY 'format-patch --stdout paginates' '
rm -f pager_used &&
- (
- GIT_PAGER="wc >pager_used" &&
- export GIT_PAGER &&
- test_terminal git format-patch --stdout --all
- ) &&
+ test_terminal env GIT_PAGER="wc >pager_used" git format-patch --stdout --all &&
test_path_is_file pager_used
'
test_expect_success TTY 'format-patch --stdout pagination can be disabled' '
rm -f pager_used &&
- (
- GIT_PAGER="wc >pager_used" &&
- export GIT_PAGER &&
- test_terminal git --no-pager format-patch --stdout --all &&
- test_terminal git -c "pager.format-patch=false" format-patch --stdout --all
- ) &&
+ test_terminal env GIT_PAGER="wc >pager_used" git --no-pager format-patch --stdout --all &&
+ test_terminal env GIT_PAGER="wc >pager_used" git -c "pager.format-patch=false" format-patch --stdout --all &&
test_path_is_missing pager_used &&
test_path_is_missing .git/pager_used
'
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 38a092a..34591c2 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -7,179 +7,103 @@ test_description='Test custom diff function name patterns'
. ./test-lib.sh
-LF='
-'
-cat >Beer.java <<\EOF
-public class Beer
-{
- int special;
- public static void main(String args[])
- {
- String s=" ";
- for(int x = 99; x > 0; x--)
- {
- System.out.print(x + " bottles of beer on the wall "
- + x + " bottles of beer\n"
- + "Take one down, pass it around, " + (x - 1)
- + " bottles of beer on the wall.\n");
- }
- System.out.print("Go to the store, buy some more,\n"
- + "99 bottles of beer on the wall.\n");
- }
-}
-EOF
-sed 's/beer\\/beer,\\/' <Beer.java >Beer-correct.java
-cat >Beer.perl <<\EOT
-package Beer;
-
-use strict;
-use warnings;
-use parent qw(Exporter);
-our @EXPORT_OK = qw(round finalround);
-
-sub other; # forward declaration
-
-# hello
-
-sub round {
- my ($n) = @_;
- print "$n bottles of beer on the wall ";
- print "$n bottles of beer\n";
- print "Take one down, pass it around, ";
- $n = $n - 1;
- print "$n bottles of beer on the wall.\n";
-}
-
-sub finalround
-{
- print "Go to the store, buy some more\n";
- print "99 bottles of beer on the wall.\n");
-}
-
-sub withheredocument {
- print <<"EOF"
-decoy here-doc
-EOF
- # some lines of context
- # to pad it out
- print "hello\n";
-}
-
-__END__
-
-=head1 NAME
-
-Beer - subroutine to output fragment of a drinking song
-
-=head1 SYNOPSIS
-
- use Beer qw(round finalround);
-
- sub song {
- for (my $i = 99; $i > 0; $i--) {
- round $i;
- }
- finalround;
- }
+test_expect_success 'setup' '
+ # a non-trivial custom pattern
+ git config diff.custom1.funcname "!static
+!String
+[^ ].*s.*" &&
- song;
+ # a custom pattern which matches to end of line
+ git config diff.custom2.funcname "......Beer\$" &&
-=cut
-EOT
-sed -e '
- s/hello/goodbye/
- s/beer\\/beer,\\/
- s/more\\/more,\\/
- s/song;/song();/
-' <Beer.perl >Beer-correct.perl
+ # alternation in pattern
+ git config diff.custom3.funcname "Beer$" &&
+ git config diff.custom3.xfuncname "^[ ]*((public|static).*)$" &&
-test_expect_funcname () {
- lang=${2-java}
- test_expect_code 1 git diff --no-index -U1 \
- "Beer.$lang" "Beer-correct.$lang" >diff &&
- grep "^@@.*@@ $1" diff
-}
+ # for regexp compilation tests
+ echo A >A.java &&
+ echo B >B.java
+'
-for p in ada bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex
+diffpatterns="
+ ada
+ bibtex
+ cpp
+ csharp
+ fortran
+ html
+ java
+ matlab
+ objc
+ pascal
+ perl
+ php
+ python
+ ruby
+ tex
+ custom1
+ custom2
+ custom3
+"
+
+for p in $diffpatterns
do
test_expect_success "builtin $p pattern compiles" '
echo "*.java diff=$p" >.gitattributes &&
test_expect_code 1 git diff --no-index \
- Beer.java Beer-correct.java 2>msg &&
- ! grep fatal msg &&
- ! grep error msg
+ A.java B.java 2>msg &&
+ ! test_i18ngrep fatal msg &&
+ ! test_i18ngrep error msg
'
test_expect_success "builtin $p wordRegex pattern compiles" '
echo "*.java diff=$p" >.gitattributes &&
test_expect_code 1 git diff --no-index --word-diff \
- Beer.java Beer-correct.java 2>msg &&
- ! grep fatal msg &&
- ! grep error msg
+ A.java B.java 2>msg &&
+ ! test_i18ngrep fatal msg &&
+ ! test_i18ngrep error msg
'
done
-test_expect_success 'default behaviour' '
- rm -f .gitattributes &&
- test_expect_funcname "public class Beer\$"
-'
-
-test_expect_success 'set up .gitattributes declaring drivers to test' '
- cat >.gitattributes <<-\EOF
- *.java diff=java
- *.perl diff=perl
- EOF
-'
-
-test_expect_success 'preset java pattern' '
- test_expect_funcname "public static void main("
-'
-
-test_expect_success 'preset perl pattern' '
- test_expect_funcname "sub round {\$" perl
-'
-
-test_expect_success 'perl pattern accepts K&R style brace placement, too' '
- test_expect_funcname "sub finalround\$" perl
-'
-
-test_expect_success 'but is not distracted by end of <<here document' '
- test_expect_funcname "sub withheredocument {\$" perl
-'
-
-test_expect_success 'perl pattern is not distracted by sub within POD' '
- test_expect_funcname "=head" perl
-'
-
-test_expect_success 'perl pattern gets full line of POD header' '
- test_expect_funcname "=head1 SYNOPSIS\$" perl
-'
-
-test_expect_success 'perl pattern is not distracted by forward declaration' '
- test_expect_funcname "package Beer;\$" perl
-'
-
-test_expect_success 'custom pattern' '
- test_config diff.java.funcname "!static
-!String
-[^ ].*s.*" &&
- test_expect_funcname "int special;\$"
-'
-
test_expect_success 'last regexp must not be negated' '
+ echo "*.java diff=java" >.gitattributes &&
test_config diff.java.funcname "!static" &&
- test_expect_code 128 git diff --no-index Beer.java Beer-correct.java 2>msg &&
- grep ": Last expression must not be negated:" msg
+ test_expect_code 128 git diff --no-index A.java B.java 2>msg &&
+ test_i18ngrep ": Last expression must not be negated:" msg
'
-test_expect_success 'pattern which matches to end of line' '
- test_config diff.java.funcname "Beer\$" &&
- test_expect_funcname "Beer\$"
+test_expect_success 'setup hunk header tests' '
+ for i in $diffpatterns
+ do
+ echo "$i-* diff=$i"
+ done > .gitattributes &&
+
+ # add all test files to the index
+ (
+ cd "$TEST_DIRECTORY"/t4018 &&
+ git --git-dir="$TRASH_DIRECTORY/.git" add .
+ ) &&
+
+ # place modified files in the worktree
+ for i in $(git ls-files)
+ do
+ sed -e "s/ChangeMe/IWasChanged/" <"$TEST_DIRECTORY/t4018/$i" >"$i" || return 1
+ done
'
-test_expect_success 'alternation in pattern' '
- test_config diff.java.funcname "Beer$" &&
- test_config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
- test_expect_funcname "public static void main("
-'
+# check each individual file
+for i in $(git ls-files)
+do
+ if grep broken "$i" >/dev/null 2>&1
+ then
+ result=failure
+ else
+ result=success
+ fi
+ test_expect_$result "hunk header: $i" "
+ test_when_finished 'cat actual' && # for debugging only
+ git diff -U1 $i >actual &&
+ grep '@@ .* @@.*RIGHT' actual
+ "
+done
test_done
diff --git a/t/t4018/README b/t/t4018/README
new file mode 100644
index 0000000..283e01cc
--- /dev/null
+++ b/t/t4018/README
@@ -0,0 +1,18 @@
+How to write RIGHT test cases
+=============================
+
+Insert the word "ChangeMe" (exactly this form) at a distance of
+at least two lines from the line that must appear in the hunk header.
+
+The text that must appear in the hunk header must contain the word
+"right", but in all upper-case, like in the title above.
+
+To mark a test case that highlights a malfunction, insert the word
+BROKEN in all lower-case somewhere in the file.
+
+This text is a bit twisted and out of order, but it is itself a
+test case for the default hunk header pattern. Know what you are doing
+if you change it.
+
+BTW, this tests that the head line goes to the hunk header, not the line
+of equal signs.
diff --git a/t/t4018/cpp-c++-function b/t/t4018/cpp-c++-function
new file mode 100644
index 0000000..9ee6bbe
--- /dev/null
+++ b/t/t4018/cpp-c++-function
@@ -0,0 +1,4 @@
+Item RIGHT::DoSomething( Args with_spaces )
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-class-constructor b/t/t4018/cpp-class-constructor
new file mode 100644
index 0000000..ec4f115
--- /dev/null
+++ b/t/t4018/cpp-class-constructor
@@ -0,0 +1,4 @@
+Item::Item(int RIGHT)
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-class-constructor-mem-init b/t/t4018/cpp-class-constructor-mem-init
new file mode 100644
index 0000000..49a69f3
--- /dev/null
+++ b/t/t4018/cpp-class-constructor-mem-init
@@ -0,0 +1,5 @@
+Item::Item(int RIGHT) :
+ member(0)
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-class-definition b/t/t4018/cpp-class-definition
new file mode 100644
index 0000000..11b61da
--- /dev/null
+++ b/t/t4018/cpp-class-definition
@@ -0,0 +1,4 @@
+class RIGHT
+{
+ int ChangeMe;
+};
diff --git a/t/t4018/cpp-class-definition-derived b/t/t4018/cpp-class-definition-derived
new file mode 100644
index 0000000..3b98cd0
--- /dev/null
+++ b/t/t4018/cpp-class-definition-derived
@@ -0,0 +1,5 @@
+class RIGHT :
+ public Baseclass
+{
+ int ChangeMe;
+};
diff --git a/t/t4018/cpp-class-destructor b/t/t4018/cpp-class-destructor
new file mode 100644
index 0000000..5487665
--- /dev/null
+++ b/t/t4018/cpp-class-destructor
@@ -0,0 +1,4 @@
+RIGHT::~RIGHT()
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-function-returning-global-type b/t/t4018/cpp-function-returning-global-type
new file mode 100644
index 0000000..1084d59
--- /dev/null
+++ b/t/t4018/cpp-function-returning-global-type
@@ -0,0 +1,4 @@
+::Item get::it::RIGHT()
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-function-returning-nested b/t/t4018/cpp-function-returning-nested
new file mode 100644
index 0000000..d9750aa
--- /dev/null
+++ b/t/t4018/cpp-function-returning-nested
@@ -0,0 +1,5 @@
+get::Item get::it::RIGHT()
+{
+ ChangeMe;
+}
+
diff --git a/t/t4018/cpp-function-returning-pointer b/t/t4018/cpp-function-returning-pointer
new file mode 100644
index 0000000..ef15657
--- /dev/null
+++ b/t/t4018/cpp-function-returning-pointer
@@ -0,0 +1,4 @@
+const char *get_it_RIGHT(char *ptr)
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-function-returning-reference b/t/t4018/cpp-function-returning-reference
new file mode 100644
index 0000000..01b051d
--- /dev/null
+++ b/t/t4018/cpp-function-returning-reference
@@ -0,0 +1,4 @@
+string& get::it::RIGHT(char *ptr)
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-gnu-style-function b/t/t4018/cpp-gnu-style-function
new file mode 100644
index 0000000..08c7c75
--- /dev/null
+++ b/t/t4018/cpp-gnu-style-function
@@ -0,0 +1,5 @@
+const char *
+RIGHT(int arg)
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-namespace-definition b/t/t4018/cpp-namespace-definition
new file mode 100644
index 0000000..6749980
--- /dev/null
+++ b/t/t4018/cpp-namespace-definition
@@ -0,0 +1,4 @@
+namespace RIGHT
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-operator-definition b/t/t4018/cpp-operator-definition
new file mode 100644
index 0000000..1acd827
--- /dev/null
+++ b/t/t4018/cpp-operator-definition
@@ -0,0 +1,4 @@
+Value operator+(Value LEFT, Value RIGHT)
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-skip-access-specifiers b/t/t4018/cpp-skip-access-specifiers
new file mode 100644
index 0000000..4d4a9db
--- /dev/null
+++ b/t/t4018/cpp-skip-access-specifiers
@@ -0,0 +1,8 @@
+class RIGHT : public Baseclass
+{
+public:
+protected:
+private:
+ void DoSomething();
+ int ChangeMe;
+};
diff --git a/t/t4018/cpp-skip-comment-block b/t/t4018/cpp-skip-comment-block
new file mode 100644
index 0000000..3800b99
--- /dev/null
+++ b/t/t4018/cpp-skip-comment-block
@@ -0,0 +1,9 @@
+struct item RIGHT(int i)
+// Do not
+// pick up
+/* these
+** comments.
+*/
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-skip-labels b/t/t4018/cpp-skip-labels
new file mode 100644
index 0000000..b9c10ab
--- /dev/null
+++ b/t/t4018/cpp-skip-labels
@@ -0,0 +1,8 @@
+void RIGHT (void)
+{
+repeat: // C++ comment
+next: /* C comment */
+ do_something();
+
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-struct-definition b/t/t4018/cpp-struct-definition
new file mode 100644
index 0000000..521c59f
--- /dev/null
+++ b/t/t4018/cpp-struct-definition
@@ -0,0 +1,9 @@
+struct RIGHT {
+ unsigned
+ /* this bit field looks like a label and should not be picked up */
+ decoy_bitfield: 2,
+ more : 1;
+ int filler;
+
+ int ChangeMe;
+};
diff --git a/t/t4018/cpp-struct-single-line b/t/t4018/cpp-struct-single-line
new file mode 100644
index 0000000..a0de5fb
--- /dev/null
+++ b/t/t4018/cpp-struct-single-line
@@ -0,0 +1,7 @@
+void wrong()
+{
+}
+
+struct RIGHT_iterator_tag {};
+
+int ChangeMe;
diff --git a/t/t4018/cpp-template-function-definition b/t/t4018/cpp-template-function-definition
new file mode 100644
index 0000000..0cdf5ba
--- /dev/null
+++ b/t/t4018/cpp-template-function-definition
@@ -0,0 +1,4 @@
+template<class T> int RIGHT(T arg)
+{
+ ChangeMe;
+}
diff --git a/t/t4018/cpp-union-definition b/t/t4018/cpp-union-definition
new file mode 100644
index 0000000..7ec94df
--- /dev/null
+++ b/t/t4018/cpp-union-definition
@@ -0,0 +1,4 @@
+union RIGHT {
+ double v;
+ int ChangeMe;
+};
diff --git a/t/t4018/cpp-void-c-function b/t/t4018/cpp-void-c-function
new file mode 100644
index 0000000..153081e
--- /dev/null
+++ b/t/t4018/cpp-void-c-function
@@ -0,0 +1,4 @@
+void RIGHT (void)
+{
+ ChangeMe;
+}
diff --git a/t/t4018/custom1-pattern b/t/t4018/custom1-pattern
new file mode 100644
index 0000000..e8fd59f
--- /dev/null
+++ b/t/t4018/custom1-pattern
@@ -0,0 +1,17 @@
+public class Beer
+{
+ int special, RIGHT;
+ public static void main(String args[])
+ {
+ String s=" ";
+ for(int x = 99; x > 0; x--)
+ {
+ System.out.print(x + " bottles of beer on the wall "
+ + x + " bottles of beer\n" // ChangeMe
+ + "Take one down, pass it around, " + (x - 1)
+ + " bottles of beer on the wall.\n");
+ }
+ System.out.print("Go to the store, buy some more,\n"
+ + "99 bottles of beer on the wall.\n");
+ }
+}
diff --git a/t/t4018/custom2-match-to-end-of-line b/t/t4018/custom2-match-to-end-of-line
new file mode 100644
index 0000000..f88ac31
--- /dev/null
+++ b/t/t4018/custom2-match-to-end-of-line
@@ -0,0 +1,8 @@
+public class RIGHT_Beer
+{
+ int special;
+ public static void main(String args[])
+ {
+ System.out.print("ChangeMe");
+ }
+}
diff --git a/t/t4018/custom3-alternation-in-pattern b/t/t4018/custom3-alternation-in-pattern
new file mode 100644
index 0000000..5f3769c
--- /dev/null
+++ b/t/t4018/custom3-alternation-in-pattern
@@ -0,0 +1,17 @@
+public class Beer
+{
+ int special;
+ public static void main(String RIGHT[])
+ {
+ String s=" ";
+ for(int x = 99; x > 0; x--)
+ {
+ System.out.print(x + " bottles of beer on the wall "
+ + x + " bottles of beer\n" // ChangeMe
+ + "Take one down, pass it around, " + (x - 1)
+ + " bottles of beer on the wall.\n");
+ }
+ System.out.print("Go to the store, buy some more,\n"
+ + "99 bottles of beer on the wall.\n");
+ }
+}
diff --git a/t/t4018/java-class-member-function b/t/t4018/java-class-member-function
new file mode 100644
index 0000000..298bc7a
--- /dev/null
+++ b/t/t4018/java-class-member-function
@@ -0,0 +1,8 @@
+public class Beer
+{
+ int special;
+ public static void main(String RIGHT[])
+ {
+ System.out.print("ChangeMe");
+ }
+}
diff --git a/t/t4018/perl-skip-end-of-heredoc b/t/t4018/perl-skip-end-of-heredoc
new file mode 100644
index 0000000..c22d39b
--- /dev/null
+++ b/t/t4018/perl-skip-end-of-heredoc
@@ -0,0 +1,8 @@
+sub RIGHTwithheredocument {
+ print <<"EOF"
+decoy here-doc
+EOF
+ # some lines of context
+ # to pad it out
+ print "ChangeMe\n";
+}
diff --git a/t/t4018/perl-skip-forward-decl b/t/t4018/perl-skip-forward-decl
new file mode 100644
index 0000000..a98cb8b
--- /dev/null
+++ b/t/t4018/perl-skip-forward-decl
@@ -0,0 +1,10 @@
+package RIGHT;
+
+use strict;
+use warnings;
+use parent qw(Exporter);
+our @EXPORT_OK = qw(round finalround);
+
+sub other; # forward declaration
+
+# ChangeMe
diff --git a/t/t4018/perl-skip-sub-in-pod b/t/t4018/perl-skip-sub-in-pod
new file mode 100644
index 0000000..e39f024
--- /dev/null
+++ b/t/t4018/perl-skip-sub-in-pod
@@ -0,0 +1,18 @@
+=head1 NAME
+
+Beer - subroutine to output fragment of a drinking song
+
+=head1 SYNOPSIS_RIGHT
+
+ use Beer qw(round finalround);
+
+ sub song {
+ for (my $i = 99; $i > 0; $i--) {
+ round $i;
+ }
+ finalround;
+ }
+
+ ChangeMe;
+
+=cut
diff --git a/t/t4018/perl-sub-definition b/t/t4018/perl-sub-definition
new file mode 100644
index 0000000..a507d1f
--- /dev/null
+++ b/t/t4018/perl-sub-definition
@@ -0,0 +1,4 @@
+sub RIGHT {
+ my ($n) = @_;
+ print "ChangeMe";
+}
diff --git a/t/t4018/perl-sub-definition-kr-brace b/t/t4018/perl-sub-definition-kr-brace
new file mode 100644
index 0000000..330b3df
--- /dev/null
+++ b/t/t4018/perl-sub-definition-kr-brace
@@ -0,0 +1,4 @@
+sub RIGHT
+{
+ print "ChangeMe\n";
+}
diff --git a/t/t4036-format-patch-signer-mime.sh b/t/t4036-format-patch-signer-mime.sh
index ba43f18..98d9713 100755
--- a/t/t4036-format-patch-signer-mime.sh
+++ b/t/t4036-format-patch-signer-mime.sh
@@ -42,7 +42,7 @@ test_expect_success 'attach and signoff do not duplicate mime headers' '
GIT_COMMITTER_NAME="はまの ふにおう" \
git format-patch -s --stdout -1 --attach >output &&
- test `grep -ci ^MIME-Version: output` = 1
+ test $(grep -ci ^MIME-Version: output) = 1
'
diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh
index 1019d7b..41913c3 100755
--- a/t/t4038-diff-combined.sh
+++ b/t/t4038-diff-combined.sh
@@ -94,7 +94,7 @@ 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`
+ 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"
diff --git a/t/t4056-diff-order.sh b/t/t4056-diff-order.sh
index 9e2b29e..c0460bb 100755
--- a/t/t4056-diff-order.sh
+++ b/t/t4056-diff-order.sh
@@ -97,4 +97,25 @@ do
'
done
+test_expect_success 'setup for testing combine-diff order' '
+ git checkout -b tmp HEAD~ &&
+ create_files 3 &&
+ git checkout master &&
+ git merge --no-commit -s ours tmp &&
+ create_files 5
+'
+
+test_expect_success "combine-diff: no order (=tree object order)" '
+ git diff --name-only HEAD HEAD^ HEAD^2 >actual &&
+ test_cmp expect_none actual
+'
+
+for i in 1 2
+do
+ test_expect_success "combine-diff: orderfile using option ($i)" '
+ git diff -Oorder_file_$i --name-only HEAD HEAD^ HEAD^2 >actual &&
+ test_cmp expect_$i actual
+ '
+done
+
test_done
diff --git a/t/t4057-diff-combined-paths.sh b/t/t4057-diff-combined-paths.sh
new file mode 100755
index 0000000..dff36b7
--- /dev/null
+++ b/t/t4057-diff-combined-paths.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+
+test_description='combined diff show only paths that are different to all parents'
+
+. ./test-lib.sh
+
+# verify that diffc.expect matches output of
+# $(git diff -c --name-only HEAD HEAD^ HEAD^2)
+diffc_verify () {
+ git diff -c --name-only HEAD HEAD^ HEAD^2 >diffc.actual &&
+ test_cmp diffc.expect diffc.actual
+}
+
+test_expect_success 'trivial merge - combine-diff empty' '
+ for i in $(test_seq 1 9)
+ do
+ echo $i >$i.txt &&
+ git add $i.txt
+ done &&
+ git commit -m "init" &&
+ git checkout -b side &&
+ for i in $(test_seq 2 9)
+ do
+ echo $i/2 >>$i.txt
+ done &&
+ git commit -a -m "side 2-9" &&
+ git checkout master &&
+ echo 1/2 >1.txt &&
+ git commit -a -m "master 1" &&
+ git merge side &&
+ >diffc.expect &&
+ diffc_verify
+'
+
+
+test_expect_success 'only one trully conflicting path' '
+ git checkout side &&
+ for i in $(test_seq 2 9)
+ do
+ echo $i/3 >>$i.txt
+ done &&
+ echo "4side" >>4.txt &&
+ git commit -a -m "side 2-9 +4" &&
+ git checkout master &&
+ for i in $(test_seq 1 9)
+ do
+ echo $i/3 >>$i.txt
+ done &&
+ echo "4master" >>4.txt &&
+ git commit -a -m "master 1-9 +4" &&
+ test_must_fail git merge side &&
+ cat <<-\EOF >4.txt &&
+ 4
+ 4/2
+ 4/3
+ 4master
+ 4side
+ EOF
+ git add 4.txt &&
+ git commit -m "merge side (2)" &&
+ echo 4.txt >diffc.expect &&
+ diffc_verify
+'
+
+test_expect_success 'merge introduces new file' '
+ git checkout side &&
+ for i in $(test_seq 5 9)
+ do
+ echo $i/4 >>$i.txt
+ done &&
+ git commit -a -m "side 5-9" &&
+ git checkout master &&
+ for i in $(test_seq 1 3)
+ do
+ echo $i/4 >>$i.txt
+ done &&
+ git commit -a -m "master 1-3 +4hello" &&
+ git merge side &&
+ echo "Hello World" >4hello.txt &&
+ git add 4hello.txt &&
+ git commit --amend &&
+ echo 4hello.txt >diffc.expect &&
+ diffc_verify
+'
+
+test_expect_success 'merge removed a file' '
+ git checkout side &&
+ for i in $(test_seq 5 9)
+ do
+ echo $i/5 >>$i.txt
+ done &&
+ git commit -a -m "side 5-9" &&
+ git checkout master &&
+ for i in $(test_seq 1 3)
+ do
+ echo $i/4 >>$i.txt
+ done &&
+ git commit -a -m "master 1-3" &&
+ git merge side &&
+ git rm 4.txt &&
+ git commit --amend &&
+ echo 4.txt >diffc.expect &&
+ diffc_verify
+'
+
+test_done
diff --git a/t/t4107-apply-ignore-whitespace.sh b/t/t4107-apply-ignore-whitespace.sh
index b04fc8f..9e29b52 100755
--- a/t/t4107-apply-ignore-whitespace.sh
+++ b/t/t4107-apply-ignore-whitespace.sh
@@ -111,7 +111,6 @@ sed -e 's/T/ /g' > main.c.final <<\EOF
#include <stdio.h>
void print_int(int num);
-T/* a comment */
int func(int num);
int main() {
@@ -154,7 +153,8 @@ test_expect_success 'patch2 reverse applies with --ignore-space-change' '
git config apply.ignorewhitespace change
test_expect_success 'patch2 applies (apply.ignorewhitespace = change)' '
- git apply patch2.patch
+ git apply patch2.patch &&
+ test_cmp main.c.final main.c
'
test_expect_success 'patch3 fails (missing string at EOL)' '
@@ -165,12 +165,8 @@ test_expect_success 'patch4 fails (missing EOL at EOF)' '
test_must_fail git apply patch4.patch
'
-test_expect_success 'patch5 applies (leading whitespace)' '
- git apply patch5.patch
-'
-
-test_expect_success 'patches do not mangle whitespace' '
- test_cmp main.c main.c.final
+test_expect_success 'patch5 fails (leading whitespace differences matter)' '
+ test_must_fail git apply patch5.patch
'
test_expect_success 're-create file (with --ignore-whitespace)' '
diff --git a/t/t4116-apply-reverse.sh b/t/t4116-apply-reverse.sh
index 1e4d438..ce8567f 100755
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
@@ -30,10 +30,10 @@ test_expect_success setup '
test_expect_success 'apply in forward' '
- T0=`git rev-parse "second^{tree}"` &&
+ T0=$(git rev-parse "second^{tree}") &&
git reset --hard initial &&
git apply --index --binary patch &&
- T1=`git write-tree` &&
+ T1=$(git write-tree) &&
test "$T0" = "$T1"
'
@@ -62,22 +62,22 @@ test_expect_success 'setup separate repository lacking postimage' '
test_expect_success 'apply in forward without postimage' '
- T0=`git rev-parse "second^{tree}"` &&
+ T0=$(git rev-parse "second^{tree}") &&
(
cd initial &&
git apply --index --binary ../patch &&
- T1=`git write-tree` &&
+ T1=$(git write-tree) &&
test "$T0" = "$T1"
)
'
test_expect_success 'apply in reverse without postimage' '
- T0=`git rev-parse "initial^{tree}"` &&
+ T0=$(git rev-parse "initial^{tree}") &&
(
cd second &&
git apply --index --binary --reverse ../patch &&
- T1=`git write-tree` &&
+ T1=$(git write-tree) &&
test "$T0" = "$T1"
)
'
diff --git a/t/t4119-apply-config.sh b/t/t4119-apply-config.sh
index 3d0384d..c393be6 100755
--- a/t/t4119-apply-config.sh
+++ b/t/t4119-apply-config.sh
@@ -68,7 +68,7 @@ test_expect_success 'apply --whitespace=strip from config' '
check_result sub/file1
'
-D=`pwd`
+D=$(pwd)
test_expect_success 'apply --whitespace=strip in subdir' '
diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
index d2c930d..7940f6f 100755
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
@@ -45,8 +45,8 @@ test_expect_success 'patch-id supports git-format-patch output' '
git checkout same &&
git format-patch -1 --stdout | calc_patch_id same &&
test_cmp patch-id_master patch-id_same &&
- set `git format-patch -1 --stdout | git patch-id` &&
- test "$2" = `git rev-parse HEAD`
+ set $(git format-patch -1 --stdout | git patch-id) &&
+ test "$2" = $(git rev-parse HEAD)
'
test_expect_success 'whitespace is irrelevant in footer' '
diff --git a/t/t4209-log-pickaxe.sh b/t/t4209-log-pickaxe.sh
index 38fb80f..844df76 100755
--- a/t/t4209-log-pickaxe.sh
+++ b/t/t4209-log-pickaxe.sh
@@ -3,82 +3,72 @@
test_description='log --grep/--author/--regexp-ignore-case/-S/-G'
. ./test-lib.sh
+test_log () {
+ expect=$1
+ kind=$2
+ needle=$3
+ shift 3
+ rest=$@
+
+ case $kind in
+ --*)
+ opt=$kind=$needle
+ ;;
+ *)
+ opt=$kind$needle
+ ;;
+ esac
+ case $expect in
+ expect_nomatch)
+ match=nomatch
+ ;;
+ *)
+ match=match
+ ;;
+ esac
+
+ test_expect_success "log $kind${rest:+ $rest} ($match)" "
+ git log $rest $opt --format=%H >actual &&
+ test_cmp $expect actual
+ "
+}
+
+# test -i and --regexp-ignore-case and expect both to behave the same way
+test_log_icase () {
+ test_log $@ --regexp-ignore-case
+ test_log $@ -i
+}
+
test_expect_success setup '
+ >expect_nomatch &&
+
>file &&
git add file &&
test_tick &&
git commit -m initial &&
+ git rev-parse --verify HEAD >expect_initial &&
echo Picked >file &&
+ git add file &&
test_tick &&
- git commit -a --author="Another Person <another@example.com>" -m second
-'
-
-test_expect_success 'log --grep' '
- git log --grep=initial --format=%H >actual &&
- git rev-parse --verify HEAD^ >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log --grep --regexp-ignore-case' '
- git log --regexp-ignore-case --grep=InItial --format=%H >actual &&
- git rev-parse --verify HEAD^ >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log --grep -i' '
- git log -i --grep=InItial --format=%H >actual &&
- git rev-parse --verify HEAD^ >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log --author --regexp-ignore-case' '
- git log --regexp-ignore-case --author=person --format=%H >actual &&
- git rev-parse --verify HEAD >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log --author -i' '
- git log -i --author=person --format=%H >actual &&
- git rev-parse --verify HEAD >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log -G (nomatch)' '
- git log -Gpicked --format=%H >actual &&
- >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log -G (match)' '
- git log -GPicked --format=%H >actual &&
- git rev-parse --verify HEAD >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log -G --regexp-ignore-case (nomatch)' '
- git log --regexp-ignore-case -Gpickle --format=%H >actual &&
- >expect &&
- test_cmp expect actual
+ git commit --author="Another Person <another@example.com>" -m second &&
+ git rev-parse --verify HEAD >expect_second
'
-test_expect_success 'log -G -i (nomatch)' '
- git log -i -Gpickle --format=%H >actual &&
- >expect &&
- test_cmp expect actual
-'
+test_log expect_initial --grep initial
+test_log expect_nomatch --grep InItial
+test_log_icase expect_initial --grep InItial
+test_log_icase expect_nomatch --grep initail
-test_expect_success 'log -G --regexp-ignore-case (match)' '
- git log --regexp-ignore-case -Gpicked --format=%H >actual &&
- git rev-parse --verify HEAD >expect &&
- test_cmp expect actual
-'
+test_log expect_second --author Person
+test_log expect_nomatch --author person
+test_log_icase expect_second --author person
+test_log_icase expect_nomatch --author spreon
-test_expect_success 'log -G -i (match)' '
- git log -i -Gpicked --format=%H >actual &&
- git rev-parse --verify HEAD >expect &&
- test_cmp expect actual
-'
+test_log expect_nomatch -G picked
+test_log expect_second -G Picked
+test_log_icase expect_nomatch -G pickle
+test_log_icase expect_second -G picked
test_expect_success 'log -G --textconv (missing textconv tool)' '
echo "* diff=test" >.gitattributes &&
@@ -89,46 +79,19 @@ test_expect_success 'log -G --textconv (missing textconv tool)' '
test_expect_success 'log -G --no-textconv (missing textconv tool)' '
echo "* diff=test" >.gitattributes &&
git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
- >expect &&
- test_cmp expect actual &&
+ test_cmp expect_nomatch actual &&
rm .gitattributes
'
-test_expect_success 'log -S (nomatch)' '
- git log -Spicked --format=%H >actual &&
- >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log -S (match)' '
- git log -SPicked --format=%H >actual &&
- git rev-parse --verify HEAD >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log -S --regexp-ignore-case (match)' '
- git log --regexp-ignore-case -Spicked --format=%H >actual &&
- git rev-parse --verify HEAD >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log -S -i (match)' '
- git log -i -Spicked --format=%H >actual &&
- git rev-parse --verify HEAD >expect &&
- test_cmp expect actual
-'
-
-test_expect_success 'log -S --regexp-ignore-case (nomatch)' '
- git log --regexp-ignore-case -Spickle --format=%H >actual &&
- >expect &&
- test_cmp expect actual
-'
+test_log expect_nomatch -S picked
+test_log expect_second -S Picked
+test_log_icase expect_second -S picked
+test_log_icase expect_nomatch -S pickle
-test_expect_success 'log -S -i (nomatch)' '
- git log -i -Spickle --format=%H >actual &&
- >expect &&
- test_cmp expect actual
-'
+test_log expect_nomatch -S p.cked --pickaxe-regex
+test_log expect_second -S P.cked --pickaxe-regex
+test_log_icase expect_second -S p.cked --pickaxe-regex
+test_log_icase expect_nomatch -S p.ckle --pickaxe-regex
test_expect_success 'log -S --textconv (missing textconv tool)' '
echo "* diff=test" >.gitattributes &&
@@ -139,8 +102,7 @@ test_expect_success 'log -S --textconv (missing textconv tool)' '
test_expect_success 'log -S --no-textconv (missing textconv tool)' '
echo "* diff=test" >.gitattributes &&
git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
- >expect &&
- test_cmp expect actual &&
+ test_cmp expect_nomatch actual &&
rm .gitattributes
'
diff --git a/t/t5000-tar-tree.sh b/t/t5000-tar-tree.sh
index 05f011d..74fc5a8 100755
--- a/t/t5000-tar-tree.sh
+++ b/t/t5000-tar-tree.sh
@@ -123,7 +123,7 @@ test_expect_success \
'add files to repository' \
'find a -type f | xargs git update-index --add &&
find a -type l | xargs git update-index --add &&
- treeid=`git write-tree` &&
+ treeid=$(git write-tree) &&
echo $treeid >treeid &&
git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
git commit-tree $treeid </dev/null)'
@@ -207,12 +207,21 @@ test_expect_success \
test_expect_success 'clients cannot access unreachable commits' '
test_commit unreachable &&
- sha1=`git rev-parse HEAD` &&
+ sha1=$(git rev-parse HEAD) &&
git reset --hard HEAD^ &&
git archive $sha1 >remote.tar &&
test_must_fail git archive --remote=. $sha1 >remote.tar
'
+test_expect_success 'upload-archive can allow unreachable commits' '
+ test_commit unreachable1 &&
+ sha1=$(git rev-parse HEAD) &&
+ git reset --hard HEAD^ &&
+ git archive $sha1 >remote.tar &&
+ test_config uploadarchive.allowUnreachable true &&
+ git archive --remote=. $sha1 >remote.tar
+'
+
test_expect_success 'setup tar filters' '
git config tar.tar.foo.command "tr ab ba" &&
git config tar.bar.command "tr ab ba" &&
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
index 1afa0d5..93e2c65 100755
--- a/t/t5150-request-pull.sh
+++ b/t/t5150-request-pull.sh
@@ -86,7 +86,7 @@ test_expect_success 'setup: two scripts for reading pull requests' '
s/[-0-9]\{10\} [:0-9]\{8\} [-+][0-9]\{4\}/DATE/g
s/ [^ ].*/ SUBJECT/g
s/ [^ ].* (DATE)/ SUBJECT (DATE)/g
- s/for-upstream/BRANCH/g
+ s|tags/full|BRANCH|g
s/mnemonic.txt/FILENAME/g
s/^version [0-9]/VERSION/
/^ FILENAME | *[0-9]* [-+]*\$/ b diffstat
@@ -127,7 +127,7 @@ test_expect_success 'pull request when forgot to push' '
test_must_fail git request-pull initial "$downstream_url" \
2>../err
) &&
- grep "No branch of.*is at:\$" err &&
+ grep "No match for commit .*" err &&
grep "Are you sure you pushed" err
'
@@ -141,7 +141,7 @@ test_expect_success 'pull request after push' '
git checkout initial &&
git merge --ff-only master &&
git push origin master:for-upstream &&
- git request-pull initial origin >../request
+ git request-pull initial origin master:for-upstream >../request
) &&
sed -nf read-request.sed <request >digest &&
cat digest &&
@@ -160,7 +160,7 @@ test_expect_success 'pull request after push' '
'
-test_expect_success 'request names an appropriate branch' '
+test_expect_success 'request asks HEAD to be pulled' '
rm -fr downstream.git &&
git init --bare downstream.git &&
@@ -179,7 +179,7 @@ test_expect_success 'request names an appropriate branch' '
read repository &&
read branch
} <digest &&
- test "$branch" = tags/full
+ test -z "$branch"
'
@@ -212,12 +212,24 @@ test_expect_success 'pull request format' '
cd local &&
git checkout initial &&
git merge --ff-only master &&
- git push origin master:for-upstream &&
- git request-pull initial "$downstream_url" >../request
+ git push origin tags/full &&
+ git request-pull initial "$downstream_url" tags/full >../request
) &&
<request sed -nf fuzz.sed >request.fuzzy &&
- test_i18ncmp expect request.fuzzy
+ test_i18ncmp expect request.fuzzy &&
+ (
+ cd local &&
+ git request-pull initial "$downstream_url" tags/full:refs/tags/full
+ ) >request &&
+ sed -nf fuzz.sed <request >request.fuzzy &&
+ test_i18ncmp expect request.fuzzy &&
+
+ (
+ cd local &&
+ git request-pull initial "$downstream_url" full
+ ) >request &&
+ grep ' tags/full$'
'
test_expect_success 'request-pull ignores OPTIONS_KEEPDASHDASH poison' '
@@ -229,7 +241,7 @@ test_expect_success 'request-pull ignores OPTIONS_KEEPDASHDASH poison' '
git checkout initial &&
git merge --ff-only master &&
git push origin master:for-upstream &&
- git request-pull -- initial "$downstream_url" >../request
+ git request-pull -- initial "$downstream_url" master:for-upstream >../request
)
'
diff --git a/t/t5305-include-tag.sh b/t/t5305-include-tag.sh
index b061864..21517c7 100755
--- a/t/t5305-include-tag.sh
+++ b/t/t5305-include-tag.sh
@@ -45,9 +45,7 @@ test_expect_success 'unpack objects' '
test_expect_success 'check unpacked result (have commit, no tag)' '
git rev-list --objects $commit >list.expect &&
(
- GIT_DIR=clone.git &&
- export GIT_DIR &&
- test_must_fail git cat-file -e $tag &&
+ test_must_fail env GIT_DIR=clone.git git cat-file -e $tag &&
git rev-list --objects $commit
) >list.actual &&
test_cmp list.expect list.actual
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
new file mode 100755
index 0000000..f4f02ba
--- /dev/null
+++ b/t/t5310-pack-bitmaps.sh
@@ -0,0 +1,173 @@
+#!/bin/sh
+
+test_description='exercise basic bitmap functionality'
+. ./test-lib.sh
+
+objpath () {
+ echo ".git/objects/$(echo "$1" | sed -e 's|\(..\)|\1/|')"
+}
+
+test_expect_success 'setup repo with moderate-sized history' '
+ for i in $(test_seq 1 10); do
+ test_commit $i
+ done &&
+ git checkout -b other HEAD~5 &&
+ for i in $(test_seq 1 10); do
+ test_commit side-$i
+ done &&
+ git checkout master &&
+ blob=$(echo tagged-blob | git hash-object -w --stdin) &&
+ git tag tagged-blob $blob &&
+ git config pack.writebitmaps true &&
+ git config pack.writebitmaphashcache true
+'
+
+test_expect_success 'full repack creates bitmaps' '
+ git repack -ad &&
+ ls .git/objects/pack/ | grep bitmap >output &&
+ test_line_count = 1 output
+'
+
+test_expect_success 'rev-list --test-bitmap verifies bitmaps' '
+ git rev-list --test-bitmap HEAD
+'
+
+rev_list_tests() {
+ state=$1
+
+ test_expect_success "counting commits via bitmap ($state)" '
+ git rev-list --count HEAD >expect &&
+ git rev-list --use-bitmap-index --count HEAD >actual &&
+ test_cmp expect actual
+ '
+
+ test_expect_success "counting partial commits via bitmap ($state)" '
+ git rev-list --count HEAD~5..HEAD >expect &&
+ git rev-list --use-bitmap-index --count HEAD~5..HEAD >actual &&
+ test_cmp expect actual
+ '
+
+ test_expect_success "counting non-linear history ($state)" '
+ git rev-list --count other...master >expect &&
+ git rev-list --use-bitmap-index --count other...master >actual &&
+ test_cmp expect actual
+ '
+
+ test_expect_success "enumerate --objects ($state)" '
+ git rev-list --objects --use-bitmap-index HEAD >tmp &&
+ cut -d" " -f1 <tmp >tmp2 &&
+ sort <tmp2 >actual &&
+ git rev-list --objects HEAD >tmp &&
+ cut -d" " -f1 <tmp >tmp2 &&
+ sort <tmp2 >expect &&
+ test_cmp expect actual
+ '
+
+ test_expect_success "bitmap --objects handles non-commit objects ($state)" '
+ git rev-list --objects --use-bitmap-index HEAD tagged-blob >actual &&
+ grep $blob actual
+ '
+}
+
+rev_list_tests 'full bitmap'
+
+test_expect_success 'clone from bitmapped repository' '
+ git clone --no-local --bare . clone.git &&
+ git rev-parse HEAD >expect &&
+ git --git-dir=clone.git rev-parse HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'setup further non-bitmapped commits' '
+ for i in $(test_seq 1 10); do
+ test_commit further-$i
+ done
+'
+
+rev_list_tests 'partial bitmap'
+
+test_expect_success 'fetch (partial bitmap)' '
+ git --git-dir=clone.git fetch origin master:master &&
+ git rev-parse HEAD >expect &&
+ git --git-dir=clone.git rev-parse HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'incremental repack cannot create bitmaps' '
+ test_commit more-1 &&
+ find .git/objects/pack -name "*.bitmap" >expect &&
+ git repack -d &&
+ find .git/objects/pack -name "*.bitmap" >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'incremental repack can disable bitmaps' '
+ test_commit more-2 &&
+ git repack -d --no-write-bitmap-index
+'
+
+test_expect_success 'full repack, reusing previous bitmaps' '
+ git repack -ad &&
+ ls .git/objects/pack/ | grep bitmap >output &&
+ test_line_count = 1 output
+'
+
+test_expect_success 'fetch (full bitmap)' '
+ git --git-dir=clone.git fetch origin master:master &&
+ git rev-parse HEAD >expect &&
+ git --git-dir=clone.git rev-parse HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'create objects for missing-HAVE tests' '
+ blob=$(echo "missing have" | git hash-object -w --stdin) &&
+ tree=$(printf "100644 blob $blob\tfile\n" | git mktree) &&
+ parent=$(echo parent | git commit-tree $tree) &&
+ commit=$(echo commit | git commit-tree $tree -p $parent) &&
+ cat >revs <<-EOF
+ HEAD
+ ^HEAD^
+ ^$commit
+ EOF
+'
+
+test_expect_success 'pack with missing blob' '
+ rm $(objpath $blob) &&
+ git pack-objects --stdout --revs <revs >/dev/null
+'
+
+test_expect_success 'pack with missing tree' '
+ rm $(objpath $tree) &&
+ git pack-objects --stdout --revs <revs >/dev/null
+'
+
+test_expect_success 'pack with missing parent' '
+ rm $(objpath $parent) &&
+ git pack-objects --stdout --revs <revs >/dev/null
+'
+
+test_lazy_prereq JGIT '
+ type jgit
+'
+
+test_expect_success JGIT 'we can read jgit bitmaps' '
+ git clone . compat-jgit &&
+ (
+ cd compat-jgit &&
+ rm -f .git/objects/pack/*.bitmap &&
+ jgit gc &&
+ git rev-list --test-bitmap HEAD
+ )
+'
+
+test_expect_success JGIT 'jgit can read our bitmaps' '
+ git clone . compat-us &&
+ (
+ cd compat-us &&
+ git repack -adb &&
+ # jgit gc will barf if it does not like our bitmaps
+ jgit gc
+ )
+'
+
+test_done
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 129fc88..0736bcb 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -164,6 +164,7 @@ test_expect_success 'receive-pack runs auto-gc in remote repo' '
# Set the child to auto-pack if more than one pack exists
cd child &&
git config gc.autopacklimit 1 &&
+ git config gc.autodetach false &&
git branch test_auto_gc &&
# And create a file that follows the temporary object naming
# convention for the auto-gc to remove
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index b212f83..29d59ef 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -321,7 +321,7 @@ test_expect_success 'fetch via rsync' '
mkdir rsynced &&
(cd rsynced &&
git init --bare &&
- git fetch "rsync:$(pwd)/../.git" master:refs/heads/master &&
+ git fetch "rsync:../.git" master:refs/heads/master &&
git gc --prune &&
test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
git fsck --full)
@@ -332,7 +332,7 @@ test_expect_success 'push via rsync' '
(cd rsynced2 &&
git init) &&
(cd rsynced &&
- git push "rsync:$(pwd)/../rsynced2/.git" master) &&
+ git push "rsync:../rsynced2/.git" master) &&
(cd rsynced2 &&
git gc --prune &&
test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
@@ -343,7 +343,7 @@ test_expect_success 'push via rsync' '
mkdir rsynced3 &&
(cd rsynced3 &&
git init) &&
- git push --all "rsync:$(pwd)/rsynced3/.git" &&
+ git push --all "rsync:rsynced3/.git" &&
(cd rsynced3 &&
test $(git rev-parse master) = $(cd .. && git rev-parse master) &&
git fsck --full)
diff --git a/t/t5529-push-errors.sh b/t/t5529-push-errors.sh
new file mode 100755
index 0000000..9871307
--- /dev/null
+++ b/t/t5529-push-errors.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+test_description='detect some push errors early (before contacting remote)'
+. ./test-lib.sh
+
+test_expect_success 'setup commits' '
+ test_commit one
+'
+
+test_expect_success 'setup remote' '
+ git init --bare remote.git &&
+ git remote add origin remote.git
+'
+
+test_expect_success 'setup fake receive-pack' '
+ FAKE_RP_ROOT=$(pwd) &&
+ export FAKE_RP_ROOT &&
+ write_script fake-rp <<-\EOF &&
+ echo yes >"$FAKE_RP_ROOT"/rp-ran
+ exit 1
+ EOF
+ git config remote.origin.receivepack "\"\$FAKE_RP_ROOT/fake-rp\""
+'
+
+test_expect_success 'detect missing branches early' '
+ echo no >rp-ran &&
+ echo no >expect &&
+ test_must_fail git push origin missing &&
+ test_cmp expect rp-ran
+'
+
+test_expect_success 'detect missing sha1 expressions early' '
+ echo no >rp-ran &&
+ echo no >expect &&
+ test_must_fail git push origin master~2:master &&
+ test_cmp expect rp-ran
+'
+
+test_expect_success 'detect ambiguous refs early' '
+ git branch foo &&
+ git tag foo &&
+ echo no >rp-ran &&
+ echo no >expect &&
+ test_must_fail git push origin foo &&
+ test_cmp expect rp-ran
+'
+
+test_done
diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh
index 3ae9092..a980574 100755
--- a/t/t5537-fetch-shallow.sh
+++ b/t/t5537-fetch-shallow.sh
@@ -173,4 +173,17 @@ EOF
)
'
+test_expect_success POSIXPERM,SANITY 'shallow fetch from a read-only repo' '
+ cp -R .git read-only.git &&
+ find read-only.git -print | xargs chmod -w &&
+ test_when_finished "find read-only.git -type d -print | xargs chmod +w" &&
+ git clone --no-local --depth=2 read-only.git from-read-only &&
+ git --git-dir=from-read-only/.git log --format=%s >actual &&
+ cat >expect <<EOF &&
+add-1-back
+4
+EOF
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t5560-http-backend-noserver.sh b/t/t5560-http-backend-noserver.sh
index 9be9ae3..5abd11a 100755
--- a/t/t5560-http-backend-noserver.sh
+++ b/t/t5560-http-backend-noserver.sh
@@ -9,8 +9,8 @@ test_have_prereq GREP_STRIPS_CR && export GREP_OPTIONS=-U
run_backend() {
echo "$2" |
- QUERY_STRING="${1#*\?}" \
- PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%\?*}" \
+ QUERY_STRING="${1#*[?]}" \
+ PATH_TRANSLATED="$HTTPD_DOCUMENT_ROOT_PATH/${1%%[?]*}" \
git http-backend >act.out 2>act.err
}
diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index e061468..6b16379 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -3,7 +3,6 @@
test_description='test fetching over git protocol'
. ./test-lib.sh
-LIB_GIT_DAEMON_PORT=${LIB_GIT_DAEMON_PORT-5570}
. "$TEST_DIRECTORY"/lib-git-daemon.sh
start_git_daemon
diff --git a/t/t5602-clone-remote-exec.sh b/t/t5602-clone-remote-exec.sh
index 3f353d9..cbcceab 100755
--- a/t/t5602-clone-remote-exec.sh
+++ b/t/t5602-clone-remote-exec.sh
@@ -12,21 +12,14 @@ test_expect_success setup '
'
test_expect_success 'clone calls git upload-pack unqualified with no -u option' '
- (
- GIT_SSH=./not_ssh &&
- export GIT_SSH &&
- test_must_fail git clone localhost:/path/to/repo junk
- ) &&
+ test_must_fail env GIT_SSH=./not_ssh git clone localhost:/path/to/repo junk &&
echo "localhost git-upload-pack '\''/path/to/repo'\''" >expected &&
test_cmp expected not_ssh_output
'
test_expect_success 'clone calls specified git upload-pack with -u option' '
- (
- GIT_SSH=./not_ssh &&
- export GIT_SSH &&
- test_must_fail git clone -u ./something/bin/git-upload-pack localhost:/path/to/repo junk
- ) &&
+ test_must_fail env GIT_SSH=./not_ssh \
+ git clone -u ./something/bin/git-upload-pack localhost:/path/to/repo junk &&
echo "localhost ./something/bin/git-upload-pack '\''/path/to/repo'\''" >expected &&
test_cmp expected not_ssh_output
'
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index c490368..3c087e9 100755
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
@@ -12,8 +12,8 @@ test_expect_success 'preparing origin repository' '
: >file && git add . && git commit -m1 &&
git clone --bare . a.git &&
git clone --bare . x &&
- test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true &&
- test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true &&
+ test "$(cd a.git && git config --bool core.bare)" = true &&
+ test "$(cd x && git config --bool core.bare)" = true &&
git bundle create b1.bundle --all &&
git bundle create b2.bundle master &&
mkdir dir &&
@@ -24,7 +24,7 @@ test_expect_success 'preparing origin repository' '
test_expect_success 'local clone without .git suffix' '
git clone -l -s a b &&
(cd b &&
- test "$(GIT_CONFIG=.git/config git config --bool core.bare)" = false &&
+ test "$(git config --bool core.bare)" = false &&
git fetch)
'
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index 613f69a..a00a660 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -94,6 +94,19 @@ test_expect_failure 'push new branch with old:new refspec' '
compare_refs local HEAD server refs/heads/new-refspec
'
+test_expect_success 'forced push' '
+ (cd local &&
+ git checkout -b force-test &&
+ echo content >> file &&
+ git commit -a -m eight &&
+ git push origin force-test &&
+ echo content >> file &&
+ git commit -a --amend -m eight-modified &&
+ git push --force origin force-test
+ ) &&
+ compare_refs local refs/heads/force-test server refs/heads/force-test
+'
+
test_expect_success 'cloning without refspec' '
GIT_REMOTE_TESTGIT_REFSPEC="" \
git clone "testgit::${PWD}/server" local2 2>error &&
@@ -199,29 +212,42 @@ test_expect_success 'push update refs failure' '
echo "update fail" >>file &&
git commit -a -m "update fail" &&
git rev-parse --verify testgit/origin/heads/update >expect &&
- GIT_REMOTE_TESTGIT_PUSH_ERROR="non-fast forward" &&
- export GIT_REMOTE_TESTGIT_PUSH_ERROR &&
- test_expect_code 1 git push origin update &&
+ test_expect_code 1 env GIT_REMOTE_TESTGIT_FAILURE="non-fast forward" \
+ git push origin update &&
git rev-parse --verify testgit/origin/heads/update >actual &&
test_cmp expect actual
)
'
+clean_mark () {
+ cut -f 2 -d ' ' "$1" |
+ git cat-file --batch-check |
+ grep commit |
+ sort >$(basename "$1")
+}
+
+cmp_marks () {
+ test_when_finished "rm -rf git.marks testgit.marks" &&
+ clean_mark ".git/testgit/$1/git.marks" &&
+ clean_mark ".git/testgit/$1/testgit.marks" &&
+ test_cmp git.marks testgit.marks
+}
+
test_expect_success 'proper failure checks for fetching' '
- (GIT_REMOTE_TESTGIT_FAILURE=1 &&
- export GIT_REMOTE_TESTGIT_FAILURE &&
- cd local &&
- test_must_fail git fetch 2> error &&
+ (cd local &&
+ test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error &&
cat error &&
grep -q "Error while running fast-import" error
)
'
test_expect_success 'proper failure checks for pushing' '
- (GIT_REMOTE_TESTGIT_FAILURE=1 &&
- export GIT_REMOTE_TESTGIT_FAILURE &&
- cd local &&
- test_must_fail git push --all
+ (cd local &&
+ git checkout -b crash master &&
+ echo crash >>file &&
+ git commit -a -m crash &&
+ test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git push --all &&
+ cmp_marks origin
)
'
diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 9874403..9d9d9de 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -190,12 +190,9 @@ test_expect_success '%C(auto) respects --no-color' '
'
test_expect_success TTY '%C(auto) respects --color=auto (stdout is tty)' '
- (
- TERM=vt100 && export TERM &&
- test_terminal \
- git log --format=$AUTO_COLOR -1 --color=auto >actual &&
- has_color actual
- )
+ test_terminal env TERM=vt100 \
+ git log --format=$AUTO_COLOR -1 --color=auto >actual &&
+ has_color actual
'
test_expect_success '%C(auto) respects --color=auto (stdout not tty)' '
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 215d43d..54d7807 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -308,7 +308,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm
(
cd sub &&
rm -f .git &&
- cp -a ../.git/modules/sub .git &&
+ cp -R -P -p ../.git/modules/sub .git &&
GIT_WORK_TREE=. git config --unset core.worktree
) &&
mkdir mod &&
@@ -331,7 +331,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu
(
cd sub &&
rm -f .git &&
- cp -a ../.git/modules/sub .git &&
+ cp -R -P -p ../.git/modules/sub .git &&
GIT_WORK_TREE=. git config --unset core.worktree
) &&
mkdir mod &&
@@ -447,8 +447,7 @@ test_expect_success 'checking out a commit before submodule moved needs manual u
git mv sub sub2 &&
git commit -m "moved sub to sub2" &&
git checkout -q HEAD^ 2>actual &&
- echo "warning: unable to rmdir sub2: Directory not empty" >expected &&
- test_i18ncmp expected actual &&
+ test_i18ngrep "^warning: unable to rmdir sub2:" actual &&
git status -s sub2 >actual &&
echo "?? sub2/" >expected &&
test_cmp expected actual &&
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index c8d6e9f..e4ab0f5 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1380,4 +1380,73 @@ test_expect_success 'multiple --points-at are OR-ed together' '
test_cmp expect actual
'
+test_expect_success 'lexical sort' '
+ git tag foo1.3 &&
+ git tag foo1.6 &&
+ git tag foo1.10 &&
+ git tag -l --sort=refname "foo*" >actual &&
+ cat >expect <<EOF &&
+foo1.10
+foo1.3
+foo1.6
+EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'version sort' '
+ git tag -l --sort=version:refname "foo*" >actual &&
+ cat >expect <<EOF &&
+foo1.3
+foo1.6
+foo1.10
+EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'reverse version sort' '
+ git tag -l --sort=-version:refname "foo*" >actual &&
+ cat >expect <<EOF &&
+foo1.10
+foo1.6
+foo1.3
+EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'reverse lexical sort' '
+ git tag -l --sort=-refname "foo*" >actual &&
+ cat >expect <<EOF &&
+foo1.6
+foo1.3
+foo1.10
+EOF
+ test_cmp expect actual
+'
+
+run_with_limited_stack () {
+ (ulimit -s 64 && "$@")
+}
+
+test_lazy_prereq ULIMIT 'run_with_limited_stack true'
+
+# we require ulimit, this excludes Windows
+test_expect_success ULIMIT '--contains works in a deep repo' '
+ >expect &&
+ i=1 &&
+ while test $i -lt 4000
+ do
+ echo "commit refs/heads/master
+committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200
+data <<EOF
+commit #$i
+EOF"
+ test $i = 1 && echo "from refs/heads/master^0"
+ i=$(($i + 1))
+ done | git fast-import &&
+ git checkout master &&
+ git tag far-far-away HEAD^ &&
+ run_with_limited_stack git tag --contains HEAD >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index b9365b4..da958a8 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -146,11 +146,7 @@ test_expect_success 'no color when stdout is a regular file' '
test_expect_success TTY 'color when writing to a pager' '
rm -f paginated.out &&
test_config color.ui auto &&
- (
- TERM=vt100 &&
- export TERM &&
- test_terminal git log
- ) &&
+ test_terminal env TERM=vt100 git log &&
colorful paginated.out
'
@@ -158,11 +154,7 @@ test_expect_success TTY 'colors are suppressed by color.pager' '
rm -f paginated.out &&
test_config color.ui auto &&
test_config color.pager false &&
- (
- TERM=vt100 &&
- export TERM &&
- test_terminal git log
- ) &&
+ test_terminal env TERM=vt100 git log &&
! colorful paginated.out
'
@@ -181,11 +173,7 @@ test_expect_success 'color when writing to a file intended for a pager' '
test_expect_success TTY 'colors are sent to pager for external commands' '
test_config alias.externallog "!git log" &&
test_config color.ui auto &&
- (
- TERM=vt100 &&
- export TERM &&
- test_terminal git -p externallog
- ) &&
+ test_terminal env TERM=vt100 git -p externallog &&
colorful paginated.out
'
diff --git a/t/t7101-reset.sh b/t/t7101-reset-empty-subdirs.sh
index 96e163f..96e163f 100755
--- a/t/t7101-reset.sh
+++ b/t/t7101-reset-empty-subdirs.sh
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index ee117e2..4505294 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -535,6 +535,21 @@ test_expect_success 'reset with paths accepts tree' '
git diff HEAD --exit-code
'
+test_expect_success 'reset -N keeps removed files as intent-to-add' '
+ echo new-file >new-file &&
+ git add new-file &&
+ git reset -N HEAD &&
+
+ tree=$(git write-tree) &&
+ git ls-tree $tree new-file >actual &&
+ >expect &&
+ test_cmp expect actual &&
+
+ git diff --name-only >actual &&
+ echo new-file >expect &&
+ test_cmp expect actual
+'
+
test_expect_success 'reset --mixed sets up work tree' '
git init mixed_worktree &&
(
diff --git a/t/t7104-reset.sh b/t/t7104-reset-hard.sh
index 16faa07..16faa07 100755
--- a/t/t7104-reset.sh
+++ b/t/t7104-reset-hard.sh
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index c28e8d8..7c88245 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -249,8 +249,7 @@ test_expect_success 'submodule add in subdirectory with relative path should fai
'
test_expect_success 'setup - add an example entry to .gitmodules' '
- GIT_CONFIG=.gitmodules \
- git config submodule.example.url git://example.com/init.git
+ git config --file=.gitmodules submodule.example.url git://example.com/init.git
'
test_expect_success 'status should fail for unmapped paths' '
@@ -264,7 +263,7 @@ test_expect_success 'setup - map path in .gitmodules' '
path = init
EOF
- GIT_CONFIG=.gitmodules git config submodule.example.path init &&
+ git config --file=.gitmodules submodule.example.path init &&
test_cmp expect .gitmodules
'
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 0246e80..29d3d2c 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -774,5 +774,4 @@ test_expect_success 'submodule update --recursive drops module name before recur
test_i18ngrep "Submodule path .deeper/submodule/subsubmodule.: checked out" actual
)
'
-
test_done
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index bdc1f29..116885a 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -223,7 +223,8 @@ test_expect_success 'Commit without message is allowed with --allow-empty-messag
git add foo &&
>empty &&
git commit --allow-empty-message <empty &&
- commit_msg_is ""
+ commit_msg_is "" &&
+ git tag empty-message-commit
'
test_expect_success 'Commit without message is no-no without --allow-empty-message' '
@@ -240,6 +241,14 @@ test_expect_success 'Commit a message with --allow-empty-message' '
commit_msg_is "hello there"
'
+test_expect_success 'commit -C empty respects --allow-empty-message' '
+ echo more >>foo &&
+ git add foo &&
+ test_must_fail git commit -C empty-message-commit &&
+ git commit -C empty-message-commit --allow-empty-message &&
+ commit_msg_is ""
+'
+
commit_for_rebase_autosquash_setup () {
echo "first content line" >>foo &&
git add foo &&
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 94eec83..63e0427 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -61,11 +61,47 @@ test_expect_success 'nothing to commit' '
test_must_fail git commit -m initial
'
+test_expect_success '--dry-run fails with nothing to commit' '
+ test_must_fail git commit -m initial --dry-run
+'
+
+test_expect_success '--short fails with nothing to commit' '
+ test_must_fail git commit -m initial --short
+'
+
+test_expect_success '--porcelain fails with nothing to commit' '
+ test_must_fail git commit -m initial --porcelain
+'
+
+test_expect_success '--long fails with nothing to commit' '
+ test_must_fail git commit -m initial --long
+'
+
test_expect_success 'setup: non-initial commit' '
echo bongo bongo bongo >file &&
git commit -m next -a
'
+test_expect_success '--dry-run with stuff to commit returns ok' '
+ echo bongo bongo bongo >>file &&
+ git commit -m next -a --dry-run
+'
+
+test_expect_failure '--short with stuff to commit returns ok' '
+ echo bongo bongo bongo >>file &&
+ git commit -m next -a --short
+'
+
+test_expect_failure '--porcelain with stuff to commit returns ok' '
+ echo bongo bongo bongo >>file &&
+ git commit -m next -a --porcelain
+'
+
+test_expect_success '--long with stuff to commit returns ok' '
+ echo bongo bongo bongo >>file &&
+ git commit -m next -a --long
+'
+
test_expect_success 'commit message from non-existing file' '
echo more bongo: bongo bongo bongo bongo >file &&
test_must_fail git commit -F gah -a
@@ -310,8 +346,21 @@ test_expect_success 'amend commit to fix date' '
'
-test_expect_success 'commit complains about bogus date' '
- test_must_fail git commit --amend --date=10.11.2010
+test_expect_success 'commit mentions forced date in output' '
+ git commit --amend --date=2010-01-02T03:04:05 >output &&
+ grep "Date: *Sat Jan 2 03:04:05 2010" output
+'
+
+test_expect_success 'commit complains about completely bogus dates' '
+ test_must_fail git commit --amend --date=seventeen
+'
+
+test_expect_success 'commit --date allows approxidate' '
+ git commit --amend \
+ --date="midnight the 12th of october, anno domini 1979" &&
+ echo "Fri Oct 12 00:00:00 1979 +0000" >expect &&
+ git log -1 --format=%ad >actual &&
+ test_cmp expect actual
'
test_expect_success 'sign off (1)' '
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 6313da2..6465cd5 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -223,6 +223,22 @@ test_expect_success 'cleanup commit messages (whitespace option,-F)' '
'
+test_expect_success 'cleanup commit messages (scissors option,-F,-e)' '
+
+ echo >>negative &&
+ cat >text <<EOF &&
+
+# to be kept
+# ------------------------ >8 ------------------------
+to be removed
+EOF
+ echo "# to be kept" >expect &&
+ git commit --cleanup=scissors -e -F text -a &&
+ git cat-file -p HEAD |sed -e "1,/^\$/d">actual &&
+ test_cmp expect actual
+
+'
+
test_expect_success 'cleanup commit messages (strip option,-F)' '
echo >>negative &&
@@ -328,6 +344,13 @@ test_expect_success 'message shows author when it is not equal to committer' '
.git/COMMIT_EDITMSG
'
+test_expect_success 'message shows date when it is explicitly set' '
+ git commit --allow-empty -e -m foo --date="2010-01-02T03:04:05" &&
+ test_i18ngrep \
+ "^# Date: *Sat Jan 2 03:04:05 2010 +0000" \
+ .git/COMMIT_EDITMSG
+'
+
test_expect_success AUTOIDENT 'message shows committer when it is automatic' '
echo >>negative &&
diff --git a/t/t7510-signed-commit.sh b/t/t7510-signed-commit.sh
index 1d3c56f..5ddac1a 100755
--- a/t/t7510-signed-commit.sh
+++ b/t/t7510-signed-commit.sh
@@ -5,6 +5,8 @@ test_description='signed commit tests'
. "$TEST_DIRECTORY/lib-gpg.sh"
test_expect_success GPG 'create signed commits' '
+ test_when_finished "test_unconfig commit.gpgsign" &&
+
echo 1 >file && git add file &&
test_tick && git commit -S -m initial &&
git tag initial &&
@@ -25,12 +27,27 @@ test_expect_success GPG 'create signed commits' '
git tag fourth-unsigned &&
test_tick && git commit --amend -S -m "fourth signed" &&
- git tag fourth-signed
+ git tag fourth-signed &&
+
+ git config commit.gpgsign true &&
+ echo 5 >file && test_tick && git commit -a -m "fifth signed" &&
+ git tag fifth-signed &&
+
+ git config commit.gpgsign false &&
+ echo 6 >file && test_tick && git commit -a -m "sixth" &&
+ git tag sixth-unsigned &&
+
+ git config commit.gpgsign true &&
+ echo 7 >file && test_tick && git commit -a -m "seventh" --no-gpg-sign &&
+ git tag seventh-unsigned &&
+
+ test_tick && git rebase -f HEAD^^ && git tag sixth-signed HEAD^ &&
+ git tag seventh-signed
'
test_expect_success GPG 'show signatures' '
(
- for commit in initial second merge master
+ for commit in initial second merge fourth-signed fifth-signed sixth-signed master
do
git show --pretty=short --show-signature $commit >actual &&
grep "Good signature from" actual || exit 1
@@ -39,7 +56,7 @@ test_expect_success GPG 'show signatures' '
done
) &&
(
- for commit in merge^2 fourth-unsigned
+ for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
do
git show --pretty=short --show-signature $commit >actual &&
grep "Good signature from" actual && exit 1
@@ -52,7 +69,7 @@ test_expect_success GPG 'show signatures' '
test_expect_success GPG 'detect fudged signature' '
git cat-file commit master >raw &&
- sed -e "s/fourth signed/4th forged/" raw >forged1 &&
+ sed -e "s/seventh/7th forged/" raw >forged1 &&
git hash-object -w -t commit forged1 >forged1.commit &&
git show --pretty=short --show-signature $(cat forged1.commit) >actual1 &&
grep "BAD signature from" actual1 &&
diff --git a/t/t7601-merge-pull-config.sh b/t/t7601-merge-pull-config.sh
index 830a4c3..f768c90 100755
--- a/t/t7601-merge-pull-config.sh
+++ b/t/t7601-merge-pull-config.sh
@@ -38,6 +38,27 @@ test_expect_success 'merge c1 with c2' '
test -f c2.c
'
+test_expect_success 'fast-forward pull succeeds with "true" in pull.ff' '
+ git reset --hard c0 &&
+ test_config pull.ff true &&
+ git pull . c1 &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse c1)"
+'
+
+test_expect_success 'fast-forward pull creates merge with "false" in pull.ff' '
+ git reset --hard c0 &&
+ test_config pull.ff false &&
+ git pull . c1 &&
+ test "$(git rev-parse HEAD^1)" = "$(git rev-parse c0)" &&
+ test "$(git rev-parse HEAD^2)" = "$(git rev-parse c1)"
+'
+
+test_expect_success 'pull prevents non-fast-forward with "only" in pull.ff' '
+ git reset --hard c1 &&
+ test_config pull.ff only &&
+ test_must_fail git pull . c3
+'
+
test_expect_success 'merge c1 with c2 (ours in pull.twohead)' '
git reset --hard c1 &&
git config pull.twohead ours &&
diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index b45bd1e..284018e 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -21,7 +21,7 @@ test_expect_success 'objects in packs marked .keep are not repacked' '
objsha1=$(git verify-pack -v pack-$packsha1.idx | head -n 1 |
sed -e "s/^\([0-9a-f]\{40\}\).*/\1/") &&
mv pack-* .git/objects/pack/ &&
- git repack -A -d -l &&
+ git repack --no-pack-kept-objects -A -d -l &&
git prune-packed &&
for p in .git/objects/pack/*.idx; do
idx=$(basename $p)
@@ -35,6 +35,22 @@ test_expect_success 'objects in packs marked .keep are not repacked' '
test -z "$found_duplicate_object"
'
+test_expect_success 'writing bitmaps can duplicate .keep objects' '
+ # build on $objsha1, $packsha1, and .keep state from previous
+ git repack -Adl &&
+ test_when_finished "found_duplicate_object=" &&
+ for p in .git/objects/pack/*.idx; do
+ idx=$(basename $p)
+ test "pack-$packsha1.idx" = "$idx" && continue
+ if git verify-pack -v $p | egrep "^$objsha1"; then
+ found_duplicate_object=1
+ echo "DUPLICATE OBJECT FOUND"
+ break
+ fi
+ done &&
+ test "$found_duplicate_object" = 1
+'
+
test_expect_success 'loose objects in alternate ODB are not repacked' '
mkdir alt_objects &&
echo `pwd`/alt_objects > .git/objects/info/alternates &&
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 5a193c5..dc30a51 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -58,7 +58,7 @@ test_expect_success PERL 'custom tool commands override built-ins' '
test_expect_success PERL 'difftool ignores bad --tool values' '
: >expect &&
- test_expect_code 1 \
+ test_must_fail \
git difftool --no-prompt --tool=bad-tool branch >actual &&
test_cmp expect actual
'
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index f698001..63b3039 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -105,7 +105,7 @@ do
test_expect_success "grep -w $L (w)" '
: >expected &&
- test_must_fail git grep -n -w -e "^w" >actual &&
+ test_must_fail git grep -n -w -e "^w" $H >actual &&
test_cmp expected actual
'
@@ -240,92 +240,104 @@ do
test_cmp expected actual
'
test_expect_success "grep $L with grep.extendedRegexp=false" '
- echo "ab:a+bc" >expected &&
- git -c grep.extendedRegexp=false grep "a+b*c" ab >actual &&
+ echo "${HC}ab:a+bc" >expected &&
+ git -c grep.extendedRegexp=false grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
test_expect_success "grep $L with grep.extendedRegexp=true" '
- echo "ab:abc" >expected &&
- git -c grep.extendedRegexp=true grep "a+b*c" ab >actual &&
+ echo "${HC}ab:abc" >expected &&
+ git -c grep.extendedRegexp=true grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
test_expect_success "grep $L with grep.patterntype=basic" '
- echo "ab:a+bc" >expected &&
- git -c grep.patterntype=basic grep "a+b*c" ab >actual &&
+ echo "${HC}ab:a+bc" >expected &&
+ git -c grep.patterntype=basic grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
test_expect_success "grep $L with grep.patterntype=extended" '
- echo "ab:abc" >expected &&
- git -c grep.patterntype=extended grep "a+b*c" ab >actual &&
+ echo "${HC}ab:abc" >expected &&
+ git -c grep.patterntype=extended grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
test_expect_success "grep $L with grep.patterntype=fixed" '
- echo "ab:a+b*c" >expected &&
- git -c grep.patterntype=fixed grep "a+b*c" ab >actual &&
+ echo "${HC}ab:a+b*c" >expected &&
+ git -c grep.patterntype=fixed grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
test_expect_success LIBPCRE "grep $L with grep.patterntype=perl" '
- echo "ab:a+b*c" >expected &&
- git -c grep.patterntype=perl grep "a\x{2b}b\x{2a}c" ab >actual &&
+ echo "${HC}ab:a+b*c" >expected &&
+ git -c grep.patterntype=perl grep "a\x{2b}b\x{2a}c" $H ab >actual &&
test_cmp expected actual
'
test_expect_success "grep $L with grep.patternType=default and grep.extendedRegexp=true" '
- echo "ab:abc" >expected &&
+ echo "${HC}ab:abc" >expected &&
git \
-c grep.patternType=default \
-c grep.extendedRegexp=true \
- grep "a+b*c" ab >actual &&
+ grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
test_expect_success "grep $L with grep.extendedRegexp=true and grep.patternType=default" '
- echo "ab:abc" >expected &&
+ echo "${HC}ab:abc" >expected &&
git \
-c grep.extendedRegexp=true \
-c grep.patternType=default \
- grep "a+b*c" ab >actual &&
+ grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
- test_expect_success 'grep $L with grep.patternType=extended and grep.extendedRegexp=false' '
- echo "ab:abc" >expected &&
+ test_expect_success "grep $L with grep.patternType=extended and grep.extendedRegexp=false" '
+ echo "${HC}ab:abc" >expected &&
git \
-c grep.patternType=extended \
-c grep.extendedRegexp=false \
- grep "a+b*c" ab >actual &&
+ grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
- test_expect_success 'grep $L with grep.patternType=basic and grep.extendedRegexp=true' '
- echo "ab:a+bc" >expected &&
+ test_expect_success "grep $L with grep.patternType=basic and grep.extendedRegexp=true" '
+ echo "${HC}ab:a+bc" >expected &&
git \
-c grep.patternType=basic \
-c grep.extendedRegexp=true \
- grep "a+b*c" ab >actual &&
+ grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
- test_expect_success 'grep $L with grep.extendedRegexp=false and grep.patternType=extended' '
- echo "ab:abc" >expected &&
+ test_expect_success "grep $L with grep.extendedRegexp=false and grep.patternType=extended" '
+ echo "${HC}ab:abc" >expected &&
git \
-c grep.extendedRegexp=false \
-c grep.patternType=extended \
- grep "a+b*c" ab >actual &&
+ grep "a+b*c" $H ab >actual &&
test_cmp expected actual
'
- test_expect_success 'grep $L with grep.extendedRegexp=true and grep.patternType=basic' '
- echo "ab:a+bc" >expected &&
+ test_expect_success "grep $L with grep.extendedRegexp=true and grep.patternType=basic" '
+ echo "${HC}ab:a+bc" >expected &&
git \
-c grep.extendedRegexp=true \
-c grep.patternType=basic \
- grep "a+b*c" ab >actual &&
+ grep "a+b*c" $H ab >actual &&
+ test_cmp expected actual
+ '
+
+ test_expect_success "grep --count $L" '
+ echo ${HC}ab:3 >expected &&
+ git grep --count -e b $H -- ab >actual &&
+ test_cmp expected actual
+ '
+
+ test_expect_success "grep --count -h $L" '
+ echo 3 >expected &&
+ git grep --count -h -e b $H -- ab >actual &&
test_cmp expected actual
'
done
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 3119c8c..1ecdacb 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -409,7 +409,7 @@ test_expect_success $PREREQ 'Valid In-Reply-To when prompting' '
(echo "From Example <from@example.com>"
echo "To Example <to@example.com>"
echo ""
- ) | env GIT_SEND_EMAIL_NOTTY=1 git send-email \
+ ) | GIT_SEND_EMAIL_NOTTY=1 git send-email \
--smtp-server="$(pwd)/fake.sendmail" \
$patches 2>errors &&
! grep "^In-Reply-To: < *>" msgtxt1
diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh
index ee73013..6e69fc4 100755
--- a/t/t9107-git-svn-migrate.sh
+++ b/t/t9107-git-svn-migrate.sh
@@ -45,27 +45,27 @@ test_expect_success 'initialize old-style (v0) git svn layout' '
test_expect_success 'initialize a multi-repository repo' '
git svn init "$svnrepo" -T trunk -t tags -b branches &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
- grep "^trunk:refs/remotes/trunk$" fetch.out &&
+ grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
test -n "`git config --get svn-remote.svn.branches \
- "^branches/\*:refs/remotes/\*$"`" &&
+ "^branches/\*:refs/remotes/origin/\*$"`" &&
test -n "`git config --get svn-remote.svn.tags \
- "^tags/\*:refs/remotes/tags/\*$"`" &&
+ "^tags/\*:refs/remotes/origin/tags/\*$"`" &&
git config --unset svn-remote.svn.branches \
- "^branches/\*:refs/remotes/\*$" &&
+ "^branches/\*:refs/remotes/origin/\*$" &&
git config --unset svn-remote.svn.tags \
- "^tags/\*:refs/remotes/tags/\*$" &&
- git config --add svn-remote.svn.fetch "branches/a:refs/remotes/a" &&
- git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" &&
+ "^tags/\*:refs/remotes/origin/tags/\*$" &&
+ git config --add svn-remote.svn.fetch "branches/a:refs/remotes/origin/a" &&
+ git config --add svn-remote.svn.fetch "branches/b:refs/remotes/origin/b" &&
for i in tags/0.1 tags/0.2 tags/0.3; do
git config --add svn-remote.svn.fetch \
- $i:refs/remotes/$i || exit 1; done &&
+ $i:refs/remotes/origin/$i || exit 1; done &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
- grep "^trunk:refs/remotes/trunk$" fetch.out &&
- grep "^branches/a:refs/remotes/a$" fetch.out &&
- grep "^branches/b:refs/remotes/b$" fetch.out &&
- grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
- grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
- grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
+ grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
+ grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
+ grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
+ grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
+ grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
+ grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
grep "^:refs/${remotes_git_svn}" fetch.out
'
@@ -73,14 +73,14 @@ test_expect_success 'initialize a multi-repository repo' '
test_expect_success 'multi-fetch works on partial urls + paths' "
git svn multi-fetch &&
for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
- git rev-parse --verify refs/remotes/\$i^0 >> refs.out || exit 1;
+ git rev-parse --verify refs/remotes/origin/\$i^0 >> refs.out || exit 1;
done &&
test -z \"\`sort < refs.out | uniq -d\`\" &&
for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
for j in trunk a b tags/0.1 tags/0.2 tags/0.3; do
if test \$j != \$i; then continue; fi
- test -z \"\`git diff refs/remotes/\$i \
- refs/remotes/\$j\`\" ||exit 1; done; done
+ test -z \"\`git diff refs/remotes/origin/\$i \
+ refs/remotes/origin/\$j\`\" ||exit 1; done; done
"
test_expect_success 'migrate --minimize on old inited layout' '
@@ -98,27 +98,27 @@ test_expect_success 'migrate --minimize on old inited layout' '
git svn migrate --minimize &&
test -z "`git config -l | grep "^svn-remote\.git-svn\."`" &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
- grep "^trunk:refs/remotes/trunk$" fetch.out &&
- grep "^branches/a:refs/remotes/a$" fetch.out &&
- grep "^branches/b:refs/remotes/b$" fetch.out &&
- grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
- grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
- grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
+ grep "^trunk:refs/remotes/origin/trunk$" fetch.out &&
+ grep "^branches/a:refs/remotes/origin/a$" fetch.out &&
+ grep "^branches/b:refs/remotes/origin/b$" fetch.out &&
+ grep "^tags/0\.1:refs/remotes/origin/tags/0\.1$" fetch.out &&
+ grep "^tags/0\.2:refs/remotes/origin/tags/0\.2$" fetch.out &&
+ grep "^tags/0\.3:refs/remotes/origin/tags/0\.3$" fetch.out &&
grep "^:refs/${remotes_git_svn}" fetch.out
'
test_expect_success ".rev_db auto-converted to .rev_map.UUID" '
git svn fetch -i trunk &&
- test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
- expect="$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_map.*)" &&
+ test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
+ expect="$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_map.*)" &&
test -n "$expect" &&
rev_db="$(echo $expect | sed -e "s,_map,_db,")" &&
convert_to_rev_db "$expect" "$rev_db" &&
rm -f "$expect" &&
test -f "$rev_db" &&
git svn fetch -i trunk &&
- test -z "$(ls "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db.* 2>/dev/null)" &&
- test ! -e "$GIT_DIR"/svn/refs/remotes/trunk/.rev_db &&
+ test -z "$(ls "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db.* 2>/dev/null)" &&
+ test ! -e "$GIT_DIR"/svn/refs/remotes/origin/trunk/.rev_db &&
test -f "$expect"
'
diff --git a/t/t9114-git-svn-dcommit-merge.sh b/t/t9114-git-svn-dcommit-merge.sh
index d33d714..fb41876 100755
--- a/t/t9114-git-svn-dcommit-merge.sh
+++ b/t/t9114-git-svn-dcommit-merge.sh
@@ -48,7 +48,7 @@ test_expect_success 'setup svn repository' '
test_expect_success 'setup git mirror and merge' '
git svn init "$svnrepo" -t tags -T trunk -b branches &&
git svn fetch &&
- git checkout -b svn remotes/trunk &&
+ git checkout -b svn remotes/origin/trunk &&
git checkout -b merge &&
echo new file > new_file &&
git add new_file &&
@@ -81,7 +81,7 @@ test_debug 'gitk --all & sleep 1'
test_expect_success 'verify post-merge ancestry' "
test x\`git rev-parse --verify refs/heads/svn\` = \
- x\`git rev-parse --verify refs/remotes/trunk \` &&
+ x\`git rev-parse --verify refs/remotes/origin/trunk \` &&
test x\`git rev-parse --verify refs/heads/svn^2\` = \
x\`git rev-parse --verify refs/heads/merge\` &&
git cat-file commit refs/heads/svn^ | grep '^friend$'
diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh
index cf4c052..45773ee 100755
--- a/t/t9116-git-svn-log.sh
+++ b/t/t9116-git-svn-log.sh
@@ -20,20 +20,20 @@ test_expect_success 'setup repository and import' '
) &&
git svn init "$svnrepo" -T trunk -b branches -t tags &&
git svn fetch &&
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
echo bye >> README &&
git commit -a -m bye &&
git svn dcommit &&
- git reset --hard a &&
+ git reset --hard origin/a &&
echo why >> FEEDME &&
git update-index --add FEEDME &&
git commit -m feedme &&
git svn dcommit &&
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
echo aye >> README &&
git commit -a -m aye &&
git svn dcommit &&
- git reset --hard b &&
+ git reset --hard origin/b &&
echo spy >> README &&
git commit -a -m spy &&
echo try >> README &&
@@ -42,26 +42,26 @@ test_expect_success 'setup repository and import' '
'
test_expect_success 'run log' "
- git reset --hard a &&
- git svn log -r2 trunk | grep ^r2 &&
- git svn log -r4 trunk | grep ^r4 &&
+ git reset --hard origin/a &&
+ git svn log -r2 origin/trunk | grep ^r2 &&
+ git svn log -r4 origin/trunk | grep ^r4 &&
git svn log -r3 | grep ^r3
"
test_expect_success 'run log against a from trunk' "
- git reset --hard trunk &&
- git svn log -r3 a | grep ^r3
+ git reset --hard origin/trunk &&
+ git svn log -r3 origin/a | grep ^r3
"
printf 'r1 \nr2 \nr4 \n' > expected-range-r1-r2-r4
test_expect_success 'test ascending revision range' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
"
test_expect_success 'test ascending revision range with --show-commit' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2-r4 -
"
@@ -69,7 +69,7 @@ test_expect_success 'test ascending revision range with --show-commit (sha1)' "
git svn find-rev r1 >expected-range-r1-r2-r4-sha1 &&
git svn find-rev r2 >>expected-range-r1-r2-r4-sha1 &&
git svn find-rev r4 >>expected-range-r1-r2-r4-sha1 &&
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log --show-commit -r 1:4 | grep '^r[0-9]' | cut -d'|' -f2 >out &&
git rev-parse \$(cat out) >actual &&
test_cmp expected-range-r1-r2-r4-sha1 actual
@@ -78,67 +78,67 @@ test_expect_success 'test ascending revision range with --show-commit (sha1)' "
printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
test_expect_success 'test descending revision range' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 4:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4-r2-r1 -
"
printf 'r1 \nr2 \n' > expected-range-r1-r2
test_expect_success 'test ascending revision range with unreachable revision' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 1:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r1-r2 -
"
printf 'r2 \nr1 \n' > expected-range-r2-r1
test_expect_success 'test descending revision range with unreachable revision' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 3:1 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2-r1 -
"
printf 'r2 \n' > expected-range-r2
test_expect_success 'test ascending revision range with unreachable upper boundary revision and 1 commit' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 2:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
"
test_expect_success 'test descending revision range with unreachable upper boundary revision and 1 commit' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 3:2 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r2 -
"
printf 'r4 \n' > expected-range-r4
test_expect_success 'test ascending revision range with unreachable lower boundary revision and 1 commit' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 3:4 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
test_expect_success 'test descending revision range with unreachable lower boundary revision and 1 commit' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 4:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
printf -- '------------------------------------------------------------------------\n' > expected-separator
test_expect_success 'test ascending revision range with unreachable boundary revisions and no commits' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 5:6 | test_cmp expected-separator -
"
test_expect_success 'test descending revision range with unreachable boundary revisions and no commits' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 6:5 | test_cmp expected-separator -
"
test_expect_success 'test ascending revision range with unreachable boundary revisions and 1 commit' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 3:5 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
test_expect_success 'test descending revision range with unreachable boundary revisions and 1 commit' "
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn log -r 5:3 | grep '^r[0-9]' | cut -d'|' -f1 | test_cmp expected-range-r4 -
"
diff --git a/t/t9117-git-svn-init-clone.sh b/t/t9117-git-svn-init-clone.sh
index 69e9c0d..a66f43c 100755
--- a/t/t9117-git-svn-init-clone.sh
+++ b/t/t9117-git-svn-init-clone.sh
@@ -83,36 +83,36 @@ EOF
rm -f expect actual
}
-test_expect_success 'init with -s/-T/-b/-t without --prefix warns' '
+test_expect_success 'init with -s/-T/-b/-t assumes --prefix=origin/' '
test ! -d project &&
git svn init -s "$svnrepo"/project project 2>warning &&
- grep -q prefix warning &&
- test_svn_configured_prefix "" &&
+ test_must_fail grep -q prefix warning &&
+ test_svn_configured_prefix "origin/" &&
rm -rf project &&
rm -f warning
'
-test_expect_success 'clone with -s/-T/-b/-t without --prefix warns' '
+test_expect_success 'clone with -s/-T/-b/-t assumes --prefix=origin/' '
test ! -d project &&
git svn clone -s "$svnrepo"/project 2>warning &&
- grep -q prefix warning &&
- test_svn_configured_prefix "" &&
+ test_must_fail grep -q prefix warning &&
+ test_svn_configured_prefix "origin/" &&
rm -rf project &&
rm -f warning
'
-test_expect_success 'init with -s/-T/-b/-t and --prefix does not warn' '
+test_expect_success 'init with -s/-T/-b/-t and --prefix "" still works' '
test ! -d project &&
- git svn init -s "$svnrepo"/project project --prefix="" 2>warning &&
+ git svn init -s "$svnrepo"/project project --prefix "" 2>warning &&
test_must_fail grep -q prefix warning &&
test_svn_configured_prefix "" &&
rm -rf project &&
rm -f warning
'
-test_expect_success 'clone with -s/-T/-b/-t and --prefix does not warn' '
+test_expect_success 'clone with -s/-T/-b/-t and --prefix "" still works' '
test ! -d project &&
- git svn clone -s "$svnrepo"/project --prefix="" 2>warning &&
+ git svn clone -s "$svnrepo"/project --prefix "" 2>warning &&
test_must_fail grep -q prefix warning &&
test_svn_configured_prefix "" &&
rm -rf project &&
diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh
index 15f93b4..ed4d136 100755
--- a/t/t9118-git-svn-funky-branch-names.sh
+++ b/t/t9118-git-svn-funky-branch-names.sh
@@ -41,20 +41,20 @@ test_expect_success 'test clone with funky branch names' '
git svn clone -s "$svnrepo/pr ject" project &&
(
cd project &&
- git rev-parse "refs/remotes/fun%20plugin" &&
- git rev-parse "refs/remotes/more%20fun%20plugin!" &&
- git rev-parse "refs/remotes/$scary_ref" &&
- git rev-parse "refs/remotes/%2Eleading_dot" &&
- git rev-parse "refs/remotes/trailing_dot%2E" &&
- git rev-parse "refs/remotes/trailing_dotlock%2Elock" &&
- git rev-parse "refs/remotes/$non_reflog"
+ git rev-parse "refs/remotes/origin/fun%20plugin" &&
+ git rev-parse "refs/remotes/origin/more%20fun%20plugin!" &&
+ git rev-parse "refs/remotes/origin/$scary_ref" &&
+ git rev-parse "refs/remotes/origin/%2Eleading_dot" &&
+ git rev-parse "refs/remotes/origin/trailing_dot%2E" &&
+ git rev-parse "refs/remotes/origin/trailing_dotlock%2Elock" &&
+ git rev-parse "refs/remotes/origin/$non_reflog"
)
'
test_expect_success 'test dcommit to funky branch' "
(
cd project &&
- git reset --hard 'refs/remotes/more%20fun%20plugin!' &&
+ git reset --hard 'refs/remotes/origin/more%20fun%20plugin!' &&
echo hello >> foo &&
git commit -m 'hello' -- foo &&
git svn dcommit
@@ -64,7 +64,7 @@ test_expect_success 'test dcommit to funky branch' "
test_expect_success 'test dcommit to scary branch' '
(
cd project &&
- git reset --hard "refs/remotes/$scary_ref" &&
+ git reset --hard "refs/remotes/origin/$scary_ref" &&
echo urls are scary >> foo &&
git commit -m "eep" -- foo &&
git svn dcommit
@@ -74,7 +74,7 @@ test_expect_success 'test dcommit to scary branch' '
test_expect_success 'test dcommit to trailing_dotlock branch' '
(
cd project &&
- git reset --hard "refs/remotes/trailing_dotlock%2Elock" &&
+ git reset --hard "refs/remotes/origin/trailing_dotlock%2Elock" &&
echo who names branches like this anyway? >> foo &&
git commit -m "bar" -- foo &&
git svn dcommit
diff --git a/t/t9120-git-svn-clone-with-percent-escapes.sh b/t/t9120-git-svn-clone-with-percent-escapes.sh
index 1d92c05..1c84ce1 100755
--- a/t/t9120-git-svn-clone-with-percent-escapes.sh
+++ b/t/t9120-git-svn-clone-with-percent-escapes.sh
@@ -58,19 +58,19 @@ test_expect_success 'test clone --stdlayout with percent escapes' '
git svn clone --stdlayout "$svnrepo/pr%20ject" percent &&
(
cd percent &&
- git rev-parse refs/remotes/trunk^0 &&
- git rev-parse refs/remotes/b^0 &&
- git rev-parse refs/remotes/tags/v1^0
+ git rev-parse refs/remotes/origin/trunk^0 &&
+ git rev-parse refs/remotes/origin/b^0 &&
+ git rev-parse refs/remotes/origin/tags/v1^0
)
'
test_expect_success 'test clone -s with unescaped space' '
- git svn clone -s "$svnrepo/pr ject" space &&
+ git svn clone -s "$svnrepo/pr ject" --prefix origin/ space &&
(
cd space &&
- git rev-parse refs/remotes/trunk^0 &&
- git rev-parse refs/remotes/b^0 &&
- git rev-parse refs/remotes/tags/v1^0
+ git rev-parse refs/remotes/origin/trunk^0 &&
+ git rev-parse refs/remotes/origin/b^0 &&
+ git rev-parse refs/remotes/origin/tags/v1^0
)
'
diff --git a/t/t9125-git-svn-multi-glob-branch-names.sh b/t/t9125-git-svn-multi-glob-branch-names.sh
index 096abd1..0d53fc9 100755
--- a/t/t9125-git-svn-multi-glob-branch-names.sh
+++ b/t/t9125-git-svn-multi-glob-branch-names.sh
@@ -20,14 +20,14 @@ test_expect_success 'test clone with multi-glob in branch names' '
git svn clone -T trunk -b branches/*/* -t tags \
"$svnrepo/project" project &&
(cd project &&
- git rev-parse "refs/remotes/v14.1/beta" &&
- git rev-parse "refs/remotes/v14.1/gold"
+ git rev-parse "refs/remotes/origin/v14.1/beta" &&
+ git rev-parse "refs/remotes/origin/v14.1/gold"
)
'
test_expect_success 'test dcommit to multi-globbed branch' "
(cd project &&
- git reset --hard 'refs/remotes/v14.1/gold' &&
+ git reset --hard 'refs/remotes/origin/v14.1/gold' &&
echo hello >> foo &&
git commit -m 'hello' -- foo &&
git svn dcommit
diff --git a/t/t9128-git-svn-cmd-branch.sh b/t/t9128-git-svn-cmd-branch.sh
index 4b034a6..4e95f79 100755
--- a/t/t9128-git-svn-cmd-branch.sh
+++ b/t/t9128-git-svn-cmd-branch.sh
@@ -29,30 +29,30 @@ test_expect_success 'initialize svnrepo' '
test_expect_success 'import into git' '
git svn init --stdlayout "$svnrepo" &&
git svn fetch &&
- git checkout remotes/trunk
+ git checkout remotes/origin/trunk
'
test_expect_success 'git svn branch tests' '
git svn branch a &&
base=$(git rev-parse HEAD:) &&
- test $base = $(git rev-parse remotes/a:) &&
+ test $base = $(git rev-parse remotes/origin/a:) &&
git svn branch -m "created branch b blah" b &&
- test $base = $(git rev-parse remotes/b:) &&
+ test $base = $(git rev-parse remotes/origin/b:) &&
test_must_fail git branch -m "no branchname" &&
git svn branch -n c &&
- test_must_fail git rev-parse remotes/c &&
+ test_must_fail git rev-parse remotes/origin/c &&
test_must_fail git svn branch a &&
git svn branch -t tag1 &&
- test $base = $(git rev-parse remotes/tags/tag1:) &&
+ test $base = $(git rev-parse remotes/origin/tags/tag1:) &&
git svn branch --tag tag2 &&
- test $base = $(git rev-parse remotes/tags/tag2:) &&
+ test $base = $(git rev-parse remotes/origin/tags/tag2:) &&
git svn tag tag3 &&
- test $base = $(git rev-parse remotes/tags/tag3:) &&
+ test $base = $(git rev-parse remotes/origin/tags/tag3:) &&
git svn tag -m "created tag4 foo" tag4 &&
- test $base = $(git rev-parse remotes/tags/tag4:) &&
+ test $base = $(git rev-parse remotes/origin/tags/tag4:) &&
test_must_fail git svn tag -m "no tagname" &&
git svn tag -n tag5 &&
- test_must_fail git rev-parse remotes/tags/tag5 &&
+ test_must_fail git rev-parse remotes/origin/tags/tag5 &&
test_must_fail git svn tag tag1
'
diff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh
index c3443ce..c44de26 100755
--- a/t/t9130-git-svn-authors-file.sh
+++ b/t/t9130-git-svn-authors-file.sh
@@ -67,7 +67,7 @@ test_expect_success 'fetch fails on ee' '
'
tmp_config_get () {
- GIT_CONFIG=.git/svn/.metadata git config --get "$1"
+ git config --file=.git/svn/.metadata --get "$1"
}
test_expect_success 'failure happened without negative side effects' '
@@ -97,7 +97,6 @@ test_expect_success 'fresh clone with svn.authors-file in config' '
test x = x"$(git config svn.authorsfile)" &&
test_config="$HOME"/.gitconfig &&
sane_unset GIT_DIR &&
- sane_unset GIT_CONFIG &&
git config --global \
svn.authorsfile "$HOME"/svn-authors &&
test x"$HOME"/svn-authors = x"$(git config svn.authorsfile)" &&
diff --git a/t/t9135-git-svn-moved-branch-empty-file.sh b/t/t9135-git-svn-moved-branch-empty-file.sh
index 5280e5f..93db45d 100755
--- a/t/t9135-git-svn-moved-branch-empty-file.sh
+++ b/t/t9135-git-svn-moved-branch-empty-file.sh
@@ -12,7 +12,7 @@ test_expect_success 'clone using git svn' 'git svn clone -s "$svnrepo" x'
test_expect_success 'test that b1 exists and is empty' '
(
cd x &&
- git reset --hard branch-c &&
+ git reset --hard origin/branch-c &&
test -f b1 &&
! test -s b1
)
diff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh
index 3cd0671..8e7f7d6 100755
--- a/t/t9141-git-svn-multiple-branches.sh
+++ b/t/t9141-git-svn-multiple-branches.sh
@@ -66,18 +66,18 @@ test_expect_success 'clone multiple branch and tag paths' '
-t tags_A/* --tags tags_B \
"$svnrepo/project" git_project &&
( cd git_project &&
- git rev-parse refs/remotes/first &&
- git rev-parse refs/remotes/second &&
- git rev-parse refs/remotes/1 &&
- git rev-parse refs/remotes/2 &&
- git rev-parse refs/remotes/tags/1.0 &&
- git rev-parse refs/remotes/tags/2.0 &&
- git rev-parse refs/remotes/tags/3.0 &&
- git rev-parse refs/remotes/tags/4.0 &&
- git rev-parse refs/remotes/tags/v5 &&
- git rev-parse refs/remotes/tags/v6 &&
- git rev-parse refs/remotes/tags/v7 &&
- git rev-parse refs/remotes/tags/v8
+ git rev-parse refs/remotes/origin/first &&
+ git rev-parse refs/remotes/origin/second &&
+ git rev-parse refs/remotes/origin/1 &&
+ git rev-parse refs/remotes/origin/2 &&
+ git rev-parse refs/remotes/origin/tags/1.0 &&
+ git rev-parse refs/remotes/origin/tags/2.0 &&
+ git rev-parse refs/remotes/origin/tags/3.0 &&
+ git rev-parse refs/remotes/origin/tags/4.0 &&
+ git rev-parse refs/remotes/origin/tags/v5 &&
+ git rev-parse refs/remotes/origin/tags/v6 &&
+ git rev-parse refs/remotes/origin/tags/v7 &&
+ git rev-parse refs/remotes/origin/tags/v8
)
'
@@ -85,8 +85,8 @@ test_expect_success 'Multiple branch or tag paths require -d' '
( cd git_project &&
test_must_fail git svn branch -m "No new branch" Nope &&
test_must_fail git svn tag -m "No new tag" Tagless &&
- test_must_fail git rev-parse refs/remotes/Nope &&
- test_must_fail git rev-parse refs/remotes/tags/Tagless
+ test_must_fail git rev-parse refs/remotes/origin/Nope &&
+ test_must_fail git rev-parse refs/remotes/origin/tags/Tagless
) &&
( cd svn_project &&
svn_cmd up &&
diff --git a/t/t9145-git-svn-master-branch.sh b/t/t9145-git-svn-master-branch.sh
index 16852d2..6559137 100755
--- a/t/t9145-git-svn-master-branch.sh
+++ b/t/t9145-git-svn-master-branch.sh
@@ -17,7 +17,7 @@ test_expect_success 'git svn clone --stdlayout sets up trunk as master' '
git svn clone -s "$svnrepo" g &&
(
cd g &&
- test x`git rev-parse --verify refs/remotes/trunk^0` = \
+ test x`git rev-parse --verify refs/remotes/origin/trunk^0` = \
x`git rev-parse --verify refs/heads/master^0`
)
'
diff --git a/t/t9154-git-svn-fancy-glob.sh b/t/t9154-git-svn-fancy-glob.sh
index b780e0e..a0150f0 100755
--- a/t/t9154-git-svn-fancy-glob.sh
+++ b/t/t9154-git-svn-fancy-glob.sh
@@ -22,7 +22,7 @@ test_expect_success 'add red branch' "
"
test_expect_success 'add gre branch' "
- GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&
+ git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
git config svn-remote.svn.branches 'branches/{red,gre}:refs/remotes/*' &&
git svn fetch &&
git rev-parse refs/remotes/red &&
@@ -31,7 +31,7 @@ test_expect_success 'add gre branch' "
"
test_expect_success 'add green branch' "
- GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&
+ git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
git config svn-remote.svn.branches 'branches/{red,green}:refs/remotes/*' &&
git svn fetch &&
git rev-parse refs/remotes/red &&
@@ -40,7 +40,7 @@ test_expect_success 'add green branch' "
"
test_expect_success 'add all branches' "
- GIT_CONFIG=.git/svn/.metadata git config --unset svn-remote.svn.branches-maxRev &&
+ git config --file=.git/svn/.metadata --unset svn-remote.svn.branches-maxRev &&
git config svn-remote.svn.branches 'branches/*:refs/remotes/*' &&
git svn fetch &&
git rev-parse refs/remotes/red &&
diff --git a/t/t9155-git-svn-fetch-deleted-tag.sh b/t/t9155-git-svn-fetch-deleted-tag.sh
index a486a98..184336f 100755
--- a/t/t9155-git-svn-fetch-deleted-tag.sh
+++ b/t/t9155-git-svn-fetch-deleted-tag.sh
@@ -35,8 +35,8 @@ test_expect_success 'fetch deleted tags from same revision with checksum error'
cd git_project &&
git svn fetch &&
- git diff --exit-code mybranch:trunk/subdir/file tags/mytag:file &&
- git diff --exit-code master:subdir/file tags/mytag^:file
+ git diff --exit-code origin/mybranch:trunk/subdir/file origin/tags/mytag:file &&
+ git diff --exit-code master:subdir/file origin/tags/mytag^:file
'
test_done
diff --git a/t/t9156-git-svn-fetch-deleted-tag-2.sh b/t/t9156-git-svn-fetch-deleted-tag-2.sh
index 5ce7e2f..7a6e33b 100755
--- a/t/t9156-git-svn-fetch-deleted-tag-2.sh
+++ b/t/t9156-git-svn-fetch-deleted-tag-2.sh
@@ -36,9 +36,9 @@ test_expect_success 'fetch deleted tags from same revision with no checksum erro
cd git_project &&
git svn fetch &&
- git diff --exit-code master:subdir3/file tags/mytag:file &&
- git diff --exit-code master:subdir2/file tags/mytag^:file &&
- git diff --exit-code master:subdir1/file tags/mytag^^:file
+ git diff --exit-code master:subdir3/file origin/tags/mytag:file &&
+ git diff --exit-code master:subdir2/file origin/tags/mytag^:file &&
+ git diff --exit-code master:subdir1/file origin/tags/mytag^^:file
'
test_done
diff --git a/t/t9161-git-svn-mergeinfo-push.sh b/t/t9161-git-svn-mergeinfo-push.sh
index 1eab701..6cb0909 100755
--- a/t/t9161-git-svn-mergeinfo-push.sh
+++ b/t/t9161-git-svn-mergeinfo-push.sh
@@ -18,8 +18,8 @@ test_expect_success 'load svn dump' "
test_expect_success 'propagate merge information' '
git config svn.pushmergeinfo yes &&
- git checkout svnb1 &&
- git merge --no-ff svnb2 &&
+ git checkout origin/svnb1 &&
+ git merge --no-ff origin/svnb2 &&
git svn dcommit
'
@@ -29,7 +29,7 @@ test_expect_success 'check svn:mergeinfo' '
'
test_expect_success 'merge another branch' '
- git merge --no-ff svnb3 &&
+ git merge --no-ff origin/svnb3 &&
git svn dcommit
'
@@ -40,7 +40,7 @@ test_expect_success 'check primary parent mergeinfo respected' '
'
test_expect_success 'merge existing merge' '
- git merge --no-ff svnb4 &&
+ git merge --no-ff origin/svnb4 &&
git svn dcommit
'
@@ -53,7 +53,7 @@ test_expect_success "check both parents' mergeinfo respected" '
'
test_expect_success 'make further commits to branch' '
- git checkout svnb2 &&
+ git checkout origin/svnb2 &&
touch newb2file &&
git add newb2file &&
git commit -m "later b2 commit" &&
@@ -64,8 +64,8 @@ test_expect_success 'make further commits to branch' '
'
test_expect_success 'second forward merge' '
- git checkout svnb1 &&
- git merge --no-ff svnb2 &&
+ git checkout origin/svnb1 &&
+ git merge --no-ff origin/svnb2 &&
git svn dcommit
'
@@ -78,8 +78,8 @@ test_expect_success 'check new mergeinfo added' '
'
test_expect_success 'reintegration merge' '
- git checkout svnb4 &&
- git merge --no-ff svnb1 &&
+ git checkout origin/svnb4 &&
+ git merge --no-ff origin/svnb1 &&
git svn dcommit
'
@@ -92,11 +92,11 @@ test_expect_success 'check reintegration mergeinfo' '
'
test_expect_success 'dcommit a merge at the top of a stack' '
- git checkout svnb1 &&
+ git checkout origin/svnb1 &&
touch anotherfile &&
git add anotherfile &&
git commit -m "a commit" &&
- git merge svnb4 &&
+ git merge origin/svnb4 &&
git svn dcommit
'
diff --git a/t/t9163-git-svn-reset-clears-caches.sh b/t/t9163-git-svn-reset-clears-caches.sh
index cd4c662..d6245ce 100755
--- a/t/t9163-git-svn-reset-clears-caches.sh
+++ b/t/t9163-git-svn-reset-clears-caches.sh
@@ -70,9 +70,9 @@ test_expect_success 'rebase looses SVN merge (m)' '
#
test_expect_success 'reset and fetch gets the SVN merge (m) correctly' '
git svn reset -r 3 &&
- git reset --hard trunk &&
+ git reset --hard origin/trunk &&
git svn fetch &&
- test 2 = $(git cat-file -p trunk|grep parent|wc -l)
+ test 2 = $(git cat-file -p origin/trunk|grep parent|wc -l)
'
test_done
diff --git a/t/t9165-git-svn-fetch-merge-branch-of-branch.sh b/t/t9165-git-svn-fetch-merge-branch-of-branch.sh
index 13ae7e3..fa3ef3b 100755
--- a/t/t9165-git-svn-fetch-merge-branch-of-branch.sh
+++ b/t/t9165-git-svn-fetch-merge-branch-of-branch.sh
@@ -53,7 +53,7 @@ test_expect_success 'clone svn repo' '
'
test_expect_success 'verify merge commit' 'x=$(git rev-parse HEAD^2) &&
- y=$(git rev-parse branch2) &&
+ y=$(git rev-parse origin/branch2) &&
test "x$x" = "x$y"
'
diff --git a/t/t9166-git-svn-fetch-merge-branch-of-branch2.sh b/t/t9166-git-svn-fetch-merge-branch-of-branch2.sh
index af0ec0e..52f2e46 100755
--- a/t/t9166-git-svn-fetch-merge-branch-of-branch2.sh
+++ b/t/t9166-git-svn-fetch-merge-branch-of-branch2.sh
@@ -46,7 +46,7 @@ test_expect_success 'clone svn repo' '
'
test_expect_success 'verify merge commit' 'x=$(git rev-parse HEAD^2) &&
- y=$(git rev-parse branch2) &&
+ y=$(git rev-parse origin/branch2) &&
test "x$x" = "x$y"
'
diff --git a/t/t9167-git-svn-cmd-branch-subproject.sh b/t/t9167-git-svn-cmd-branch-subproject.sh
index 53def87..ba35fc0 100755
--- a/t/t9167-git-svn-cmd-branch-subproject.sh
+++ b/t/t9167-git-svn-cmd-branch-subproject.sh
@@ -31,7 +31,7 @@ test_expect_success 'import into git' '
git svn init --trunk=trunk/project --branches=branches/*/project \
--tags=tags/*/project "$svnrepo" &&
git svn fetch &&
- git checkout remotes/trunk
+ git checkout remotes/origin/trunk
'
test_expect_success 'git svn branch tests' '
diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh
index 1f06e25..6146c3f 100755
--- a/t/t9400-git-cvsserver-server.sh
+++ b/t/t9400-git-cvsserver-server.sh
@@ -25,7 +25,6 @@ perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
test_done
}
-unset GIT_DIR GIT_CONFIG
WORKDIR=$(pwd)
SERVERDIR=$(pwd)/gitcvs.git
git_config="$SERVERDIR/config"
diff --git a/t/t9903-bash-prompt.sh b/t/t9903-bash-prompt.sh
index 59f875e..9150984 100755
--- a/t/t9903-bash-prompt.sh
+++ b/t/t9903-bash-prompt.sh
@@ -452,53 +452,53 @@ test_expect_success 'prompt - format string starting with dash' '
'
test_expect_success 'prompt - pc mode' '
- printf "BEFORE: (master):AFTER" >expected &&
+ printf "BEFORE: (\${__git_ps1_branch_name}):AFTER\\nmaster" >expected &&
printf "" >expected_output &&
(
__git_ps1 "BEFORE:" ":AFTER" >"$actual" &&
test_cmp expected_output "$actual" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - branch name' '
- printf "BEFORE: (${c_green}master${c_clear}):AFTER" >expected &&
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nmaster" >expected &&
(
GIT_PS1_SHOWCOLORHINTS=y &&
__git_ps1 "BEFORE:" ":AFTER" >"$actual"
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - detached head' '
- printf "BEFORE: (${c_red}(%s...)${c_clear}):AFTER" $(git log -1 --format="%h" b1^) >expected &&
+ printf "BEFORE: (${c_red}\${__git_ps1_branch_name}${c_clear}):AFTER\\n(%s...)" $(git log -1 --format="%h" b1^) >expected &&
git checkout b1^ &&
test_when_finished "git checkout master" &&
(
GIT_PS1_SHOWCOLORHINTS=y &&
__git_ps1 "BEFORE:" ":AFTER" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty worktree' '
- printf "BEFORE: (${c_green}master${c_clear} ${c_red}*${c_clear}):AFTER" >expected &&
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_clear}):AFTER\\nmaster" >expected &&
echo "dirty" >file &&
test_when_finished "git reset --hard" &&
(
GIT_PS1_SHOWDIRTYSTATE=y &&
GIT_PS1_SHOWCOLORHINTS=y &&
__git_ps1 "BEFORE:" ":AFTER" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index' '
- printf "BEFORE: (${c_green}master${c_clear} ${c_green}+${c_clear}):AFTER" >expected &&
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
echo "dirty" >file &&
test_when_finished "git reset --hard" &&
git add -u &&
@@ -506,13 +506,13 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirt
GIT_PS1_SHOWDIRTYSTATE=y &&
GIT_PS1_SHOWCOLORHINTS=y &&
__git_ps1 "BEFORE:" ":AFTER" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirty index and worktree' '
- printf "BEFORE: (${c_green}master${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER" >expected &&
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}*${c_green}+${c_clear}):AFTER\\nmaster" >expected &&
echo "dirty index" >file &&
test_when_finished "git reset --hard" &&
git add -u &&
@@ -521,25 +521,25 @@ test_expect_success 'prompt - bash color pc mode - dirty status indicator - dirt
GIT_PS1_SHOWCOLORHINTS=y &&
GIT_PS1_SHOWDIRTYSTATE=y &&
__git_ps1 "BEFORE:" ":AFTER" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - dirty status indicator - before root commit' '
- printf "BEFORE: (${c_green}master${c_clear} ${c_green}#${c_clear}):AFTER" >expected &&
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_green}#${c_clear}):AFTER\\nmaster" >expected &&
(
GIT_PS1_SHOWDIRTYSTATE=y &&
GIT_PS1_SHOWCOLORHINTS=y &&
cd otherrepo &&
__git_ps1 "BEFORE:" ":AFTER" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - inside .git directory' '
- printf "BEFORE: (${c_green}GIT_DIR!${c_clear}):AFTER" >expected &&
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear}):AFTER\\nGIT_DIR!" >expected &&
echo "dirty" >file &&
test_when_finished "git reset --hard" &&
(
@@ -547,13 +547,13 @@ test_expect_success 'prompt - bash color pc mode - inside .git directory' '
GIT_PS1_SHOWCOLORHINTS=y &&
cd .git &&
__git_ps1 "BEFORE:" ":AFTER" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - stash status indicator' '
- printf "BEFORE: (${c_green}master${c_clear} ${c_lblue}\$${c_clear}):AFTER" >expected &&
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_lblue}\$${c_clear}):AFTER\\nmaster" >expected &&
echo 2 >file &&
git stash &&
test_when_finished "git stash drop" &&
@@ -561,18 +561,18 @@ test_expect_success 'prompt - bash color pc mode - stash status indicator' '
GIT_PS1_SHOWSTASHSTATE=y &&
GIT_PS1_SHOWCOLORHINTS=y &&
__git_ps1 "BEFORE:" ":AFTER" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
test_expect_success 'prompt - bash color pc mode - untracked files status indicator' '
- printf "BEFORE: (${c_green}master${c_clear} ${c_red}%%${c_clear}):AFTER" >expected &&
+ printf "BEFORE: (${c_green}\${__git_ps1_branch_name}${c_clear} ${c_red}%%${c_clear}):AFTER\\nmaster" >expected &&
(
GIT_PS1_SHOWUNTRACKEDFILES=y &&
GIT_PS1_SHOWCOLORHINTS=y &&
__git_ps1 "BEFORE:" ":AFTER" &&
- printf "%s" "$PS1" >"$actual"
+ printf "%s\\n%s" "$PS1" "${__git_ps1_branch_name}" >"$actual"
) &&
test_cmp expected "$actual"
'
@@ -582,7 +582,7 @@ test_expect_success 'prompt - zsh color pc mode' '
(
ZSH_VERSION=5.0.0 &&
GIT_PS1_SHOWCOLORHINTS=y &&
- __git_ps1 "BEFORE:" ":AFTER" >"$actual"
+ __git_ps1 "BEFORE:" ":AFTER" &&
printf "%s" "$PS1" >"$actual"
) &&
test_cmp expected "$actual"
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index aeae3ca..158e10a 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -32,6 +32,11 @@ test_set_editor () {
export EDITOR
}
+test_set_index_version () {
+ GIT_INDEX_VERSION="$1"
+ export GIT_INDEX_VERSION
+}
+
test_decode_color () {
awk '
function name(n) {
@@ -716,6 +721,64 @@ perl () {
command "$PERL_PATH" "$@"
}
+# Is the value one of the various ways to spell a boolean true/false?
+test_normalize_bool () {
+ git -c magic.variable="$1" config --bool magic.variable 2>/dev/null
+}
+
+# Given a variable $1, normalize the value of it to one of "true",
+# "false", or "auto" and store the result to it.
+#
+# test_tristate GIT_TEST_HTTPD
+#
+# A variable set to an empty string is set to 'false'.
+# A variable set to 'false' or 'auto' keeps its value.
+# Anything else is set to 'true'.
+# An unset variable defaults to 'auto'.
+#
+# The last rule is to allow people to set the variable to an empty
+# string and export it to decline testing the particular feature
+# for versions both before and after this change. We used to treat
+# both unset and empty variable as a signal for "do not test" and
+# took any non-empty string as "please test".
+
+test_tristate () {
+ if eval "test x\"\${$1+isset}\" = xisset"
+ then
+ # explicitly set
+ eval "
+ case \"\$$1\" in
+ '') $1=false ;;
+ auto) ;;
+ *) $1=\$(test_normalize_bool \$$1 || echo true) ;;
+ esac
+ "
+ else
+ eval "$1=auto"
+ fi
+}
+
+# Exit the test suite, either by skipping all remaining tests or by
+# exiting with an error. If "$1" is "auto", we then we assume we were
+# opportunistically trying to set up some tests and we skip. If it is
+# "true", then we report a failure.
+#
+# The error/skip message should be given by $2.
+#
+test_skip_or_die () {
+ case "$1" in
+ auto)
+ skip_all=$2
+ test_done
+ ;;
+ true)
+ error "$2"
+ ;;
+ *)
+ error "BUG: test tristate is '$1' (real error: $2)"
+ esac
+}
+
# The following mingw_* functions obey POSIX shell syntax, but are actually
# bash scripts, and are meant to be used only with bash on Windows.
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 3c7cb1d..c081668 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -108,6 +108,12 @@ export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
export EDITOR
+if test -n "${TEST_GIT_INDEX_VERSION:+isset}"
+then
+ GIT_INDEX_VERSION="$TEST_GIT_INDEX_VERSION"
+ export GIT_INDEX_VERSION
+fi
+
# Add libc MALLOC and MALLOC_PERTURB test
# only if we are not executing the test with valgrind
if expr " $GIT_TEST_OPTS " : ".* --valgrind " >/dev/null ||
@@ -649,7 +655,6 @@ else # normal case, use ../bin-wrappers only unless $with_dashes:
fi
fi
GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
-unset GIT_CONFIG
GIT_CONFIG_NOSYSTEM=1
GIT_ATTR_NOSYSTEM=1
export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM