summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/README28
-rw-r--r--t/annotate-tests.sh13
-rw-r--r--t/gitweb-lib.sh7
-rw-r--r--t/lib-httpd.sh2
-rw-r--r--t/lib-terminal.sh22
-rwxr-xr-xt/t0000-basic.sh10
-rwxr-xr-xt/t0001-init.sh53
-rwxr-xr-xt/t0006-date.sh1
-rwxr-xr-xt/t0040-parse-options.sh2
-rwxr-xr-xt/t0070-fundamental.sh13
-rwxr-xr-xt/t0080-vcs-svn.sh54
-rwxr-xr-xt/t0081-line-buffer.sh90
-rwxr-xr-xt/t1007-hash-object.sh13
-rwxr-xr-xt/t1021-rerere-in-workdir.sh55
-rwxr-xr-xt/t1200-tutorial.sh5
-rwxr-xr-xt/t1300-repo-config.sh22
-rwxr-xr-xt/t1400-update-ref.sh2
-rwxr-xr-xt/t1411-reflog-show.sh18
-rwxr-xr-xt/t1501-worktree.sh9
-rwxr-xr-xt/t1506-rev-parse-diagnosis.sh20
-rwxr-xr-xt/t1510-repo-setup.sh5148
-rwxr-xr-xt/t2011-checkout-invalid-head.sh2
-rwxr-xr-xt/t2019-checkout-ambiguous-ref.sh59
-rwxr-xr-xt/t2020-checkout-detach.sh142
-rwxr-xr-xt/t2021-checkout-overwrite.sh50
-rwxr-xr-xt/t2200-add-update.sh26
-rwxr-xr-xt/t2201-add-update-typechange.sh2
-rwxr-xr-xt/t2204-add-ignored.sh37
-rwxr-xr-xt/t3030-merge-recursive.sh2
-rwxr-xr-xt/t3032-merge-recursive-options.sh14
-rwxr-xr-xt/t3200-branch.sh20
-rwxr-xr-xt/t3203-branch-output.sh2
-rwxr-xr-xt/t3306-notes-prune.sh3
-rwxr-xr-xt/t3409-rebase-preserve-merges.sh32
-rwxr-xr-xt/t3501-revert-cherry-pick.sh2
-rwxr-xr-xt/t3503-cherry-pick-root.sh27
-rwxr-xr-xt/t3507-cherry-pick-conflict.sh152
-rwxr-xr-xt/t3509-cherry-pick-merge-df.sh6
-rwxr-xr-xt/t3600-rm.sh3
-rwxr-xr-xt/t3700-add.sh13
-rwxr-xr-xt/t3701-add-interactive.sh41
-rwxr-xr-xt/t3903-stash.sh63
-rwxr-xr-xt/t3904-stash-patch.sh12
-rwxr-xr-xt/t4001-diff-rename.sh4
-rwxr-xr-xt/t4002-diff-basic.sh5
-rwxr-xr-xt/t4003-diff-rename-1.sh2
-rwxr-xr-xt/t4004-diff-rename-symlink.sh2
-rwxr-xr-xt/t4005-diff-rename-2.sh2
-rwxr-xr-xt/t4008-diff-break-rewrite.sh4
-rwxr-xr-xt/t4009-diff-rename-4.sh2
-rwxr-xr-xt/t4010-diff-pathspec.sh32
-rwxr-xr-xt/t4013-diff-various.sh41
-rw-r--r--t/t4013/diff.diff_--cached38
-rw-r--r--t/t4013/diff.diff_--cached_--_file015
-rw-r--r--t/t4013/diff.diff_--dirstat-by-file_initial_rearrange3
-rw-r--r--t/t4013/diff.diff_--dirstat_initial_rearrange3
-rw-r--r--t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^2
-rw-r--r--t/t4013/diff.log_--decorate=full_--all6
-rw-r--r--t/t4013/diff.log_--decorate_--all6
-rw-r--r--t/t4013/diff.log_-SF_master_--max-count=02
-rw-r--r--t/t4013/diff.log_-SF_master_--max-count=17
-rw-r--r--t/t4013/diff.log_-SF_master_--max-count=27
-rwxr-xr-xt/t4014-format-patch.sh128
-rwxr-xr-xt/t4020-diff-external.sh2
-rwxr-xr-xt/t4027-diff-submodule.sh1
-rwxr-xr-xt/t4031-diff-rewrite-binary.sh7
-rwxr-xr-xt/t4040-whitespace-status.sh7
-rwxr-xr-xt/t4046-diff-unmerged.sh87
-rwxr-xr-xt/t4120-apply-popt.sh9
-rwxr-xr-xt/t4204-patch-id.sh36
-rwxr-xr-xt/t5304-prune.sh3
-rwxr-xr-xt/t5400-send-pack.sh4
-rwxr-xr-xt/t5501-fetch-push-alternates.sh66
-rwxr-xr-xt/t5505-remote.sh78
-rwxr-xr-xt/t5520-pull.sh11
-rwxr-xr-xt/t5526-fetch-submodules.sh297
-rwxr-xr-xt/t5532-fetch-proxy.sh43
-rwxr-xr-xt/t5541-http-push.sh7
-rwxr-xr-xt/t5601-clone.sh16
-rwxr-xr-xt/t5701-clone-local.sh13
-rwxr-xr-xt/t6000-rev-list-misc.sh51
-rwxr-xr-xt/t6004-rev-list-path-optim.sh69
-rwxr-xr-xt/t6007-rev-list-cherry-pick-file.sh113
-rwxr-xr-xt/t6009-rev-list-parent.sh118
-rwxr-xr-xt/t6017-rev-list-stdin.sh17
-rwxr-xr-xt/t6035-merge-dir-to-symlink.sh14
-rwxr-xr-xt/t6040-tracking-info.sh18
-rwxr-xr-xt/t6060-merge-index.sh100
-rwxr-xr-xt/t6110-rev-list-sparse.sh20
-rwxr-xr-xt/t6120-describe.sh2
-rwxr-xr-xt/t7004-tag.sh1
-rwxr-xr-xt/t7011-skip-worktree-reading.sh4
-rwxr-xr-xt/t7012-skip-worktree-writing.sh6
-rwxr-xr-xt/t7060-wtstatus.sh64
-rwxr-xr-xt/t7102-reset.sh2
-rwxr-xr-xt/t7110-reset-merge.sh6
-rwxr-xr-xt/t7201-co.sh26
-rwxr-xr-xt/t7300-clean.sh13
-rwxr-xr-xt/t7403-submodule-sync.sh2
-rwxr-xr-xt/t7405-submodule-merge.sh58
-rwxr-xr-xt/t7406-submodule-update.sh72
-rwxr-xr-xt/t7407-submodule-foreach.sh4
-rwxr-xr-xt/t7500-commit.sh29
-rwxr-xr-xt/t7501-commit.sh7
-rwxr-xr-xt/t7502-commit.sh60
-rwxr-xr-xt/t7505-prepare-commit-msg-hook.sh12
-rwxr-xr-xt/t7506-status-submodule.sh28
-rwxr-xr-xt/t7508-status.sh115
-rwxr-xr-xt/t7509-commit.sh29
-rwxr-xr-xt/t7600-merge.sh34
-rwxr-xr-xt/t7607-merge-overwrite.sh33
-rwxr-xr-xt/t7610-mergetool.sh324
-rwxr-xr-xt/t7611-merge-abort.sh20
-rwxr-xr-xt/t7810-grep.sh47
-rwxr-xr-xt/t7811-grep-open.sh2
-rwxr-xr-xt/t8001-annotate.sh11
-rwxr-xr-xt/t8002-blame.sh2
-rwxr-xr-xt/t8006-blame-textconv.sh3
-rwxr-xr-xt/t9010-svn-fe.sh811
-rwxr-xr-xt/t9116-git-svn-log.sh15
-rwxr-xr-xt/t9130-git-svn-authors-file.sh1
-rwxr-xr-xt/t9300-fast-import.sh189
-rwxr-xr-xt/t9301-fast-import-notes.sh1
-rwxr-xr-xt/t9500-gitweb-standalone-no-errors.sh92
-rwxr-xr-xt/t9501-gitweb-standalone-http-status.sh1
-rwxr-xr-xt/t9700/test.pl10
-rwxr-xr-xt/t9800-git-p4.sh139
-rw-r--r--t/test-lib.sh58
-rw-r--r--t/valgrind/default.supp6
129 files changed, 5130 insertions, 5024 deletions
diff --git a/t/README b/t/README
index 892d443f63..428ee05c4a 100644
--- a/t/README
+++ b/t/README
@@ -79,6 +79,10 @@ appropriately before running "make".
--debug::
This may help the person who is developing a new test.
It causes the command defined with test_debug to run.
+ The "trash" directory (used to store all temporary data
+ during testing) is not deleted even if there are no
+ failed tests so that you can inspect its contents after
+ the test finished.
--immediate::
This causes the test to immediately exit upon the first
@@ -98,6 +102,13 @@ appropriately before running "make".
not see any output, this option implies --verbose. For
convenience, it also implies --tee.
+ Note that valgrind is run with the option --leak-check=no,
+ as the git process is short-lived and some errors are not
+ interesting. In order to run a single command under the same
+ conditions manually, you should set GIT_VALGRIND to point to
+ the 't/valgrind/' directory and use the commands under
+ 't/valgrind/bin/'.
+
--tee::
In addition to printing the test output to the terminal,
write it to files named 't/test-results/$TEST_NAME.out'.
@@ -190,7 +201,7 @@ we are testing.
If you create files under t/ directory (i.e. here) that is not
the top-level test script, never name the file to match the above
pattern. The Makefile here considers all such files as the
-top-level test script and tries to run all of them. A care is
+top-level test script and tries to run all of them. Care is
especially needed if you are creating a common test library
file, similar to test-lib.sh, because such a library file may
not be suitable for standalone execution.
@@ -274,15 +285,20 @@ Do:
- Check the test coverage for your tests. See the "Test coverage"
below.
- Don't blindly follow test coverage metrics, they're a good way to
- spot if you've missed something. If a new function you added
- doesn't have any coverage you're probably doing something wrong,
+ Don't blindly follow test coverage metrics; if a new function you added
+ doesn't have any coverage, then you're probably doing something wrong,
but having 100% coverage doesn't necessarily mean that you tested
everything.
Tests that are likely to smoke out future regressions are better
than tests that just inflate the coverage metrics.
+ - When a test checks for an absolute path that a git command generated,
+ construct the expected value using $(pwd) rather than $PWD,
+ $TEST_DIRECTORY, or $TRASH_DIRECTORY. It makes a difference on
+ Windows, where the shell (MSYS bash) mangles absolute path names.
+ For details, see the commit message of 4114156ae9.
+
Don't:
- exit() within a <script> part.
@@ -322,7 +338,7 @@ Keep in mind:
Skipping tests
--------------
-If you need to skip tests you should do so be using the three-arg form
+If you need to skip tests you should do so by using the three-arg form
of the test_* functions (see the "Test harness library" section
below), e.g.:
@@ -414,7 +430,7 @@ library for your script to use.
- test_tick
Make commit and tag names consistent by setting the author and
- committer times to defined stated. Subsequent calls will
+ committer times to defined state. Subsequent calls will
advance the times by a fixed amount.
- test_commit <message> [<filename> [<contents>]]
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index d34208cc27..c56a77d237 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -1,5 +1,5 @@
# This file isn't used as a test script directly, instead it is
-# sourced from t8001-annotate.sh and t8001-blame.sh.
+# sourced from t8001-annotate.sh and t8002-blame.sh.
check_count () {
head=
@@ -124,3 +124,14 @@ test_expect_success \
test_expect_success \
'some edit' \
'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1'
+
+test_expect_success \
+ 'an obfuscated email added' \
+ 'echo "No robots allowed" > file.new &&
+ cat file >> file.new &&
+ mv file.new file &&
+ GIT_AUTHOR_NAME="E" GIT_AUTHOR_EMAIL="E at test dot git" git commit -a -m "norobots"'
+
+test_expect_success \
+ 'obfuscated email parsed' \
+ 'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1'
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
index b9bb95feaa..143eb1f240 100644
--- a/t/gitweb-lib.sh
+++ b/t/gitweb-lib.sh
@@ -82,7 +82,12 @@ gitweb_run () {
}
close O;
' gitweb.output &&
- if grep '^[[]' gitweb.log >/dev/null 2>&1; then false; else true; fi
+ if grep '^[[]' gitweb.log >/dev/null 2>&1; then
+ test_debug 'cat gitweb.log >&2' &&
+ false
+ else
+ true
+ fi
# gitweb.log is left for debugging
# gitweb.output is used to parse HTTP output
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 3f24384371..d3829b8d0a 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -157,7 +157,7 @@ test_http_push_nonff() {
grep "^ ! \[rejected\][ ]*$BRANCH -> $BRANCH (non-fast-forward)$" output
'
- test_expect_success 'non-fast-forward push shows help message' '
+ test_expect_success C_LOCALE_OUTPUT 'non-fast-forward push shows help message' '
grep "To prevent you from losing history, non-fast-forward updates were rejected" \
output
'
diff --git a/t/lib-terminal.sh b/t/lib-terminal.sh
index c383b57ed9..58d911d21b 100644
--- a/t/lib-terminal.sh
+++ b/t/lib-terminal.sh
@@ -1,8 +1,24 @@
#!/bin/sh
-test_expect_success 'set up terminal for tests' '
- if
- test_have_prereq PERL &&
+test_expect_success PERL 'set up terminal for tests' '
+ # Reading from the pty master seems to get stuck _sometimes_
+ # on Mac OS X 10.5.0, using Perl 5.10.0 or 5.8.9.
+ #
+ # Reproduction recipe: run
+ #
+ # i=0
+ # while ./test-terminal.perl echo hi $i
+ # do
+ # : $((i = $i + 1))
+ # done
+ #
+ # After 2000 iterations or so it hangs.
+ # https://rt.cpan.org/Ticket/Display.html?id=65692
+ #
+ if test "$(uname -s)" = Darwin
+ then
+ :
+ elif
"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
sh -c "test -t 1 && test -t 2"
then
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 8deec75c3a..f4e8f43bae 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -435,7 +435,7 @@ test_expect_success 'update-index D/F conflict' '
test $numpath0 = 1
'
-test_expect_success SYMLINKS 'absolute path works as expected' '
+test_expect_success SYMLINKS 'real path works as expected' '
mkdir first &&
ln -s ../.git first/.git &&
mkdir second &&
@@ -443,14 +443,14 @@ test_expect_success SYMLINKS 'absolute path works as expected' '
mkdir third &&
dir="$(cd .git; pwd -P)" &&
dir2=third/../second/other/.git &&
- test "$dir" = "$(test-path-utils make_absolute_path $dir2)" &&
+ test "$dir" = "$(test-path-utils real_path $dir2)" &&
file="$dir"/index &&
- test "$file" = "$(test-path-utils make_absolute_path $dir2/index)" &&
+ test "$file" = "$(test-path-utils real_path $dir2/index)" &&
basename=blub &&
- test "$dir/$basename" = "$(cd .git && test-path-utils make_absolute_path "$basename")" &&
+ test "$dir/$basename" = "$(cd .git && test-path-utils real_path "$basename")" &&
ln -s ../first/file .git/syml &&
sym="$(cd first; pwd -P)"/file &&
- test "$sym" = "$(test-path-utils make_absolute_path "$dir2/syml")"
+ test "$sym" = "$(test-path-utils real_path "$dir2/syml")"
'
test_expect_success 'very long name in the index handled sanely' '
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index f684993211..37c22516ff 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -47,7 +47,7 @@ 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 GIT_CONFIG_NOGLOBAL &&
+ sane_unset GIT_DIR GIT_WORK_TREE &&
HOME=$(pwd)/alias-config &&
export HOME &&
mkdir alias-config &&
@@ -180,7 +180,7 @@ test_expect_success 'GIT_DIR & GIT_WORK_TREE (2)' '
fi
'
-test_expect_success 'reinit' '
+test_expect_success C_LOCALE_OUTPUT 'reinit' '
(
sane_unset GIT_CONFIG GIT_WORK_TREE GIT_CONFIG &&
@@ -231,7 +231,6 @@ test_expect_success 'init with init.templatedir set' '
git config -f "$test_config" init.templatedir "${HOME}/templatedir-source" &&
mkdir templatedir-set &&
cd templatedir-set &&
- sane_unset GIT_CONFIG_NOGLOBAL &&
sane_unset GIT_TEMPLATE_DIR &&
NO_SET_GIT_TEMPLATE_DIR=t &&
export NO_SET_GIT_TEMPLATE_DIR &&
@@ -243,7 +242,6 @@ test_expect_success 'init with init.templatedir set' '
test_expect_success 'init --bare/--shared overrides system/global config' '
(
test_config="$HOME"/.gitconfig &&
- sane_unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" core.bare false &&
git config -f "$test_config" core.sharedRepository 0640 &&
mkdir init-bare-shared-override &&
@@ -258,7 +256,6 @@ test_expect_success 'init --bare/--shared overrides system/global config' '
test_expect_success 'init honors global core.sharedRepository' '
(
test_config="$HOME"/.gitconfig &&
- sane_unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" core.sharedRepository 0666 &&
mkdir shared-honor-global &&
cd shared-honor-global &&
@@ -374,4 +371,50 @@ test_expect_success 'init prefers command line to GIT_DIR' '
! test -d otherdir/refs
'
+test_expect_success 'init with separate gitdir' '
+ rm -rf newdir &&
+ git init --separate-git-dir realgitdir newdir &&
+ echo "gitdir: `pwd`/realgitdir" >expected &&
+ test_cmp expected newdir/.git &&
+ test -d realgitdir/refs
+'
+
+test_expect_success 're-init to update git link' '
+ (
+ cd newdir &&
+ git init --separate-git-dir ../surrealgitdir
+ ) &&
+ echo "gitdir: `pwd`/surrealgitdir" >expected &&
+ test_cmp expected newdir/.git &&
+ test -d surrealgitdir/refs &&
+ ! test -d realgitdir/refs
+'
+
+test_expect_success 're-init to move gitdir' '
+ rm -rf newdir realgitdir surrealgitdir &&
+ git init newdir &&
+ (
+ cd newdir &&
+ git init --separate-git-dir ../realgitdir
+ ) &&
+ echo "gitdir: `pwd`/realgitdir" >expected &&
+ test_cmp expected newdir/.git &&
+ test -d realgitdir/refs
+'
+
+test_expect_success SYMLINKS 're-init to move gitdir symlink' '
+ rm -rf newdir realgitdir &&
+ git init newdir &&
+ (
+ cd newdir &&
+ mv .git here &&
+ ln -s here .git &&
+ git init --separate-git-dir ../realgitdir
+ ) &&
+ echo "gitdir: `pwd`/realgitdir" >expected &&
+ test_cmp expected newdir/.git &&
+ test -d realgitdir/refs &&
+ ! test -d newdir/here
+'
+
test_done
diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index 1d4d0a5c7d..f87abb5a06 100755
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
@@ -25,6 +25,7 @@ check_show 37500000 '1 year, 2 months ago'
check_show 55188000 '1 year, 9 months ago'
check_show 630000000 '20 years ago'
check_show 31449600 '12 months ago'
+check_show 62985600 '2 years ago'
check_parse() {
echo "$1 -> $2" >expect
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 20924506af..ae266147b6 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -19,7 +19,7 @@ usage: test-parse-options <options>
--set23 set integer to 23
-t <time> get timestamp of <time>
-L, --length <str> get length of <str>
- -F, --file <FILE> set file to <FILE>
+ -F, --file <file> set file to <file>
String options
-s, --string <string>
diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
index 680d7d6861..9bee8bfd2e 100755
--- a/t/t0070-fundamental.sh
+++ b/t/t0070-fundamental.sh
@@ -12,4 +12,17 @@ test_expect_success 'character classes (isspace, isalpha etc.)' '
test-ctype
'
+test_expect_success 'mktemp to nonexistent directory prints filename' '
+ test_must_fail test-mktemp doesnotexist/testXXXXXX 2>err &&
+ grep "doesnotexist/test" err
+'
+
+test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' '
+ mkdir cannotwrite &&
+ chmod -w cannotwrite &&
+ test_when_finished "chmod +w cannotwrite" &&
+ test_must_fail test-mktemp cannotwrite/testXXXXXX 2>err &&
+ grep "cannotwrite/test" err
+'
+
test_done
diff --git a/t/t0080-vcs-svn.sh b/t/t0080-vcs-svn.sh
index d3225ada68..99a314b080 100755
--- a/t/t0080-vcs-svn.sh
+++ b/t/t0080-vcs-svn.sh
@@ -76,60 +76,6 @@ test_expect_success 'obj pool: high-water mark' '
test_cmp expected actual
'
-test_expect_success 'line buffer' '
- echo HELLO >expected1 &&
- printf "%s\n" "" HELLO >expected2 &&
- echo >expected3 &&
- printf "%s\n" "" Q | q_to_nul >expected4 &&
- printf "%s\n" foo "" >expected5 &&
- printf "%s\n" "" foo >expected6 &&
-
- test-line-buffer <<-\EOF >actual1 &&
- 5
- HELLO
- EOF
-
- test-line-buffer <<-\EOF >actual2 &&
- 0
-
- 5
- HELLO
- EOF
-
- q_to_nul <<-\EOF |
- 1
- Q
- EOF
- test-line-buffer >actual3 &&
-
- q_to_nul <<-\EOF |
- 0
-
- 1
- Q
- EOF
- test-line-buffer >actual4 &&
-
- test-line-buffer <<-\EOF >actual5 &&
- 5
- foo
- EOF
-
- test-line-buffer <<-\EOF >actual6 &&
- 0
-
- 5
- foo
- EOF
-
- test_cmp expected1 actual1 &&
- test_cmp expected2 actual2 &&
- test_cmp expected3 actual3 &&
- test_cmp expected4 actual4 &&
- test_cmp expected5 actual5 &&
- test_cmp expected6 actual6
-'
-
test_expect_success 'string pool' '
echo a does not equal b >expected.differ &&
echo a equals a >expected.match &&
diff --git a/t/t0081-line-buffer.sh b/t/t0081-line-buffer.sh
new file mode 100755
index 0000000000..bd83ed371a
--- /dev/null
+++ b/t/t0081-line-buffer.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+test_description="Test the svn importer's input handling routines.
+
+These tests provide some simple checks that the line_buffer API
+behaves as advertised.
+
+While at it, check that input of newlines and null bytes are handled
+correctly.
+"
+. ./test-lib.sh
+
+test_expect_success 'hello world' '
+ echo ">HELLO" >expect &&
+ test-line-buffer <<-\EOF >actual &&
+ binary 6
+ HELLO
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success '0-length read, send along greeting' '
+ echo ">HELLO" >expect &&
+ test-line-buffer <<-\EOF >actual &&
+ binary 0
+ copy 6
+ HELLO
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'read from file descriptor' '
+ rm -f input &&
+ echo hello >expect &&
+ echo hello >input &&
+ echo copy 6 |
+ test-line-buffer "&4" 4<input >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'skip, copy null byte' '
+ echo Q | q_to_nul >expect &&
+ q_to_nul <<-\EOF | test-line-buffer >actual &&
+ skip 2
+ Q
+ copy 2
+ Q
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'read null byte' '
+ echo ">QhelloQ" | q_to_nul >expect &&
+ q_to_nul <<-\EOF | test-line-buffer >actual &&
+ binary 8
+ QhelloQ
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'long reads are truncated' '
+ echo ">foo" >expect &&
+ test-line-buffer <<-\EOF >actual &&
+ binary 5
+ foo
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'long copies are truncated' '
+ printf "%s\n" ">" foo >expect &&
+ test-line-buffer <<-\EOF >actual &&
+ binary 1
+
+ copy 5
+ foo
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'long binary reads are truncated' '
+ echo ">foo" >expect &&
+ test-line-buffer <<-\EOF >actual &&
+ binary 5
+ foo
+ EOF
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh
index dd32432d62..6d52b824b1 100755
--- a/t/t1007-hash-object.sh
+++ b/t/t1007-hash-object.sh
@@ -188,4 +188,17 @@ for args in "-w --stdin-paths" "--stdin-paths -w"; do
pop_repo
done
+test_expect_success 'corrupt tree' '
+ echo abc >malformed-tree
+ test_must_fail git hash-object -t tree malformed-tree
+'
+
+test_expect_success 'corrupt commit' '
+ test_must_fail git hash-object -t commit --stdin </dev/null
+'
+
+test_expect_success 'corrupt tag' '
+ test_must_fail git hash-object -t tag --stdin </dev/null
+'
+
test_done
diff --git a/t/t1021-rerere-in-workdir.sh b/t/t1021-rerere-in-workdir.sh
new file mode 100755
index 0000000000..301e071ff7
--- /dev/null
+++ b/t/t1021-rerere-in-workdir.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+test_description='rerere run in a workdir'
+. ./test-lib.sh
+
+test_expect_success SYMLINKS setup '
+ git config rerere.enabled true &&
+ >world &&
+ git add world &&
+ test_tick &&
+ git commit -m initial &&
+
+ echo hello >world &&
+ test_tick &&
+ git commit -a -m hello &&
+
+ git checkout -b side HEAD^ &&
+ echo goodbye >world &&
+ test_tick &&
+ git commit -a -m goodbye &&
+
+ git checkout master
+'
+
+test_expect_success SYMLINKS 'rerere in workdir' '
+ rm -rf .git/rr-cache &&
+ "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" . work &&
+ (
+ cd work &&
+ test_must_fail git merge side &&
+ git rerere status >actual &&
+ echo world >expect &&
+ test_cmp expect actual
+ )
+'
+
+# This fails because we don't resolve relative symlink in mkdir_in_gitdir()
+# For the purpose of helping contrib/workdir/git-new-workdir users, we do not
+# have to support relative symlinks, but it might be nicer to make this work
+# with a relative symbolic link someday.
+test_expect_failure SYMLINKS 'rerere in workdir (relative)' '
+ rm -rf .git/rr-cache &&
+ "$SHELL_PATH" "$TEST_DIRECTORY/../contrib/workdir/git-new-workdir" . krow &&
+ (
+ cd krow &&
+ rm -f .git/rr-cache &&
+ ln -s ../.git/rr-cache .git/rr-cache &&
+ test_must_fail git merge side &&
+ git rerere status >actual &&
+ echo world >expect &&
+ test_cmp expect actual
+ )
+'
+
+test_done
diff --git a/t/t1200-tutorial.sh b/t/t1200-tutorial.sh
index bfa2c2190d..3264fefbad 100755
--- a/t/t1200-tutorial.sh
+++ b/t/t1200-tutorial.sh
@@ -163,7 +163,10 @@ test_expect_success 'git resolve' '
git checkout mybranch &&
git merge -m "Merge upstream changes." master |
sed -e "1s/[0-9a-f]\{7\}/VARIABLE/g" \
- -e "s/^Fast[- ]forward /FASTFORWARD /" >resolve.output &&
+ -e "s/^Fast[- ]forward /FASTFORWARD /" >resolve.output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'git resolve output' '
test_cmp resolve.expect resolve.output
'
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index d0e55465ff..53fb8228cf 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -876,11 +876,25 @@ test_expect_success 'check split_cmdline return' "
"
test_expect_success 'git -c "key=value" support' '
- test "z$(git -c name=value config name)" = zvalue &&
test "z$(git -c core.name=value config core.name)" = zvalue &&
- test "z$(git -c CamelCase=value config camelcase)" = zvalue &&
- test "z$(git -c flag config --bool flag)" = ztrue &&
- test_must_fail git -c core.name=value config name
+ test "z$(git -c foo.CamelCase=value config foo.camelcase)" = zvalue &&
+ test "z$(git -c foo.flag config --bool foo.flag)" = ztrue &&
+ test_must_fail git -c name=value config core.name
+'
+
+test_expect_success 'key sanity-checking' '
+ test_must_fail git config foo=bar &&
+ test_must_fail git config foo=.bar &&
+ test_must_fail git config foo.ba=r &&
+ test_must_fail git config foo.1bar &&
+ test_must_fail git config foo."ba
+ z".bar &&
+ test_must_fail git config . false &&
+ test_must_fail git config .foo false &&
+ test_must_fail git config foo. false &&
+ test_must_fail git config .foo. false &&
+ git config foo.bar true &&
+ git config foo."ba =z".bar false
'
test_done
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index ff747f8229..4fd83a667a 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -6,7 +6,7 @@
test_description='Test git update-ref and basic ref logging'
. ./test-lib.sh
-Z=0000000000000000000000000000000000000000
+Z=$_z40
test_expect_success setup '
diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh
index ba25ff354d..caa687b5b4 100755
--- a/t/t1411-reflog-show.sh
+++ b/t/t1411-reflog-show.sh
@@ -28,6 +28,24 @@ test_expect_success 'oneline reflog format' '
test_cmp expect actual
'
+test_expect_success 'reflog default format' '
+ git reflog -1 >actual &&
+ test_cmp expect actual
+'
+
+cat >expect <<'EOF'
+commit e46513e
+Reflog: HEAD@{0} (C O Mitter <committer@example.com>)
+Reflog message: commit (initial): one
+Author: A U Thor <author@example.com>
+
+ one
+EOF
+test_expect_success 'override reflog default format' '
+ git reflog --format=short -1 >actual &&
+ test_cmp expect actual
+'
+
cat >expect <<'EOF'
Reflog: HEAD@{Thu Apr 7 15:13:13 2005 -0700} (C O Mitter <committer@example.com>)
Reflog message: commit (initial): one
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index f072a8ed48..63849836c8 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -7,7 +7,6 @@ test_expect_success 'setup' '
EMPTY_TREE=$(git write-tree) &&
EMPTY_BLOB=$(git hash-object -t blob --stdin </dev/null) &&
CHANGED_BLOB=$(echo changed | git hash-object -t blob --stdin) &&
- ZEROES=0000000000000000000000000000000000000000 &&
EMPTY_BLOB7=$(echo $EMPTY_BLOB | sed "s/\(.......\).*/\1/") &&
CHANGED_BLOB7=$(echo $CHANGED_BLOB | sed "s/\(.......\).*/\1/") &&
@@ -239,10 +238,10 @@ test_expect_success '_gently() groks relative GIT_DIR & GIT_WORK_TREE' '
test_expect_success 'diff-index respects work tree under .git dir' '
cat >diff-index-cached.expected <<-EOF &&
- :000000 100644 $ZEROES $EMPTY_BLOB A sub/dir/tracked
+ :000000 100644 $_z40 $EMPTY_BLOB A sub/dir/tracked
EOF
cat >diff-index.expected <<-EOF &&
- :000000 100644 $ZEROES $ZEROES A sub/dir/tracked
+ :000000 100644 $_z40 $_z40 A sub/dir/tracked
EOF
(
@@ -258,7 +257,7 @@ test_expect_success 'diff-index respects work tree under .git dir' '
test_expect_success 'diff-files respects work tree under .git dir' '
cat >diff-files.expected <<-EOF &&
- :100644 100644 $EMPTY_BLOB $ZEROES M sub/dir/tracked
+ :100644 100644 $EMPTY_BLOB $_z40 M sub/dir/tracked
EOF
(
@@ -343,7 +342,7 @@ test_expect_success 'make_relative_path handles double slashes in GIT_DIR' '
test_expect_success 'relative $GIT_WORK_TREE and git subprocesses' '
GIT_DIR=repo.git GIT_WORK_TREE=repo.git/work \
test-subprocess --setup-work-tree rev-parse --show-toplevel >actual &&
- echo "$TRASH_DIRECTORY/repo.git/work" >expected &&
+ echo "$(pwd)/repo.git/work" >expected &&
test_cmp expected actual
'
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index 9f8adb1f82..0843a1c13b 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -6,6 +6,16 @@ exec </dev/null
. ./test-lib.sh
+test_did_you_mean ()
+{
+ sq="'" &&
+ cat >expected <<-EOF &&
+ fatal: Path '$2$3' $4, but not ${5:-$sq$3$sq}.
+ Did you mean '$1:$2$3'${2:+ aka $sq$1:./$3$sq}?
+ EOF
+ test_cmp expected error
+}
+
HASH_file=
test_expect_success 'set up basic repo' '
@@ -106,7 +116,7 @@ test_expect_success 'incorrect file in sha1:path' '
grep "fatal: Path '"'"'index-only.txt'"'"' exists on disk, but not in '"'"'HEAD'"'"'." error &&
(cd subdir &&
test_must_fail git rev-parse HEAD:file2.txt 2> error &&
- grep "Did you mean '"'"'HEAD:subdir/file2.txt'"'"'?" error )
+ test_did_you_mean HEAD subdir/ file2.txt exists )
'
test_expect_success 'incorrect file in :path and :N:path' '
@@ -115,14 +125,14 @@ test_expect_success 'incorrect file in :path and :N:path' '
test_must_fail git rev-parse :1:nothing.txt 2> error &&
grep "Path '"'"'nothing.txt'"'"' does not exist (neither on disk nor in the index)." error &&
test_must_fail git rev-parse :1:file.txt 2> error &&
- grep "Did you mean '"'"':0:file.txt'"'"'?" error &&
+ test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&
(cd subdir &&
test_must_fail git rev-parse :1:file.txt 2> error &&
- grep "Did you mean '"'"':0:file.txt'"'"'?" error &&
+ test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&
test_must_fail git rev-parse :file2.txt 2> error &&
- grep "Did you mean '"'"':0:subdir/file2.txt'"'"'?" error &&
+ test_did_you_mean ":0" subdir/ file2.txt "is in the index" &&
test_must_fail git rev-parse :2:file2.txt 2> error &&
- grep "Did you mean '"'"':0:subdir/file2.txt'"'"'?" error) &&
+ test_did_you_mean :0 subdir/ file2.txt "is in the index") &&
test_must_fail git rev-parse :disk-only.txt 2> error &&
grep "fatal: Path '"'"'disk-only.txt'"'"' exists on disk, but not in the index." error
'
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index c3798ce179..ec50a9ad70 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -1,4532 +1,776 @@
#!/bin/sh
-test_description='Tests of cwd/prefix/worktree/gitdir setup in all cases'
+test_description="Tests of cwd/prefix/worktree/gitdir setup in all cases
-. ./test-lib.sh
-
-#
-# A few rules for repo setup:
-#
-# 1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
-# GIT_DIR.
-#
-# 2. .git file is relative to parent directory. .git file is basically
-# symlink in disguise. The directory where .git file points to will
-# become new git_dir.
-#
-# 3. core.worktree is relative to git_dir.
-#
-# 4. GIT_WORK_TREE is relative to user's cwd. --work-tree is
-# equivalent to GIT_WORK_TREE.
-#
-# 5. GIT_WORK_TREE/core.worktree is only effective if GIT_DIR is set
-# Uneffective worktree settings should be warned.
-#
-# 6. Effective GIT_WORK_TREE overrides core.worktree and core.bare
-#
-# 7. Effective core.worktree conflicts with core.bare
-#
-# 8. If GIT_DIR is set but neither worktree nor bare setting is given,
-# original cwd becomes worktree.
-#
-# 9. If .git discovery is done inside a repo, the repo becomes a bare
-# repo. .git discovery is performed if GIT_DIR is not set.
-#
-# 10. If no worktree is available, cwd remains unchanged, prefix is
-# NULL.
-#
-# 11. When user's cwd is outside worktree, cwd remains unchanged,
-# prefix is NULL.
-#
-
-test_repo() {
- (
- cd "$1" &&
- if test -n "$2"; then GIT_DIR="$2" && export GIT_DIR; fi &&
- if test -n "$3"; then GIT_WORK_TREE="$3" && export GIT_WORK_TREE; fi &&
- rm -f trace &&
- GIT_TRACE="`pwd`/trace" git symbolic-ref HEAD >/dev/null &&
- grep '^setup: ' trace >result &&
- test_cmp expected result
- )
-}
-
-# Bit 0 = GIT_WORK_TREE
-# Bit 1 = GIT_DIR
-# Bit 2 = core.worktree
-# Bit 3 = .git is a file
-# Bit 4 = bare repo
-# Case# = encoding of the above 5 bits
-
-#
-# Case #0
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# - worktree is .git's parent directory
-# - cwd is at worktree root dir
-# - prefix is calculated
-# - git_dir is set to ".git"
-# - cwd can't be outside worktree
-
-test_expect_success '#0: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 0 0/sub &&
- cd 0 && git init && cd ..
-'
-
-test_expect_success '#0: at root' '
- cat >0/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/0
-setup: cwd: $TRASH_DIRECTORY/0
-setup: prefix: (null)
-EOF
- test_repo 0
-'
-
-test_expect_success '#0: in subdir' '
- cat >0/sub/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/0
-setup: cwd: $TRASH_DIRECTORY/0
-setup: prefix: sub/
-EOF
- test_repo 0/sub
-'
-
-#
-# case #1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# GIT_WORK_TREE is ignored -> #0
-
-test_expect_success '#1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
- cd 1 &&
- git init &&
- GIT_WORK_TREE=non-existent &&
- export GIT_WORK_TREE &&
- cd ..
-'
-
-test_expect_success '#1: at root' '
- cat >1/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/1
-setup: cwd: $TRASH_DIRECTORY/1
-setup: prefix: (null)
-EOF
- test_repo 1
-'
-
-test_expect_success '#1: in subdir' '
- cat >1/sub/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/1
-setup: cwd: $TRASH_DIRECTORY/1
-setup: prefix: sub/
-EOF
- test_repo 1/sub
-'
-
-#
-# case #2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# - worktree is at original cwd
-# - cwd is unchanged
-# - prefix is NULL
-# - git_dir is set to $GIT_DIR
-# - cwd can't be outside worktree
-
-test_expect_success '#2: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 2 2/sub &&
- cd 2 && git init && cd ..
-'
-
-test_expect_success '#2: at root' '
- cat >2/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/2/.git
-setup: worktree: $TRASH_DIRECTORY/2
-setup: cwd: $TRASH_DIRECTORY/2
-setup: prefix: (null)
-EOF
- test_repo 2 "$TRASH_DIRECTORY/2/.git"
-'
-
-test_expect_success '#2: in subdir' '
- cat >2/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/2/.git
-setup: worktree: $TRASH_DIRECTORY/2/sub
-setup: cwd: $TRASH_DIRECTORY/2/sub
-setup: prefix: (null)
-EOF
- test_repo 2/sub "$TRASH_DIRECTORY/2/.git"
-'
-
-test_expect_success '#2: relative GIT_DIR at root' '
- cat >2/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/2
-setup: cwd: $TRASH_DIRECTORY/2
-setup: prefix: (null)
-EOF
- test_repo 2 .git
-'
-
-test_expect_success '#2: relative GIT_DIR in subdir' '
- cat >2/sub/expected <<EOF &&
-setup: git_dir: ../.git
-setup: worktree: $TRASH_DIRECTORY/2/sub
-setup: cwd: $TRASH_DIRECTORY/2/sub
-setup: prefix: (null)
-EOF
- test_repo 2/sub ../.git
-'
-
-#
-# case #3
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# - worktree is set to $GIT_WORK_TREE
-# - cwd is at worktree root
-# - prefix is calculated
-# - git_dir is set to $GIT_DIR
-# - cwd can be outside worktree
-
-test_expect_success '#3: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
- cd 3 && git init && cd ..
-'
-
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/3
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: (null)
-EOF
- test_repo 3 .git "$TRASH_DIRECTORY/3"
-'
-
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/3
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: (null)
-EOF
- test_repo 3 .git .
-'
+A few rules for repo setup:
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: (null)
-EOF
- test_repo 3 "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY/3"
-'
-
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: (null)
-EOF
- test_repo 3 "$TRASH_DIRECTORY/3/.git" .
-'
-
-test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: sub/sub/
-EOF
- test_repo 3/sub/sub ../../.git "$TRASH_DIRECTORY/3"
-'
-
-test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: sub/sub/
-EOF
- test_repo 3/sub/sub ../../.git ../..
-'
-
-test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >3/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: sub/
-EOF
- test_repo 3/sub "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY/3"
-'
-
-test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: sub/sub/
-EOF
- test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" ../..
-'
-
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/3/wt
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: (null)
-EOF
- test_repo 3 .git "$TRASH_DIRECTORY/3/wt"
-'
-
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/3/wt
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: (null)
-EOF
- test_repo 3 .git wt
-'
-
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3/wt
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: (null)
-EOF
- test_repo 3 "$TRASH_DIRECTORY/3/.git" wt
-'
-
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3/wt
-setup: cwd: $TRASH_DIRECTORY/3
-setup: prefix: (null)
-EOF
- test_repo 3 "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY/3/wt"
-'
-
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/3/wt
-setup: cwd: $TRASH_DIRECTORY/3/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 3/sub/sub ../../.git "$TRASH_DIRECTORY/3/wt"
-'
-
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/3/wt
-setup: cwd: $TRASH_DIRECTORY/3/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 3/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3/wt
-setup: cwd: $TRASH_DIRECTORY/3/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" ../../wt
-'
+1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
+ GIT_DIR.
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY/3/wt
-setup: cwd: $TRASH_DIRECTORY/3/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY/3/wt"
-'
+2. .git file is relative to parent directory. .git file is basically
+ symlink in disguise. The directory where .git file points to will
+ become new git_dir.
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 3/
-EOF
- test_repo 3 .git "$TRASH_DIRECTORY"
-'
+3. core.worktree is relative to git_dir.
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 3/
-EOF
- test_repo 3 .git ..
-'
+4. GIT_WORK_TREE is relative to user's cwd. --work-tree is
+ equivalent to GIT_WORK_TREE.
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 3/
-EOF
- test_repo 3 "$TRASH_DIRECTORY/3/.git" ..
-'
+5. GIT_WORK_TREE/core.worktree was originally meant to work only if
+ GIT_DIR is set, but earlier git didn't enforce it, and some scripts
+ depend on the implementation that happened to first discover .git by
+ going up from the users $cwd and then using the specified working tree
+ that may or may not have any relation to where .git was found in. This
+ historical behaviour must be kept.
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >3/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 3/
-EOF
- test_repo 3 "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY"
-'
+6. Effective GIT_WORK_TREE overrides core.worktree and core.bare
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 3/sub/sub/
-EOF
- test_repo 3/sub/sub ../../.git "$TRASH_DIRECTORY"
-'
+7. Effective core.worktree conflicts with core.bare
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 3/sub/sub/
-EOF
- test_repo 3/sub/sub ../../.git ../../..
-'
+8. If GIT_DIR is set but neither worktree nor bare setting is given,
+ original cwd becomes worktree.
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 3/sub/sub/
-EOF
- test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" ../../../
-'
+9. If .git discovery is done inside a repo, the repo becomes a bare
+ repo. .git discovery is performed if GIT_DIR is not set.
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >3/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/3/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 3/sub/sub/
-EOF
- test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY"
-'
+10. If no worktree is available, cwd remains unchanged, prefix is
+ NULL.
-#
-# case #4
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# core.worktree is ignored -> #0
+11. When user's cwd is outside worktree, cwd remains unchanged,
+ prefix is NULL.
+"
+. ./test-lib.sh
-test_expect_success '#4: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 4 4/sub &&
- cd 4 &&
- git init &&
- git config core.worktree non-existent &&
- cd ..
-'
+here=$(pwd)
-test_expect_success '#4: at root' '
- cat >4/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/4
-setup: cwd: $TRASH_DIRECTORY/4
-setup: prefix: (null)
-EOF
- test_repo 4
-'
-
-test_expect_success '#4: in subdir' '
- cat >4/sub/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/4
-setup: cwd: $TRASH_DIRECTORY/4
-setup: prefix: sub/
-EOF
- test_repo 4/sub
-'
+test_repo () {
+ (
+ cd "$1" &&
+ if test -n "$2"
+ then
+ GIT_DIR="$2" &&
+ export GIT_DIR
+ fi &&
+ if test -n "$3"
+ then
+ GIT_WORK_TREE="$3" &&
+ export GIT_WORK_TREE
+ fi &&
+ rm -f trace &&
+ GIT_TRACE_SETUP="$(pwd)/trace" git symbolic-ref HEAD >/dev/null &&
+ grep '^setup: ' trace >result &&
+ test_cmp expected result
+ )
+}
-#
-# case #5
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# GIT_WORK_TREE/core.worktree are ignored -> #0
+maybe_config () {
+ file=$1 var=$2 value=$3 &&
+ if test "$value" != unset
+ then
+ git config --file="$file" "$var" "$value"
+ fi
+}
-test_expect_success '#5: setup' '
+setup_repo () {
+ name=$1 worktreecfg=$2 gitfile=$3 barecfg=$4 &&
sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 5 5/sub &&
- cd 5 &&
- git init &&
- git config core.worktree non-existent &&
- GIT_WORK_TREE=non-existent-too &&
- export GIT_WORK_TREE &&
- cd ..
-'
-test_expect_success '#5: at root' '
- cat >5/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/5
-setup: cwd: $TRASH_DIRECTORY/5
-setup: prefix: (null)
-EOF
- test_repo 5
-'
+ git init "$name" &&
+ maybe_config "$name/.git/config" core.worktree "$worktreecfg" &&
+ maybe_config "$name/.git/config" core.bare "$barecfg" &&
+ mkdir -p "$name/sub/sub" &&
-test_expect_success '#5: in subdir' '
- cat >5/sub/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/5
-setup: cwd: $TRASH_DIRECTORY/5
-setup: prefix: sub/
-EOF
- test_repo 5/sub
-'
+ if test "${gitfile:+set}"
+ then
+ mv "$name/.git" "$name.git" &&
+ echo "gitdir: ../$name.git" >"$name/.git"
+ fi
+}
-#
-# case #6
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# - worktree is at core.worktree
-# - cwd is at worktree root
-# - prefix is calculated
-# - git_dir is at $GIT_DIR
-# - cwd can be outside worktree
+maybe_set () {
+ var=$1 value=$2 &&
+ if test "$value" != unset
+ then
+ eval "$var=\$value" &&
+ export $var
+ fi
+}
-test_expect_success '#6: setup' '
+setup_env () {
+ worktreenv=$1 gitdirenv=$2 &&
sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
- cd 6 && git init && cd ..
-'
-
-test_expect_success '#6: GIT_DIR(rel), core.worktree=.. at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/6
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
- test_repo 6 .git
-'
-
-test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/6
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
- test_repo 6 .git
-'
-
-test_expect_success '#6: GIT_DIR, core.worktree=.. at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
- test_repo 6 "$TRASH_DIRECTORY/6/.git"
-'
-
-test_expect_success '#6: GIT_DIR, core.worktree=..(rel) at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
- test_repo 6 "$TRASH_DIRECTORY/6/.git"
-'
-
-test_expect_success '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
- test_repo 6/sub/sub ../../.git
-'
-
-test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
- test_repo 6/sub/sub ../../.git
-'
-
-test_expect_success '#6: GIT_DIR, core.worktree=.. in subdir' '
- cat >6/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: sub/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
- test_repo 6/sub "$TRASH_DIRECTORY/6/.git"
-'
-
-test_expect_success '#6: GIT_DIR, core.worktree=..(rel) in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
- test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
-'
-
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/6/wt
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
- test_repo 6 .git
-'
-
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/6/wt
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
- test_repo 6 .git
-'
-
-test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6/wt
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
- test_repo 6 "$TRASH_DIRECTORY/6/.git"
-'
-
-test_expect_success '#6: GIT_DIR, core.worktree=../wt at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6/wt
-setup: cwd: $TRASH_DIRECTORY/6
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
- test_repo 6 "$TRASH_DIRECTORY/6/.git"
-'
-
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/6/wt
-setup: cwd: $TRASH_DIRECTORY/6/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
- test_repo 6/sub/sub ../../.git
-'
-
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/6/wt
-setup: cwd: $TRASH_DIRECTORY/6/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
- test_repo 6/sub/sub ../../.git
-'
-
-test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6/wt
-setup: cwd: $TRASH_DIRECTORY/6/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
- test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
-'
+ maybe_set GIT_DIR "$gitdirenv" &&
+ maybe_set GIT_WORK_TREE "$worktreeenv"
+}
-test_expect_success '#6: GIT_DIR, core.worktree=../wt in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY/6/wt
-setup: cwd: $TRASH_DIRECTORY/6/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
- test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
-'
+expect () {
+ cat >"$1/expected" <<-EOF
+ setup: git_dir: $2
+ setup: worktree: $3
+ setup: cwd: $4
+ setup: prefix: $5
+ EOF
+}
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 6/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
- test_repo 6 .git
-'
+try_case () {
+ name=$1 worktreeenv=$2 gitdirenv=$3 &&
+ setup_env "$worktreeenv" "$gitdirenv" &&
+ expect "$name" "$4" "$5" "$6" "$7" &&
+ test_repo "$name"
+}
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 6/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
- test_repo 6 .git
-'
+run_wt_tests () {
+ N=$1 gitfile=$2
+
+ absgit="$here/$N/.git"
+ dotgit=.git
+ dotdotgit=../../.git
+
+ if test "$gitfile"
+ then
+ absgit="$here/$N.git"
+ dotgit=$absgit dotdotgit=$absgit
+ fi
+
+ test_expect_success "#$N: explicit GIT_WORK_TREE and GIT_DIR at toplevel" '
+ try_case $N "$here/$N" .git \
+ "$dotgit" "$here/$N" "$here/$N" "(null)" &&
+ try_case $N . .git \
+ "$dotgit" "$here/$N" "$here/$N" "(null)" &&
+ try_case $N "$here/$N" "$here/$N/.git" \
+ "$absgit" "$here/$N" "$here/$N" "(null)" &&
+ try_case $N . "$here/$N/.git" \
+ "$absgit" "$here/$N" "$here/$N" "(null)"
+ '
+
+ test_expect_success "#$N: explicit GIT_WORK_TREE and GIT_DIR in subdir" '
+ try_case $N/sub/sub "$here/$N" ../../.git \
+ "$absgit" "$here/$N" "$here/$N" sub/sub/ &&
+ try_case $N/sub/sub ../.. ../../.git \
+ "$absgit" "$here/$N" "$here/$N" sub/sub/ &&
+ try_case $N/sub/sub "$here/$N" "$here/$N/.git" \
+ "$absgit" "$here/$N" "$here/$N" sub/sub/ &&
+ try_case $N/sub/sub ../.. "$here/$N/.git" \
+ "$absgit" "$here/$N" "$here/$N" sub/sub/
+ '
+
+ test_expect_success "#$N: explicit GIT_WORK_TREE from parent of worktree" '
+ try_case $N "$here/$N/wt" .git \
+ "$dotgit" "$here/$N/wt" "$here/$N" "(null)" &&
+ try_case $N wt .git \
+ "$dotgit" "$here/$N/wt" "$here/$N" "(null)" &&
+ try_case $N wt "$here/$N/.git" \
+ "$absgit" "$here/$N/wt" "$here/$N" "(null)" &&
+ try_case $N "$here/$N/wt" "$here/$N/.git" \
+ "$absgit" "$here/$N/wt" "$here/$N" "(null)"
+ '
+
+ test_expect_success "#$N: explicit GIT_WORK_TREE from nephew of worktree" '
+ try_case $N/sub/sub "$here/$N/wt" ../../.git \
+ "$dotdotgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&
+ try_case $N/sub/sub ../../wt ../../.git \
+ "$dotdotgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&
+ try_case $N/sub/sub ../../wt "$here/$N/.git" \
+ "$absgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&
+ try_case $N/sub/sub "$here/$N/wt" "$here/$N/.git" \
+ "$absgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)"
+ '
+
+ test_expect_success "#$N: chdir_to_toplevel uses worktree, not git dir" '
+ try_case $N "$here" .git \
+ "$absgit" "$here" "$here" $N/ &&
+ try_case $N .. .git \
+ "$absgit" "$here" "$here" $N/ &&
+ try_case $N .. "$here/$N/.git" \
+ "$absgit" "$here" "$here" $N/ &&
+ try_case $N "$here" "$here/$N/.git" \
+ "$absgit" "$here" "$here" $N/
+ '
+
+ test_expect_success "#$N: chdir_to_toplevel uses worktree (from subdir)" '
+ try_case $N/sub/sub "$here" ../../.git \
+ "$absgit" "$here" "$here" $N/sub/sub/ &&
+ try_case $N/sub/sub ../../.. ../../.git \
+ "$absgit" "$here" "$here" $N/sub/sub/ &&
+ try_case $N/sub/sub ../../../ "$here/$N/.git" \
+ "$absgit" "$here" "$here" $N/sub/sub/ &&
+ try_case $N/sub/sub "$here" "$here/$N/.git" \
+ "$absgit" "$here" "$here" $N/sub/sub/
+ '
+}
-test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 6/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
- test_repo 6 "$TRASH_DIRECTORY/6/.git"
-'
+# try_repo #c GIT_WORK_TREE GIT_DIR core.worktree .gitfile? core.bare \
+# (git dir) (work tree) (cwd) (prefix) \ <-- at toplevel
+# (git dir) (work tree) (cwd) (prefix) <-- from subdir
+try_repo () {
+ name=$1 worktreeenv=$2 gitdirenv=$3 &&
+ setup_repo "$name" "$4" "$5" "$6" &&
+ shift 6 &&
+ try_case "$name" "$worktreeenv" "$gitdirenv" \
+ "$1" "$2" "$3" "$4" &&
+ shift 4 &&
+ case "$gitdirenv" in
+ /* | ?:/* | unset) ;;
+ *)
+ gitdirenv=../$gitdirenv ;;
+ esac &&
+ try_case "$name/sub" "$worktreeenv" "$gitdirenv" \
+ "$1" "$2" "$3" "$4"
+}
-test_expect_success '#6: GIT_DIR, core.worktree=../.. at root' '
- cat >6/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 6/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
- test_repo 6 "$TRASH_DIRECTORY/6/.git"
-'
+# Bit 0 = GIT_WORK_TREE
+# Bit 1 = GIT_DIR
+# Bit 2 = core.worktree
+# Bit 3 = .git is a file
+# Bit 4 = bare repo
+# Case# = encoding of the above 5 bits
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 6/sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
- test_repo 6/sub/sub ../../.git
+test_expect_success '#0: nonbare repo, no explicit configuration' '
+ try_repo 0 unset unset unset "" unset \
+ .git "$here/0" "$here/0" "(null)" \
+ .git "$here/0" "$here/0" sub/ 2>message &&
+ ! test -s message
'
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 6/sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
- test_repo 6/sub/sub ../../.git
+test_expect_success '#1: GIT_WORK_TREE without explicit GIT_DIR is accepted' '
+ mkdir -p wt &&
+ try_repo 1 "$here" unset unset "" unset \
+ "$here/1/.git" "$here" "$here" 1/ \
+ "$here/1/.git" "$here" "$here" 1/sub/ 2>message &&
+ ! test -s message
'
-test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 6/sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
- test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
+test_expect_success '#2: worktree defaults to cwd with explicit GIT_DIR' '
+ try_repo 2 unset "$here/2/.git" unset "" unset \
+ "$here/2/.git" "$here/2" "$here/2" "(null)" \
+ "$here/2/.git" "$here/2/sub" "$here/2/sub" "(null)"
'
-test_expect_success '#6: GIT_DIR, core.worktree=../.. in subdir' '
- cat >6/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/6/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 6/sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
- test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
+test_expect_success '#2b: relative GIT_DIR' '
+ try_repo 2b unset ".git" unset "" unset \
+ ".git" "$here/2b" "$here/2b" "(null)" \
+ "../.git" "$here/2b/sub" "$here/2b/sub" "(null)"
'
-#
-# case #7
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# core.worktree is overridden by GIT_WORK_TREE -> #3
-
+test_expect_success '#3: setup' '
+ setup_repo 3 unset "" unset &&
+ mkdir -p 3/sub/sub 3/wt/sub
+'
+run_wt_tests 3
+
+test_expect_success '#4: core.worktree without GIT_DIR set is accepted' '
+ setup_repo 4 ../sub "" unset &&
+ mkdir -p 4/sub sub &&
+ try_case 4 unset unset \
+ .git "$here/4/sub" "$here/4" "(null)" \
+ "$here/4/.git" "$here/4/sub" "$here/4/sub" "(null)" 2>message &&
+ ! test -s message
+'
+
+test_expect_success '#5: core.worktree + GIT_WORK_TREE is accepted' '
+ # or: you cannot intimidate away the lack of GIT_DIR setting
+ try_repo 5 "$here" unset "$here/5" "" unset \
+ "$here/5/.git" "$here" "$here" 5/ \
+ "$here/5/.git" "$here" "$here" 5/sub/ 2>message &&
+ try_repo 5a .. unset "$here/5a" "" unset \
+ "$here/5a/.git" "$here" "$here" 5a/ \
+ "$here/5a/.git" "$here/5a" "$here/5a" sub/ &&
+ ! test -s message
+'
+
+test_expect_success '#6: setting GIT_DIR brings core.worktree to life' '
+ setup_repo 6 "$here/6" "" unset &&
+ try_case 6 unset .git \
+ .git "$here/6" "$here/6" "(null)" &&
+ try_case 6 unset "$here/6/.git" \
+ "$here/6/.git" "$here/6" "$here/6" "(null)" &&
+ try_case 6/sub/sub unset ../../.git \
+ "$here/6/.git" "$here/6" "$here/6" sub/sub/ &&
+ try_case 6/sub/sub unset "$here/6/.git" \
+ "$here/6/.git" "$here/6" "$here/6" sub/sub/
+'
+
+test_expect_success '#6b: GIT_DIR set, core.worktree relative' '
+ setup_repo 6b .. "" unset &&
+ try_case 6b unset .git \
+ .git "$here/6b" "$here/6b" "(null)" &&
+ try_case 6b unset "$here/6b/.git" \
+ "$here/6b/.git" "$here/6b" "$here/6b" "(null)" &&
+ try_case 6b/sub/sub unset ../../.git \
+ "$here/6b/.git" "$here/6b" "$here/6b" sub/sub/ &&
+ try_case 6b/sub/sub unset "$here/6b/.git" \
+ "$here/6b/.git" "$here/6b" "$here/6b" sub/sub/
+'
+
+test_expect_success '#6c: GIT_DIR set, core.worktree=../wt (absolute)' '
+ setup_repo 6c "$here/6c/wt" "" unset &&
+ mkdir -p 6c/wt/sub &&
+
+ try_case 6c unset .git \
+ .git "$here/6c/wt" "$here/6c" "(null)" &&
+ try_case 6c unset "$here/6c/.git" \
+ "$here/6c/.git" "$here/6c/wt" "$here/6c" "(null)" &&
+ try_case 6c/sub/sub unset ../../.git \
+ ../../.git "$here/6c/wt" "$here/6c/sub/sub" "(null)" &&
+ try_case 6c/sub/sub unset "$here/6c/.git" \
+ "$here/6c/.git" "$here/6c/wt" "$here/6c/sub/sub" "(null)"
+'
+
+test_expect_success '#6d: GIT_DIR set, core.worktree=../wt (relative)' '
+ setup_repo 6d "$here/6d/wt" "" unset &&
+ mkdir -p 6d/wt/sub &&
+
+ try_case 6d unset .git \
+ .git "$here/6d/wt" "$here/6d" "(null)" &&
+ try_case 6d unset "$here/6d/.git" \
+ "$here/6d/.git" "$here/6d/wt" "$here/6d" "(null)" &&
+ try_case 6d/sub/sub unset ../../.git \
+ ../../.git "$here/6d/wt" "$here/6d/sub/sub" "(null)" &&
+ try_case 6d/sub/sub unset "$here/6d/.git" \
+ "$here/6d/.git" "$here/6d/wt" "$here/6d/sub/sub" "(null)"
+'
+
+test_expect_success '#6e: GIT_DIR set, core.worktree=../.. (absolute)' '
+ setup_repo 6e "$here" "" unset &&
+ try_case 6e unset .git \
+ "$here/6e/.git" "$here" "$here" 6e/ &&
+ try_case 6e unset "$here/6e/.git" \
+ "$here/6e/.git" "$here" "$here" 6e/ &&
+ try_case 6e/sub/sub unset ../../.git \
+ "$here/6e/.git" "$here" "$here" 6e/sub/sub/ &&
+ try_case 6e/sub/sub unset "$here/6e/.git" \
+ "$here/6e/.git" "$here" "$here" 6e/sub/sub/
+'
+
+test_expect_success '#6f: GIT_DIR set, core.worktree=../.. (relative)' '
+ setup_repo 6f ../../ "" unset &&
+ try_case 6f unset .git \
+ "$here/6f/.git" "$here" "$here" 6f/ &&
+ try_case 6f unset "$here/6f/.git" \
+ "$here/6f/.git" "$here" "$here" 6f/ &&
+ try_case 6f/sub/sub unset ../../.git \
+ "$here/6f/.git" "$here" "$here" 6f/sub/sub/ &&
+ try_case 6f/sub/sub unset "$here/6f/.git" \
+ "$here/6f/.git" "$here" "$here" 6f/sub/sub/
+'
+
+# case #7: GIT_WORK_TREE overrides core.worktree.
test_expect_success '#7: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
- cd 7 &&
- git init &&
- git config core.worktree non-existent &&
- cd ..
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/7
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: (null)
-EOF
- test_repo 7 .git "$TRASH_DIRECTORY/7"
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/7
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: (null)
-EOF
- test_repo 7 .git .
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: (null)
-EOF
- test_repo 7 "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY/7"
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: (null)
-EOF
- test_repo 7 "$TRASH_DIRECTORY/7/.git" .
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: sub/sub/
-EOF
- test_repo 7/sub/sub ../../.git "$TRASH_DIRECTORY/7"
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: sub/sub/
-EOF
- test_repo 7/sub/sub ../../.git ../..
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >7/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: sub/
-EOF
- test_repo 7/sub "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY/7"
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: sub/sub/
-EOF
- test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" ../..
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/7/wt
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: (null)
-EOF
- test_repo 7 .git "$TRASH_DIRECTORY/7/wt"
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/7/wt
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: (null)
-EOF
- test_repo 7 .git wt
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7/wt
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: (null)
-EOF
- test_repo 7 "$TRASH_DIRECTORY/7/.git" wt
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7/wt
-setup: cwd: $TRASH_DIRECTORY/7
-setup: prefix: (null)
-EOF
- test_repo 7 "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY/7/wt"
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/7/wt
-setup: cwd: $TRASH_DIRECTORY/7/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 7/sub/sub ../../.git "$TRASH_DIRECTORY/7/wt"
+ setup_repo 7 non-existent "" unset &&
+ mkdir -p 7/sub/sub 7/wt/sub
'
+run_wt_tests 7
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/7/wt
-setup: cwd: $TRASH_DIRECTORY/7/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 7/sub/sub ../../.git ../../wt
+test_expect_success '#8: gitfile, easy case' '
+ try_repo 8 unset unset unset gitfile unset \
+ "$here/8.git" "$here/8" "$here/8" "(null)" \
+ "$here/8.git" "$here/8" "$here/8" sub/
'
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7/wt
-setup: cwd: $TRASH_DIRECTORY/7/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" ../../wt
+test_expect_success '#9: GIT_WORK_TREE accepted with gitfile' '
+ mkdir -p 9/wt &&
+ try_repo 9 wt unset unset gitfile unset \
+ "$here/9.git" "$here/9/wt" "$here/9" "(null)" \
+ "$here/9.git" "$here/9/sub/wt" "$here/9/sub" "(null)" 2>message &&
+ ! test -s message
'
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY/7/wt
-setup: cwd: $TRASH_DIRECTORY/7/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY/7/wt"
+test_expect_success '#10: GIT_DIR can point to gitfile' '
+ try_repo 10 unset "$here/10/.git" unset gitfile unset \
+ "$here/10.git" "$here/10" "$here/10" "(null)" \
+ "$here/10.git" "$here/10/sub" "$here/10/sub" "(null)"
'
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 7/
-EOF
- test_repo 7 .git "$TRASH_DIRECTORY"
+test_expect_success '#10b: relative GIT_DIR can point to gitfile' '
+ try_repo 10b unset .git unset gitfile unset \
+ "$here/10b.git" "$here/10b" "$here/10b" "(null)" \
+ "$here/10b.git" "$here/10b/sub" "$here/10b/sub" "(null)"
'
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 7/
-EOF
- test_repo 7 .git ..
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 7/
-EOF
- test_repo 7 "$TRASH_DIRECTORY/7/.git" ..
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >7/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 7/
-EOF
- test_repo 7 "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 7/sub/sub/
-EOF
- test_repo 7/sub/sub ../../.git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 7/sub/sub/
-EOF
- test_repo 7/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 7/sub/sub/
-EOF
- test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" ../../../
-'
-
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >7/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/7/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 7/sub/sub/
-EOF
- test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY"
-'
-
-#
-# case #8
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #0 except that git_dir is set by .git file
-
-test_expect_success '#8: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 8 8/sub &&
- cd 8 &&
- git init &&
- mv .git ../8.git &&
- echo gitdir: ../8.git >.git &&
- cd ..
-'
-
-test_expect_success '#8: at root' '
- cat >8/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/8.git
-setup: worktree: $TRASH_DIRECTORY/8
-setup: cwd: $TRASH_DIRECTORY/8
-setup: prefix: (null)
-EOF
- test_repo 8
-'
-
-test_expect_success '#8: in subdir' '
- cat >8/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/8.git
-setup: worktree: $TRASH_DIRECTORY/8
-setup: cwd: $TRASH_DIRECTORY/8
-setup: prefix: sub/
-EOF
- test_repo 8/sub
-'
-
-#
-# case #9
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #1 except that git_dir is set by .git file
-
-test_expect_success '#9: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
- cd 9 &&
- git init &&
- mv .git ../9.git &&
- echo gitdir: ../9.git >.git &&
- GIT_WORK_TREE=non-existent &&
- export GIT_WORK_TREE &&
- cd ..
-'
-
-test_expect_success '#9: at root' '
- cat >9/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/9.git
-setup: worktree: $TRASH_DIRECTORY/9
-setup: cwd: $TRASH_DIRECTORY/9
-setup: prefix: (null)
-EOF
- test_repo 9
-'
-
-test_expect_success '#9: in subdir' '
- cat >9/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/9.git
-setup: worktree: $TRASH_DIRECTORY/9
-setup: cwd: $TRASH_DIRECTORY/9
-setup: prefix: sub/
-EOF
- test_repo 9/sub
-'
-
-#
-# case #10
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #2 except that git_dir is set by .git file
-
-test_expect_success '#10: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 10 10/sub &&
- cd 10 &&
- git init &&
- mv .git ../10.git &&
- echo gitdir: ../10.git >.git &&
- cd ..
-'
-
-test_expect_success '#10: at root' '
- cat >10/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/10.git
-setup: worktree: $TRASH_DIRECTORY/10
-setup: cwd: $TRASH_DIRECTORY/10
-setup: prefix: (null)
-EOF
- test_repo 10 "$TRASH_DIRECTORY/10/.git"
-'
-
-test_expect_success '#10: in subdir' '
- cat >10/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/10.git
-setup: worktree: $TRASH_DIRECTORY/10/sub
-setup: cwd: $TRASH_DIRECTORY/10/sub
-setup: prefix: (null)
-EOF
- test_repo 10/sub "$TRASH_DIRECTORY/10/.git"
-'
-
-test_expect_success '#10: relative GIT_DIR at root' '
- cat >10/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/10.git
-setup: worktree: $TRASH_DIRECTORY/10
-setup: cwd: $TRASH_DIRECTORY/10
-setup: prefix: (null)
-EOF
- test_repo 10 .git
-'
-
-test_expect_success '#10: relative GIT_DIR in subdir' '
- cat >10/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/10.git
-setup: worktree: $TRASH_DIRECTORY/10/sub
-setup: cwd: $TRASH_DIRECTORY/10/sub
-setup: prefix: (null)
-EOF
- test_repo 10/sub ../.git
-'
-
-#
-# case #11
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #3 except that git_dir is set by .git file
-
+# case #11: GIT_WORK_TREE works, gitfile case.
test_expect_success '#11: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
- cd 11 &&
- git init &&
- mv .git ../11.git &&
- echo gitdir: ../11.git >.git &&
- cd ..
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: (null)
-EOF
- test_repo 11 .git "$TRASH_DIRECTORY/11"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: (null)
-EOF
- test_repo 11 .git .
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: (null)
-EOF
- test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11"
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: (null)
-EOF
- test_repo 11 "$TRASH_DIRECTORY/11/.git" .
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: sub/sub/
-EOF
- test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY/11"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: sub/sub/
-EOF
- test_repo 11/sub/sub ../../.git ../..
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >11/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: sub/
-EOF
- test_repo 11/sub "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11"
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: sub/sub/
-EOF
- test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../..
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11/wt
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: (null)
-EOF
- test_repo 11 .git "$TRASH_DIRECTORY/11/wt"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11/wt
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: (null)
-EOF
- test_repo 11 .git wt
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11/wt
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: (null)
-EOF
- test_repo 11 "$TRASH_DIRECTORY/11/.git" wt
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11/wt
-setup: cwd: $TRASH_DIRECTORY/11
-setup: prefix: (null)
-EOF
- test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11/wt"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11/wt
-setup: cwd: $TRASH_DIRECTORY/11/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY/11/wt"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11/wt
-setup: cwd: $TRASH_DIRECTORY/11/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 11/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11/wt
-setup: cwd: $TRASH_DIRECTORY/11/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../../wt
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY/11/wt
-setup: cwd: $TRASH_DIRECTORY/11/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11/wt"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 11/
-EOF
- test_repo 11 .git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 11/
-EOF
- test_repo 11 .git ..
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 11/
-EOF
- test_repo 11 "$TRASH_DIRECTORY/11/.git" ..
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >11/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 11/
-EOF
- test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 11/sub/sub/
-EOF
- test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 11/sub/sub/
-EOF
- test_repo 11/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 11/sub/sub/
-EOF
- test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../../../
-'
-
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >11/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/11.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 11/sub/sub/
-EOF
- test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY"
-'
-
-#
-# case #12
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #4 except that git_dir is set by .git file
-
-
-test_expect_success '#12: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
- cd 12 &&
- git init &&
- git config core.worktree non-existent &&
- mv .git ../12.git &&
- echo gitdir: ../12.git >.git &&
- cd ..
-'
-
-test_expect_success '#12: at root' '
- cat >12/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/12.git
-setup: worktree: $TRASH_DIRECTORY/12
-setup: cwd: $TRASH_DIRECTORY/12
-setup: prefix: (null)
-EOF
- test_repo 12
-'
-
-test_expect_success '#12: in subdir' '
- cat >12/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/12.git
-setup: worktree: $TRASH_DIRECTORY/12
-setup: cwd: $TRASH_DIRECTORY/12
-setup: prefix: sub/
-EOF
- test_repo 12/sub
-'
-
-#
-# case #13
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #5 except that git_dir is set by .git file
-
-test_expect_success '#13: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
- cd 13 &&
- git init &&
- git config core.worktree non-existent &&
- GIT_WORK_TREE=non-existent-too &&
- export GIT_WORK_TREE &&
- mv .git ../13.git &&
- echo gitdir: ../13.git >.git &&
- cd ..
-'
-
-test_expect_success '#13: at root' '
- cat >13/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/13.git
-setup: worktree: $TRASH_DIRECTORY/13
-setup: cwd: $TRASH_DIRECTORY/13
-setup: prefix: (null)
-EOF
- test_repo 13
-'
-
-test_expect_success '#13: in subdir' '
- cat >13/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/13.git
-setup: worktree: $TRASH_DIRECTORY/13
-setup: cwd: $TRASH_DIRECTORY/13
-setup: prefix: sub/
-EOF
- test_repo 13/sub
-'
-
-#
-# case #14
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #6 except that git_dir is set by .git file
-
-test_expect_success '#14: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
- cd 14 &&
- git init &&
- mv .git ../14.git &&
- echo gitdir: ../14.git >.git &&
- cd ..
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14 at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
- test_repo 14 "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
- test_repo 14 "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14 in subdir' '
- cat >14/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: sub/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
- test_repo 14/sub "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
- test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14/wt
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14/wt
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14/wt
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
- test_repo 14 "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14/wt
-setup: cwd: $TRASH_DIRECTORY/14
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
- test_repo 14 "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14/wt
-setup: cwd: $TRASH_DIRECTORY/14/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14/wt
-setup: cwd: $TRASH_DIRECTORY/14/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14/wt
-setup: cwd: $TRASH_DIRECTORY/14/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
- test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY/14/wt
-setup: cwd: $TRASH_DIRECTORY/14/sub/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
- test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=.. at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 14/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 14/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
- test_repo 14 .git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=..(rel) at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 14/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
- test_repo 14 "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=.. at root' '
- cat >14/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 14/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
- test_repo 14 "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 14/sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 14/sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
- test_repo 14/sub/sub ../../.git
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 14/sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
- test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
-'
-
-test_expect_success '#14: GIT_DIR, core.worktree=.. in subdir' '
- cat >14/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/14.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 14/sub/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
- test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
-'
-
-#
-# case #15
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is not set, cwd is outside .git
-#
-# Output:
-#
-# #7 except that git_dir is set by .git file
-
+ setup_repo 11 unset gitfile unset &&
+ mkdir -p 11/sub/sub 11/wt/sub
+'
+run_wt_tests 11 gitfile
+
+test_expect_success '#12: core.worktree with gitfile is accepted' '
+ try_repo 12 unset unset "$here/12" gitfile unset \
+ "$here/12.git" "$here/12" "$here/12" "(null)" \
+ "$here/12.git" "$here/12" "$here/12" sub/ 2>message &&
+ ! test -s message
+'
+
+test_expect_success '#13: core.worktree+GIT_WORK_TREE accepted (with gitfile)' '
+ # or: you cannot intimidate away the lack of GIT_DIR setting
+ try_repo 13 non-existent-too unset non-existent gitfile unset \
+ "$here/13.git" "$here/13/non-existent-too" "$here/13" "(null)" \
+ "$here/13.git" "$here/13/sub/non-existent-too" "$here/13/sub" "(null)" 2>message &&
+ ! test -s message
+'
+
+# case #14.
+# If this were more table-driven, it could share code with case #6.
+
+test_expect_success '#14: core.worktree with GIT_DIR pointing to gitfile' '
+ setup_repo 14 "$here/14" gitfile unset &&
+ try_case 14 unset .git \
+ "$here/14.git" "$here/14" "$here/14" "(null)" &&
+ try_case 14 unset "$here/14/.git" \
+ "$here/14.git" "$here/14" "$here/14" "(null)" &&
+ try_case 14/sub/sub unset ../../.git \
+ "$here/14.git" "$here/14" "$here/14" sub/sub/ &&
+ try_case 14/sub/sub unset "$here/14/.git" \
+ "$here/14.git" "$here/14" "$here/14" sub/sub/ &&
+
+ setup_repo 14c "$here/14c/wt" gitfile unset &&
+ mkdir -p 14c/wt/sub &&
+
+ try_case 14c unset .git \
+ "$here/14c.git" "$here/14c/wt" "$here/14c" "(null)" &&
+ try_case 14c unset "$here/14c/.git" \
+ "$here/14c.git" "$here/14c/wt" "$here/14c" "(null)" &&
+ try_case 14c/sub/sub unset ../../.git \
+ "$here/14c.git" "$here/14c/wt" "$here/14c/sub/sub" "(null)" &&
+ try_case 14c/sub/sub unset "$here/14c/.git" \
+ "$here/14c.git" "$here/14c/wt" "$here/14c/sub/sub" "(null)" &&
+
+ setup_repo 14d "$here/14d/wt" gitfile unset &&
+ mkdir -p 14d/wt/sub &&
+
+ try_case 14d unset .git \
+ "$here/14d.git" "$here/14d/wt" "$here/14d" "(null)" &&
+ try_case 14d unset "$here/14d/.git" \
+ "$here/14d.git" "$here/14d/wt" "$here/14d" "(null)" &&
+ try_case 14d/sub/sub unset ../../.git \
+ "$here/14d.git" "$here/14d/wt" "$here/14d/sub/sub" "(null)" &&
+ try_case 14d/sub/sub unset "$here/14d/.git" \
+ "$here/14d.git" "$here/14d/wt" "$here/14d/sub/sub" "(null)" &&
+
+ setup_repo 14e "$here" gitfile unset &&
+ try_case 14e unset .git \
+ "$here/14e.git" "$here" "$here" 14e/ &&
+ try_case 14e unset "$here/14e/.git" \
+ "$here/14e.git" "$here" "$here" 14e/ &&
+ try_case 14e/sub/sub unset ../../.git \
+ "$here/14e.git" "$here" "$here" 14e/sub/sub/ &&
+ try_case 14e/sub/sub unset "$here/14e/.git" \
+ "$here/14e.git" "$here" "$here" 14e/sub/sub/
+'
+
+test_expect_success '#14b: core.worktree is relative to actual git dir' '
+ setup_repo 14b ../14b gitfile unset &&
+ try_case 14b unset .git \
+ "$here/14b.git" "$here/14b" "$here/14b" "(null)" &&
+ try_case 14b unset "$here/14b/.git" \
+ "$here/14b.git" "$here/14b" "$here/14b" "(null)" &&
+ try_case 14b/sub/sub unset ../../.git \
+ "$here/14b.git" "$here/14b" "$here/14b" sub/sub/ &&
+ try_case 14b/sub/sub unset "$here/14b/.git" \
+ "$here/14b.git" "$here/14b" "$here/14b" sub/sub/ &&
+
+ setup_repo 14f ../ gitfile unset &&
+ try_case 14f unset .git \
+ "$here/14f.git" "$here" "$here" 14f/ &&
+ try_case 14f unset "$here/14f/.git" \
+ "$here/14f.git" "$here" "$here" 14f/ &&
+ try_case 14f/sub/sub unset ../../.git \
+ "$here/14f.git" "$here" "$here" 14f/sub/sub/ &&
+ try_case 14f/sub/sub unset "$here/14f/.git" \
+ "$here/14f.git" "$here" "$here" 14f/sub/sub/
+'
+
+# case #15: GIT_WORK_TREE overrides core.worktree (gitfile case).
test_expect_success '#15: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
- cd 15 &&
- git init &&
- git config core.worktree non-existent &&
- mv .git ../15.git &&
- echo gitdir: ../15.git >.git &&
- cd ..
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: (null)
-EOF
- test_repo 15 .git "$TRASH_DIRECTORY/15"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: (null)
-EOF
- test_repo 15 .git .
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: (null)
-EOF
- test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15"
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: (null)
-EOF
- test_repo 15 "$TRASH_DIRECTORY/15/.git" .
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: sub/sub/
-EOF
- test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY/15"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: sub/sub/
-EOF
- test_repo 15/sub/sub ../../.git ../..
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >15/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: sub/
-EOF
- test_repo 15/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15"
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: sub/sub/
-EOF
- test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../..
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15/wt
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: (null)
-EOF
- test_repo 15 .git "$TRASH_DIRECTORY/15/wt"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15/wt
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: (null)
-EOF
- test_repo 15 .git wt
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15/wt
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: (null)
-EOF
- test_repo 15 "$TRASH_DIRECTORY/15/.git" wt
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15/wt
-setup: cwd: $TRASH_DIRECTORY/15
-setup: prefix: (null)
-EOF
- test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15/wt"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15/wt
-setup: cwd: $TRASH_DIRECTORY/15/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY/15/wt"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15/wt
-setup: cwd: $TRASH_DIRECTORY/15/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 15/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15/wt
-setup: cwd: $TRASH_DIRECTORY/15/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../../wt
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY/15/wt
-setup: cwd: $TRASH_DIRECTORY/15/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15/wt"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 15/
-EOF
- test_repo 15 .git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 15/
-EOF
- test_repo 15 .git ..
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 15/
-EOF
- test_repo 15 "$TRASH_DIRECTORY/15/.git" ..
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >15/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 15/
-EOF
- test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 15/sub/sub/
-EOF
- test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 15/sub/sub/
-EOF
- test_repo 15/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 15/sub/sub/
-EOF
- test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../../../
-'
-
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >15/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/15.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 15/sub/sub/
-EOF
- test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY"
-'
-
-#
-# case #16.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# - no worktree
-# - cwd is unchanged
-# - prefix is NULL
-# - git_dir is set
-# - cwd can't be outside worktree
-
-test_expect_success '#16.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 16 16/sub &&
- cd 16 &&
- git init &&
- mkdir .git/wt .git/wt/sub &&
- cd ..
-'
-
-test_expect_success '#16.1: at .git' '
- cat >16/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/16/.git
-setup: prefix: (null)
-EOF
- test_repo 16/.git
-'
-
-test_expect_success '#16.1: in .git/wt' '
- cat >16/.git/wt/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/16/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/16/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 16/.git/wt
-'
-
-test_expect_success '#16.1: in .git/wt/sub' '
- cat >16/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/16/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/16/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 16/.git/wt/sub
-'
-
-#
-# case #16.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# - no worktree
-# - cwd is unchanged
-# - prefix is NULL
-# - git_dir is set
-# - cwd can't be outside worktree
-
-test_expect_success '#16.2: setup' '
- git config --file="$TRASH_DIRECTORY/16/.git/config" core.bare true
-'
-
-test_expect_success '#16.2: at .git' '
- cat >16/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/16/.git
-setup: prefix: (null)
-EOF
- test_repo 16/.git
-'
-
-test_expect_success '#16.2: in .git/wt' '
- cat >16/.git/wt/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/16/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/16/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 16/.git/wt
-'
-
-test_expect_success '#16.2: in .git/wt/sub' '
- cat >16/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/16/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/16/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 16/.git/wt/sub
-'
-
-test_expect_success '#16.2: at root' '
- cat >16/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/16
-setup: prefix: (null)
-EOF
- test_repo 16
-'
-
-test_expect_success '#16.2: in subdir' '
- cat >16/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/16/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/16/sub
-setup: prefix: (null)
-EOF
- test_repo 16/sub
-'
-
-#
-# case #17.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
-
-test_expect_success '#17.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 17 17/sub &&
- cd 17 &&
- git init &&
- mkdir .git/wt .git/wt/sub &&
- GIT_WORK_TREE=non-existent &&
- export GIT_WORK_TREE &&
- cd ..
-'
-
-test_expect_success '#17.1: at .git' '
- cat >17/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/17/.git
-setup: prefix: (null)
-EOF
- test_repo 17/.git
-'
-
-test_expect_success '#17.1: in .git/wt' '
- cat >17/.git/wt/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/17/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/17/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 17/.git/wt
-'
-
-test_expect_success '#17.1: in .git/wt/sub' '
- cat >17/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/17/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/17/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 17/.git/wt/sub
-'
-
-#
-# case #17.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# GIT_WORK_TREE is ignored -> #16.2 (with warnings perhaps)
-
-test_expect_success '#17.2: setup' '
- git config --file="$TRASH_DIRECTORY/17/.git/config" core.bare true
-'
-
-test_expect_success '#17.2: at .git' '
- cat >17/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/17/.git
-setup: prefix: (null)
-EOF
- test_repo 17/.git
-'
-
-test_expect_success '#17.2: in .git/wt' '
- cat >17/.git/wt/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/17/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/17/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 17/.git/wt
-'
-
-test_expect_success '#17.2: in .git/wt/sub' '
- cat >17/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/17/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/17/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 17/.git/wt/sub
-'
-
-test_expect_success '#17.2: at root' '
- cat >17/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/17
-setup: prefix: (null)
-EOF
- test_repo 17
-'
-
-test_expect_success '#17.2: in subdir' '
- cat >17/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/17/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/17/sub
-setup: prefix: (null)
-EOF
- test_repo 17/sub
-'
-
-#
-# case #18
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is not set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# - no worktree (rule #8)
-# - cwd is unchanged
-# - prefix is NULL
-# - git_dir is set to $GIT_DIR
-# - cwd can't be outside worktree
-
-test_expect_success '#18: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 18 18/sub &&
- cd 18 &&
- git init &&
- mkdir .git/wt .git/wt/sub &&
- git config core.bare true &&
- cd ..
-'
-
-test_expect_success '#18: (rel) at root' '
- cat >18/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/18
-setup: prefix: (null)
-EOF
- test_repo 18 .git
-'
-
-test_expect_success '#18: at root' '
- cat >18/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/18/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/18
-setup: prefix: (null)
-EOF
- test_repo 18 "$TRASH_DIRECTORY/18/.git"
-'
-
-test_expect_success '#18: (rel) in subdir' '
- cat >18/sub/expected <<EOF &&
-setup: git_dir: ../.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/18/sub
-setup: prefix: (null)
-EOF
- test_repo 18/sub ../.git
-'
-
-test_expect_success '#18: in subdir' '
- cat >18/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/18/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/18/sub
-setup: prefix: (null)
-EOF
- test_repo 18/sub "$TRASH_DIRECTORY/18/.git"
-'
-
-#
-# case #19
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - .git is a directory
-# - core.worktree is not set
-# - core.bare is set
-#
-# Output:
-#
-# bare repo is overridden by GIT_WORK_TREE -> #3
-
+ setup_repo 15 non-existent gitfile unset &&
+ mkdir -p 15/sub/sub 15/wt/sub
+'
+run_wt_tests 15 gitfile
+
+test_expect_success '#16a: implicitly bare repo (cwd inside .git dir)' '
+ setup_repo 16a unset "" unset &&
+ mkdir -p 16a/.git/wt/sub &&
+
+ try_case 16a/.git unset unset \
+ . "(null)" "$here/16a/.git" "(null)" &&
+ try_case 16a/.git/wt unset unset \
+ "$here/16a/.git" "(null)" "$here/16a/.git/wt" "(null)" &&
+ try_case 16a/.git/wt/sub unset unset \
+ "$here/16a/.git" "(null)" "$here/16a/.git/wt/sub" "(null)"
+'
+
+test_expect_success '#16b: bare .git (cwd inside .git dir)' '
+ setup_repo 16b unset "" true &&
+ mkdir -p 16b/.git/wt/sub &&
+
+ try_case 16b/.git unset unset \
+ . "(null)" "$here/16b/.git" "(null)" &&
+ try_case 16b/.git/wt unset unset \
+ "$here/16b/.git" "(null)" "$here/16b/.git/wt" "(null)" &&
+ try_case 16b/.git/wt/sub unset unset \
+ "$here/16b/.git" "(null)" "$here/16b/.git/wt/sub" "(null)"
+'
+
+test_expect_success '#16c: bare .git has no worktree' '
+ try_repo 16c unset unset unset "" true \
+ .git "(null)" "$here/16c" "(null)" \
+ "$here/16c/.git" "(null)" "$here/16c/sub" "(null)"
+'
+
+test_expect_success '#17: GIT_WORK_TREE without explicit GIT_DIR is accepted (bare case)' '
+ # Just like #16.
+ setup_repo 17a unset "" true &&
+ setup_repo 17b unset "" true &&
+ mkdir -p 17a/.git/wt/sub &&
+ mkdir -p 17b/.git/wt/sub &&
+
+ try_case 17a/.git "$here/17a" unset \
+ "$here/17a/.git" "$here/17a" "$here/17a" .git/ \
+ 2>message &&
+ try_case 17a/.git/wt "$here/17a" unset \
+ "$here/17a/.git" "$here/17a" "$here/17a" .git/wt/ &&
+ try_case 17a/.git/wt/sub "$here/17a" unset \
+ "$here/17a/.git" "$here/17a" "$here/17a" .git/wt/sub/ &&
+
+ try_case 17b/.git "$here/17b" unset \
+ "$here/17b/.git" "$here/17b" "$here/17b" .git/ &&
+ try_case 17b/.git/wt "$here/17b" unset \
+ "$here/17b/.git" "$here/17b" "$here/17b" .git/wt/ &&
+ try_case 17b/.git/wt/sub "$here/17b" unset \
+ "$here/17b/.git" "$here/17b" "$here/17b" .git/wt/sub/ &&
+
+ try_repo 17c "$here/17c" unset unset "" true \
+ .git "$here/17c" "$here/17c" "(null)" \
+ "$here/17c/.git" "$here/17c" "$here/17c" sub/ 2>message &&
+ ! test -s message
+'
+
+test_expect_success '#18: bare .git named by GIT_DIR has no worktree' '
+ try_repo 18 unset .git unset "" true \
+ .git "(null)" "$here/18" "(null)" \
+ ../.git "(null)" "$here/18/sub" "(null)" &&
+ try_repo 18b unset "$here/18b/.git" unset "" true \
+ "$here/18b/.git" "(null)" "$here/18b" "(null)" \
+ "$here/18b/.git" "(null)" "$here/18b/sub" "(null)"
+'
+
+# Case #19: GIT_DIR + GIT_WORK_TREE suppresses bareness.
test_expect_success '#19: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 19 19/sub 19/sub/sub 19.wt 19.wt/sub 19/wt 19/wt/sub &&
- cd 19 &&
- git init &&
- git config core.bare true &&
- cd ..
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/19
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: (null)
-EOF
- test_repo 19 .git "$TRASH_DIRECTORY/19"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/19
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: (null)
-EOF
- test_repo 19 .git .
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: (null)
-EOF
- test_repo 19 "$TRASH_DIRECTORY/19/.git" "$TRASH_DIRECTORY/19"
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: (null)
-EOF
- test_repo 19 "$TRASH_DIRECTORY/19/.git" .
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: sub/sub/
-EOF
- test_repo 19/sub/sub ../../.git "$TRASH_DIRECTORY/19"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: sub/sub/
-EOF
- test_repo 19/sub/sub ../../.git ../..
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >19/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: sub/
-EOF
- test_repo 19/sub "$TRASH_DIRECTORY/19/.git" "$TRASH_DIRECTORY/19"
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: sub/sub/
-EOF
- test_repo 19/sub/sub "$TRASH_DIRECTORY/19/.git" ../..
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/19/wt
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: (null)
-EOF
- test_repo 19 .git "$TRASH_DIRECTORY/19/wt"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/19/wt
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: (null)
-EOF
- test_repo 19 .git wt
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19/wt
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: (null)
-EOF
- test_repo 19 "$TRASH_DIRECTORY/19/.git" wt
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19/wt
-setup: cwd: $TRASH_DIRECTORY/19
-setup: prefix: (null)
-EOF
- test_repo 19 "$TRASH_DIRECTORY/19/.git" "$TRASH_DIRECTORY/19/wt"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/19/wt
-setup: cwd: $TRASH_DIRECTORY/19/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 19/sub/sub ../../.git "$TRASH_DIRECTORY/19/wt"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/19/wt
-setup: cwd: $TRASH_DIRECTORY/19/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 19/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19/wt
-setup: cwd: $TRASH_DIRECTORY/19/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 19/sub/sub "$TRASH_DIRECTORY/19/.git" ../../wt
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY/19/wt
-setup: cwd: $TRASH_DIRECTORY/19/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 19/sub/sub "$TRASH_DIRECTORY/19/.git" "$TRASH_DIRECTORY/19/wt"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 19/
-EOF
- test_repo 19 .git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 19/
-EOF
- test_repo 19 .git ..
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 19/
-EOF
- test_repo 19 "$TRASH_DIRECTORY/19/.git" ..
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >19/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 19/
-EOF
- test_repo 19 "$TRASH_DIRECTORY/19/.git" "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 19/sub/sub/
-EOF
- test_repo 19/sub/sub ../../.git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 19/sub/sub/
-EOF
- test_repo 19/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 19/sub/sub/
-EOF
- test_repo 19/sub/sub "$TRASH_DIRECTORY/19/.git" ../../../
-'
-
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >19/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/19/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 19/sub/sub/
-EOF
- test_repo 19/sub/sub "$TRASH_DIRECTORY/19/.git" "$TRASH_DIRECTORY"
-'
-
-#
-# case #20.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# core.worktree is ignored -> #16.1
-
-test_expect_success '#20.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 20 20/sub &&
- cd 20 &&
- git init &&
- git config core.worktree non-existent &&
- mkdir .git/wt .git/wt/sub &&
- cd ..
-'
-
-test_expect_success '#20.1: at .git' '
- cat >20/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/20/.git
-setup: prefix: (null)
-EOF
- test_repo 20/.git
-'
-
-test_expect_success '#20.1: in .git/wt' '
- cat >20/.git/wt/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/20/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/20/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 20/.git/wt
-'
-
-test_expect_success '#20.1: in .git/wt/sub' '
- cat >20/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/20/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/20/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 20/.git/wt/sub
-'
-
-#
-# case #20.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree is ignored -> #16.2
-
-test_expect_success '#20.2: setup' '
- git config --file="$TRASH_DIRECTORY/20/.git/config" core.bare true
-'
-
-test_expect_success '#20.2: at .git' '
- cat >20/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/20/.git
-setup: prefix: (null)
-EOF
- test_repo 20/.git
-'
-
-test_expect_success '#20.2: in .git/wt' '
- cat >20/.git/wt/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/20/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/20/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 20/.git/wt
-'
-
-test_expect_success '#20.2: in .git/wt/sub' '
- cat >20/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/20/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/20/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 20/.git/wt/sub
-'
-
-test_expect_success '#20.2: at root' '
- cat >20/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/20
-setup: prefix: (null)
-EOF
- test_repo 20
-'
-
-test_expect_success '#20.2: in subdir' '
- cat >20/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/20/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/20/sub
-setup: prefix: (null)
-EOF
- test_repo 20/sub
-'
-
-#
-# case #21.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# GIT_WORK_TREE/core.worktree are ignored -> #20.1
-
-test_expect_success '#21.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 21 21/sub &&
- cd 21 &&
- git init &&
- git config core.worktree non-existent &&
- GIT_WORK_TREE=non-existent-too &&
- export GIT_WORK_TREE &&
- mkdir .git/wt .git/wt/sub &&
- cd ..
-'
-
-test_expect_success '#21.1: at .git' '
- cat >21/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/21/.git
-setup: prefix: (null)
-EOF
- test_repo 21/.git
-'
-
-test_expect_success '#21.1: in .git/wt' '
- cat >21/.git/wt/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/21/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/21/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 21/.git/wt
-'
-
-test_expect_success '#21.1: in .git/wt/sub' '
- cat >21/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/21/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/21/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 21/.git/wt/sub
-'
-
-#
-# case #21.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# GIT_WORK_TREE/core.worktree are ignored -> #20.2
-
-test_expect_success '#21.2: setup' '
- git config --file="$TRASH_DIRECTORY/21/.git/config" core.bare true
-'
-
-test_expect_success '#21.2: at .git' '
- cat >21/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/21/.git
-setup: prefix: (null)
-EOF
- test_repo 21/.git
-'
-
-test_expect_success '#21.2: in .git/wt' '
- cat >21/.git/wt/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/21/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/21/.git/wt
-setup: prefix: (null)
-EOF
- test_repo 21/.git/wt
-'
-
-test_expect_success '#21.2: in .git/wt/sub' '
- cat >21/.git/wt/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/21/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/21/.git/wt/sub
-setup: prefix: (null)
-EOF
- test_repo 21/.git/wt/sub
-'
-
-test_expect_success '#21.2: at root' '
- cat >21/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/21
-setup: prefix: (null)
-EOF
- test_repo 21
-'
-
-test_expect_success '#21.2: in subdir' '
- cat >21/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/21/.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/21/sub
-setup: prefix: (null)
-EOF
- test_repo 21/sub
-'
-
-#
-# case #22.1
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a directory
-# - cwd is inside .git
-#
-# Output:
-#
-# bare attribute is ignored
-#
-# - worktree is at core.worktree
-# - cwd is at worktree root
-# - prefix is calculated
-# - git_dir is at $GIT_DIR
-# - cwd can be outside worktree
-
-test_expect_success '#22.1: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 22 &&
- cd 22 &&
- git init &&
- mkdir .git/sub .git/wt .git/wt/sub &&
- cd ..
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: $TRASH_DIRECTORY/22/.git
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git" &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: $TRASH_DIRECTORY/22/.git
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree . &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=. at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git" &&
- test_repo 22/.git "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) at root' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree . &&
- test_repo 22/.git "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: sub/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git" &&
- test_repo 22/.git/sub ..
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: sub/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree . &&
- test_repo 22/.git/sub/ ..
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=. in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: sub/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git" &&
- test_repo 22/.git/sub "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: sub/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree . &&
- test_repo 22/.git/sub "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: $TRASH_DIRECTORY/22/.git/wt
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git/wt" &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: .
-setup: worktree: $TRASH_DIRECTORY/22/.git/wt
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree wt &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git/wt
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree wt &&
- test_repo 22/.git "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git/wt
-setup: cwd: $TRASH_DIRECTORY/22/.git
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git/wt" &&
- test_repo 22/.git "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: ..
-setup: worktree: $TRASH_DIRECTORY/22/.git/wt
-setup: cwd: $TRASH_DIRECTORY/22/.git/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git/wt" &&
- test_repo 22/.git/sub ..
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: ..
-setup: worktree: $TRASH_DIRECTORY/22/.git/wt
-setup: cwd: $TRASH_DIRECTORY/22/.git/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree wt &&
- test_repo 22/.git/sub ..
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git/wt
-setup: cwd: $TRASH_DIRECTORY/22/.git/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree wt &&
- test_repo 22/.git/sub "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22/.git/wt
-setup: cwd: $TRASH_DIRECTORY/22/.git/sub
-setup: prefix: (null)
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22/.git/wt" &&
- test_repo 22/.git/sub "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22
-setup: cwd: $TRASH_DIRECTORY/22
-setup: prefix: .git/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22" &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22
-setup: cwd: $TRASH_DIRECTORY/22
-setup: prefix: .git/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree .. &&
- test_repo 22/.git .
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22
-setup: cwd: $TRASH_DIRECTORY/22
-setup: prefix: .git/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree .. &&
- test_repo 22/.git "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=.. at .git' '
- cat >22/.git/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22
-setup: cwd: $TRASH_DIRECTORY/22
-setup: prefix: .git/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22" &&
- test_repo 22/.git "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22
-setup: cwd: $TRASH_DIRECTORY/22
-setup: prefix: .git/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22" &&
- test_repo 22/.git/sub ..
-'
-
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22
-setup: cwd: $TRASH_DIRECTORY/22
-setup: prefix: .git/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree .. &&
- test_repo 22/.git/sub ..
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22
-setup: cwd: $TRASH_DIRECTORY/22
-setup: prefix: .git/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree .. &&
- test_repo 22/.git/sub "$TRASH_DIRECTORY/22/.git"
-'
-
-test_expect_success '#22.1: GIT_DIR, core.worktree=.. in .git/sub' '
- cat >22/.git/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/22/.git
-setup: worktree: $TRASH_DIRECTORY/22
-setup: cwd: $TRASH_DIRECTORY/22
-setup: prefix: .git/sub/
-EOF
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.worktree "$TRASH_DIRECTORY/22" &&
- test_repo 22/.git/sub "$TRASH_DIRECTORY/22/.git"
-'
-
-#
-# case #22.2
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree and core.bare conflict, won't fly.
-
-test_expect_success '#22.2: setup' '
- git config --file="$TRASH_DIRECTORY/22/.git/config" core.bare true
-'
-
-test_expect_success '#22.2: at .git' '
+ setup_repo 19 unset "" true &&
+ mkdir -p 19/sub/sub 19/wt/sub
+'
+run_wt_tests 19
+
+test_expect_success '#20a: core.worktree without GIT_DIR accepted (inside .git)' '
+ # Unlike case #16a.
+ setup_repo 20a "$here/20a" "" unset &&
+ mkdir -p 20a/.git/wt/sub &&
+ try_case 20a/.git unset unset \
+ "$here/20a/.git" "$here/20a" "$here/20a" .git/ 2>message &&
+ try_case 20a/.git/wt unset unset \
+ "$here/20a/.git" "$here/20a" "$here/20a" .git/wt/ &&
+ try_case 20a/.git/wt/sub unset unset \
+ "$here/20a/.git" "$here/20a" "$here/20a" .git/wt/sub/ &&
+ ! test -s message
+'
+
+test_expect_success '#20b/c: core.worktree and core.bare conflict' '
+ setup_repo 20b non-existent "" true &&
+ mkdir -p 20b/.git/wt/sub &&
(
- cd 22/.git &&
- GIT_DIR=. &&
- export GIT_DIR &&
- test_must_fail git symbolic-ref HEAD 2>result &&
- grep "core.bare and core.worktree do not make sense" result
- )
+ cd 20b/.git &&
+ test_must_fail git symbolic-ref HEAD >/dev/null
+ ) 2>message &&
+ grep "core.bare and core.worktree" message
'
-test_expect_success '#22.2: at root' '
+# Case #21: core.worktree/GIT_WORK_TREE overrides core.bare' '
+test_expect_success '#21: setup, core.worktree warns before overriding core.bare' '
+ setup_repo 21 non-existent "" unset &&
+ mkdir -p 21/.git/wt/sub &&
(
- cd 22 &&
- GIT_DIR=.git &&
- export GIT_DIR &&
- test_must_fail git symbolic-ref HEAD 2>result &&
- grep "core.bare and core.worktree do not make sense" result
- )
+ cd 21/.git &&
+ GIT_WORK_TREE="$here/21" &&
+ export GIT_WORK_TREE &&
+ git symbolic-ref HEAD >/dev/null
+ ) 2>message &&
+ ! test -s message
+
+'
+run_wt_tests 21
+
+test_expect_success '#22a: core.worktree = GIT_DIR = .git dir' '
+ # like case #6.
+
+ setup_repo 22a "$here/22a/.git" "" unset &&
+ setup_repo 22ab . "" unset
+ mkdir -p 22a/.git/sub 22a/sub &&
+ mkdir -p 22ab/.git/sub 22ab/sub &&
+ try_case 22a/.git unset . \
+ . "$here/22a/.git" "$here/22a/.git" "(null)" &&
+ try_case 22a/.git unset "$here/22a/.git" \
+ "$here/22a/.git" "$here/22a/.git" "$here/22a/.git" "(null)" &&
+ try_case 22a/.git/sub unset .. \
+ "$here/22a/.git" "$here/22a/.git" "$here/22a/.git" sub/ &&
+ try_case 22a/.git/sub unset "$here/22a/.git" \
+ "$here/22a/.git" "$here/22a/.git" "$here/22a/.git" sub/ &&
+
+ try_case 22ab/.git unset . \
+ . "$here/22ab/.git" "$here/22ab/.git" "(null)" &&
+ try_case 22ab/.git unset "$here/22ab/.git" \
+ "$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" "(null)" &&
+ try_case 22ab/.git/sub unset .. \
+ "$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" sub/ &&
+ try_case 22ab/.git unset "$here/22ab/.git" \
+ "$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" "(null)"
+'
+
+test_expect_success '#22b: core.worktree child of .git, GIT_DIR=.git' '
+ setup_repo 22b "$here/22b/.git/wt" "" unset &&
+ setup_repo 22bb wt "" unset &&
+ mkdir -p 22b/.git/sub 22b/sub 22b/.git/wt/sub 22b/wt/sub &&
+ mkdir -p 22bb/.git/sub 22bb/sub 22bb/.git/wt 22bb/wt &&
+
+ try_case 22b/.git unset . \
+ . "$here/22b/.git/wt" "$here/22b/.git" "(null)" &&
+ try_case 22b/.git unset "$here/22b/.git" \
+ "$here/22b/.git" "$here/22b/.git/wt" "$here/22b/.git" "(null)" &&
+ try_case 22b/.git/sub unset .. \
+ .. "$here/22b/.git/wt" "$here/22b/.git/sub" "(null)" &&
+ try_case 22b/.git/sub unset "$here/22b/.git" \
+ "$here/22b/.git" "$here/22b/.git/wt" "$here/22b/.git/sub" "(null)" &&
+
+ try_case 22bb/.git unset . \
+ . "$here/22bb/.git/wt" "$here/22bb/.git" "(null)" &&
+ try_case 22bb/.git unset "$here/22bb/.git" \
+ "$here/22bb/.git" "$here/22bb/.git/wt" "$here/22bb/.git" "(null)" &&
+ try_case 22bb/.git/sub unset .. \
+ .. "$here/22bb/.git/wt" "$here/22bb/.git/sub" "(null)" &&
+ try_case 22bb/.git/sub unset "$here/22bb/.git" \
+ "$here/22bb/.git" "$here/22bb/.git/wt" "$here/22bb/.git/sub" "(null)"
+'
+
+test_expect_success '#22c: core.worktree = .git/.., GIT_DIR=.git' '
+ setup_repo 22c "$here/22c" "" unset &&
+ setup_repo 22cb .. "" unset &&
+ mkdir -p 22c/.git/sub 22c/sub &&
+ mkdir -p 22cb/.git/sub 22cb/sub &&
+
+ try_case 22c/.git unset . \
+ "$here/22c/.git" "$here/22c" "$here/22c" .git/ &&
+ try_case 22c/.git unset "$here/22c/.git" \
+ "$here/22c/.git" "$here/22c" "$here/22c" .git/ &&
+ try_case 22c/.git/sub unset .. \
+ "$here/22c/.git" "$here/22c" "$here/22c" .git/sub/ &&
+ try_case 22c/.git/sub unset "$here/22c/.git" \
+ "$here/22c/.git" "$here/22c" "$here/22c" .git/sub/ &&
+
+ try_case 22cb/.git unset . \
+ "$here/22cb/.git" "$here/22cb" "$here/22cb" .git/ &&
+ try_case 22cb/.git unset "$here/22cb/.git" \
+ "$here/22cb/.git" "$here/22cb" "$here/22cb" .git/ &&
+ try_case 22cb/.git/sub unset .. \
+ "$here/22cb/.git" "$here/22cb" "$here/22cb" .git/sub/ &&
+ try_case 22cb/.git/sub unset "$here/22cb/.git" \
+ "$here/22cb/.git" "$here/22cb" "$here/22cb" .git/sub/
+'
+
+test_expect_success '#22.2: core.worktree and core.bare conflict' '
+ setup_repo 22 "$here/22" "" true &&
+ (
+ cd 22/.git &&
+ GIT_DIR=. &&
+ export GIT_DIR &&
+ test_must_fail git symbolic-ref HEAD 2>result
+ ) &&
+ (
+ cd 22 &&
+ GIT_DIR=.git &&
+ export GIT_DIR &&
+ test_must_fail git symbolic-ref HEAD 2>result
+ ) &&
+ grep "core.bare and core.worktree" 22/.git/result &&
+ grep "core.bare and core.worktree" 22/result
'
-#
-# case #23
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a directory
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree is overridden by GIT_WORK_TREE -> #19
-
+# Case #23: GIT_DIR + GIT_WORK_TREE(+core.worktree) suppresses bareness.
test_expect_success '#23: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
- cd 23 &&
- git init &&
- git config core.bare true &&
- git config core.worktree non-existent &&
- cd ..
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/23
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: (null)
-EOF
- test_repo 23 .git "$TRASH_DIRECTORY/23"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/23
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: (null)
-EOF
- test_repo 23 .git .
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: (null)
-EOF
- test_repo 23 "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY/23"
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: (null)
-EOF
- test_repo 23 "$TRASH_DIRECTORY/23/.git" .
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: sub/sub/
-EOF
- test_repo 23/sub/sub ../../.git "$TRASH_DIRECTORY/23"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: sub/sub/
-EOF
- test_repo 23/sub/sub ../../.git ../..
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >23/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: sub/
-EOF
- test_repo 23/sub "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY/23"
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: sub/sub/
-EOF
- test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" ../..
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/23/wt
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: (null)
-EOF
- test_repo 23 .git "$TRASH_DIRECTORY/23/wt"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: .git
-setup: worktree: $TRASH_DIRECTORY/23/wt
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: (null)
-EOF
- test_repo 23 .git wt
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23/wt
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: (null)
-EOF
- test_repo 23 "$TRASH_DIRECTORY/23/.git" wt
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23/wt
-setup: cwd: $TRASH_DIRECTORY/23
-setup: prefix: (null)
-EOF
- test_repo 23 "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY/23/wt"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/23/wt
-setup: cwd: $TRASH_DIRECTORY/23/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 23/sub/sub ../../.git "$TRASH_DIRECTORY/23/wt"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: ../../.git
-setup: worktree: $TRASH_DIRECTORY/23/wt
-setup: cwd: $TRASH_DIRECTORY/23/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 23/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23/wt
-setup: cwd: $TRASH_DIRECTORY/23/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" ../../wt
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY/23/wt
-setup: cwd: $TRASH_DIRECTORY/23/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY/23/wt"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 23/
-EOF
- test_repo 23 .git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 23/
-EOF
- test_repo 23 .git ..
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 23/
-EOF
- test_repo 23 "$TRASH_DIRECTORY/23/.git" ..
-'
-
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >23/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 23/
-EOF
- test_repo 23 "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 23/sub/sub/
-EOF
- test_repo 23/sub/sub ../../.git "$TRASH_DIRECTORY"
+ setup_repo 23 non-existent "" true &&
+ mkdir -p 23/sub/sub 23/wt/sub
'
+run_wt_tests 23
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 23/sub/sub/
-EOF
- test_repo 23/sub/sub ../../.git ../../..
+test_expect_success '#24: bare repo has no worktree (gitfile case)' '
+ try_repo 24 unset unset unset gitfile true \
+ "$here/24.git" "(null)" "$here/24" "(null)" \
+ "$here/24.git" "(null)" "$here/24/sub" "(null)"
'
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 23/sub/sub/
-EOF
- test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" ../../../
+test_expect_success '#25: GIT_WORK_TREE accepted if GIT_DIR unset (bare gitfile case)' '
+ try_repo 25 "$here/25" unset unset gitfile true \
+ "$here/25.git" "$here/25" "$here/25" "(null)" \
+ "$here/25.git" "$here/25" "$here/25" "sub/" 2>message &&
+ ! test -s message
'
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >23/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/23/.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 23/sub/sub/
-EOF
- test_repo 23/sub/sub "$TRASH_DIRECTORY/23/.git" "$TRASH_DIRECTORY"
+test_expect_success '#26: bare repo has no worktree (GIT_DIR -> gitfile case)' '
+ try_repo 26 unset "$here/26/.git" unset gitfile true \
+ "$here/26.git" "(null)" "$here/26" "(null)" \
+ "$here/26.git" "(null)" "$here/26/sub" "(null)" &&
+ try_repo 26b unset .git unset gitfile true \
+ "$here/26b.git" "(null)" "$here/26b" "(null)" \
+ "$here/26b.git" "(null)" "$here/26b/sub" "(null)"
'
-#
-# case #24
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# #16.2 except git_dir is set according to .git file
-
-test_expect_success '#24: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 24 24/sub &&
- cd 24 &&
- git init &&
- git config core.bare true &&
- mv .git ../24.git &&
- echo gitdir: ../24.git >.git &&
- cd ..
-'
-
-test_expect_success '#24: at root' '
- cat >24/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/24.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/24
-setup: prefix: (null)
-EOF
- test_repo 24
-'
-
-test_expect_success '#24: in subdir' '
- cat >24/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/24.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/24/sub
-setup: prefix: (null)
-EOF
- test_repo 24/sub
-'
-
-#
-# case #25
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# #17.2 except git_dir is set according to .git file
-
-test_expect_success '#25: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 25 25/sub &&
- cd 25 &&
- git init &&
- git config core.bare true &&
- GIT_WORK_TREE=non-existent &&
- export GIT_WORK_TREE &&
- mv .git ../25.git &&
- echo gitdir: ../25.git >.git &&
- cd ..
-'
-
-test_expect_success '#25: at root' '
- cat >25/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/25.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/25
-setup: prefix: (null)
-EOF
- test_repo 25
-'
-
-test_expect_success '#25: in subdir' '
- cat >25/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/25.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/25/sub
-setup: prefix: (null)
-EOF
- test_repo 25/sub
-'
-
-#
-# case #26
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is not set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# #18 except git_dir is set according to .git file
-
-test_expect_success '#26: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 26 26/sub &&
- cd 26 &&
- git init &&
- git config core.bare true &&
- mv .git ../26.git &&
- echo gitdir: ../26.git >.git &&
- cd ..
-'
-
-test_expect_success '#26: (rel) at root' '
- cat >26/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/26.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/26
-setup: prefix: (null)
-EOF
- test_repo 26 .git
-'
-
-test_expect_success '#26: at root' '
- cat >26/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/26.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/26
-setup: prefix: (null)
-EOF
- test_repo 26 "$TRASH_DIRECTORY/26/.git"
-'
-
-test_expect_success '#26: (rel) in subdir' '
- cat >26/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/26.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/26/sub
-setup: prefix: (null)
-EOF
- test_repo 26/sub ../.git
-'
-
-test_expect_success '#26: in subdir' '
- cat >26/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/26.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/26/sub
-setup: prefix: (null)
-EOF
- test_repo 26/sub "$TRASH_DIRECTORY/26/.git"
-'
-
-#
-# case #27
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - .git is a file
-# - core.worktree is not set
-# - core.bare is set
-#
-# Output:
-#
-# #19 except git_dir is set according to .git file
-
+# Case #27: GIT_DIR + GIT_WORK_TREE suppresses bareness (with gitfile).
test_expect_success '#27: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 27 27/sub 27/sub/sub 27.wt 27.wt/sub 27/wt 27/wt/sub &&
- cd 27 &&
- git init &&
- git config core.bare true &&
- mv .git ../27.git &&
- echo gitdir: ../27.git >.git &&
- cd ..
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: (null)
-EOF
- test_repo 27 .git "$TRASH_DIRECTORY/27"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: (null)
-EOF
- test_repo 27 .git .
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: (null)
-EOF
- test_repo 27 "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY/27"
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: (null)
-EOF
- test_repo 27 "$TRASH_DIRECTORY/27/.git" .
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: sub/sub/
-EOF
- test_repo 27/sub/sub ../../.git "$TRASH_DIRECTORY/27"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: sub/sub/
-EOF
- test_repo 27/sub/sub ../../.git ../..
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >27/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: sub/
-EOF
- test_repo 27/sub "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY/27"
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: sub/sub/
-EOF
- test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" ../..
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27/wt
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: (null)
-EOF
- test_repo 27 .git "$TRASH_DIRECTORY/27/wt"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27/wt
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: (null)
-EOF
- test_repo 27 .git wt
+ setup_repo 27 unset gitfile true &&
+ mkdir -p 27/sub/sub 27/wt/sub
'
+run_wt_tests 27 gitfile
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27/wt
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: (null)
-EOF
- test_repo 27 "$TRASH_DIRECTORY/27/.git" wt
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27/wt
-setup: cwd: $TRASH_DIRECTORY/27
-setup: prefix: (null)
-EOF
- test_repo 27 "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY/27/wt"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27/wt
-setup: cwd: $TRASH_DIRECTORY/27/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 27/sub/sub ../../.git "$TRASH_DIRECTORY/27/wt"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27/wt
-setup: cwd: $TRASH_DIRECTORY/27/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 27/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27/wt
-setup: cwd: $TRASH_DIRECTORY/27/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" ../../wt
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY/27/wt
-setup: cwd: $TRASH_DIRECTORY/27/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY/27/wt"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 27/
-EOF
- test_repo 27 .git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 27/
-EOF
- test_repo 27 .git ..
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 27/
-EOF
- test_repo 27 "$TRASH_DIRECTORY/27/.git" ..
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >27/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 27/
-EOF
- test_repo 27 "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 27/sub/sub/
-EOF
- test_repo 27/sub/sub ../../.git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 27/sub/sub/
-EOF
- test_repo 27/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 27/sub/sub/
-EOF
- test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" ../../../
-'
-
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >27/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/27.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 27/sub/sub/
-EOF
- test_repo 27/sub/sub "$TRASH_DIRECTORY/27/.git" "$TRASH_DIRECTORY"
-'
-
-#
-# case #28
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree is ignored -> #24
-
-test_expect_success '#28: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 28 28/sub &&
- cd 28 &&
- git init &&
- git config core.bare true &&
- git config core.worktree non-existent &&
- mv .git ../28.git &&
- echo gitdir: ../28.git >.git &&
- cd ..
-'
-
-test_expect_success '#28: at root' '
- cat >28/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/28.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/28
-setup: prefix: (null)
-EOF
- test_repo 28
-'
-
-test_expect_success '#28: in subdir' '
- cat >28/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/28.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/28/sub
-setup: prefix: (null)
-EOF
- test_repo 28/sub
+test_expect_success '#28: core.worktree and core.bare conflict (gitfile case)' '
+ setup_repo 28 "$here/28" gitfile true &&
+ (
+ cd 28 &&
+ test_must_fail git symbolic-ref HEAD
+ ) 2>message &&
+ ! grep "^warning:" message &&
+ grep "core.bare and core.worktree" message
'
-#
-# case #29
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is not set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# GIT_WORK_TREE/core.worktree are ignored -> #28
-
+# Case #29: GIT_WORK_TREE(+core.worktree) overrides core.bare (gitfile case).
test_expect_success '#29: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 29 29/sub &&
- cd 29 &&
- git init &&
- git config core.bare true &&
- GIT_WORK_TREE=non-existent &&
- export GIT_WORK_TREE &&
- mv .git ../29.git &&
- echo gitdir: ../29.git >.git &&
- cd ..
-'
-
-test_expect_success '#29: at root' '
- cat >29/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/29.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/29
-setup: prefix: (null)
-EOF
- test_repo 29
-'
-
-test_expect_success '#29: in subdir' '
- cat >29/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/29.git
-setup: worktree: (null)
-setup: cwd: $TRASH_DIRECTORY/29/sub
-setup: prefix: (null)
-EOF
- test_repo 29/sub
-'
-
-#
-# case #30
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is not set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# core.worktree and core.bare conflict, won't fly.
-
-test_expect_success '#30: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 30 &&
- cd 30 &&
- git init &&
- git config core.bare true &&
- git config core.worktree non-existent &&
- mv .git ../30.git &&
- echo gitdir: ../30.git >.git &&
- cd ..
-'
-
-test_expect_success '#30: at root' '
+ setup_repo 29 non-existent gitfile true &&
+ mkdir -p 29/sub/sub 29/wt/sub
(
- cd 30 &&
- GIT_DIR=.git &&
- export GIT_DIR &&
- test_must_fail git symbolic-ref HEAD 2>result &&
- grep "core.bare and core.worktree do not make sense" result
- )
+ cd 29 &&
+ GIT_WORK_TREE="$here/29" &&
+ export GIT_WORK_TREE &&
+ git symbolic-ref HEAD >/dev/null
+ ) 2>message &&
+ ! test -s message
+'
+run_wt_tests 29 gitfile
+
+test_expect_success '#30: core.worktree and core.bare conflict (gitfile version)' '
+ # Just like case #22.
+ setup_repo 30 "$here/30" gitfile true &&
+ (
+ cd 30 &&
+ GIT_DIR=.git &&
+ export GIT_DIR &&
+ test_must_fail git symbolic-ref HEAD 2>result
+ ) &&
+ grep "core.bare and core.worktree" 30/result
'
-#
-# case #31
-#
-############################################################
-#
-# Input:
-#
-# - GIT_WORK_TREE is set
-# - GIT_DIR is set
-# - core.worktree is set
-# - .git is a file
-# - core.bare is set
-#
-# Output:
-#
-# #23 except git_dir is set according to .git file
-
+# Case #31: GIT_DIR + GIT_WORK_TREE(+core.worktree) suppresses
+# bareness (gitfile version).
test_expect_success '#31: setup' '
- sane_unset GIT_DIR GIT_WORK_TREE &&
- mkdir 31 31/sub 31/sub/sub 31.wt 31.wt/sub 31/wt 31/wt/sub &&
- cd 31 &&
- git init &&
- git config core.bare true &&
- git config core.worktree non-existent &&
- mv .git ../31.git &&
- echo gitdir: ../31.git >.git &&
- cd ..
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: (null)
-EOF
- test_repo 31 .git "$TRASH_DIRECTORY/31"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: (null)
-EOF
- test_repo 31 .git .
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: (null)
-EOF
- test_repo 31 "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY/31"
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: (null)
-EOF
- test_repo 31 "$TRASH_DIRECTORY/31/.git" .
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: sub/sub/
-EOF
- test_repo 31/sub/sub ../../.git "$TRASH_DIRECTORY/31"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: sub/sub/
-EOF
- test_repo 31/sub/sub ../../.git ../..
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root in subdir' '
- cat >31/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: sub/
-EOF
- test_repo 31/sub "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY/31"
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: sub/sub/
-EOF
- test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" ../..
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31/wt
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: (null)
-EOF
- test_repo 31 .git "$TRASH_DIRECTORY/31/wt"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31/wt
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: (null)
-EOF
- test_repo 31 .git wt
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31/wt
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: (null)
-EOF
- test_repo 31 "$TRASH_DIRECTORY/31/.git" wt
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31/wt
-setup: cwd: $TRASH_DIRECTORY/31
-setup: prefix: (null)
-EOF
- test_repo 31 "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY/31/wt"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31/wt
-setup: cwd: $TRASH_DIRECTORY/31/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 31/sub/sub ../../.git "$TRASH_DIRECTORY/31/wt"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31/wt
-setup: cwd: $TRASH_DIRECTORY/31/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 31/sub/sub ../../.git ../../wt
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31/wt
-setup: cwd: $TRASH_DIRECTORY/31/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" ../../wt
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY/31/wt
-setup: cwd: $TRASH_DIRECTORY/31/sub/sub
-setup: prefix: (null)
-EOF
- test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY/31/wt"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 31/
-EOF
- test_repo 31 .git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 31/
-EOF
- test_repo 31 .git ..
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 31/
-EOF
- test_repo 31 "$TRASH_DIRECTORY/31/.git" ..
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. at root' '
- cat >31/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 31/
-EOF
- test_repo 31 "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 31/sub/sub/
-EOF
- test_repo 31/sub/sub ../../.git "$TRASH_DIRECTORY"
-'
-
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 31/sub/sub/
-EOF
- test_repo 31/sub/sub ../../.git ../../..
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 31/sub/sub/
-EOF
- test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" ../../../
-'
-
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
- cat >31/sub/sub/expected <<EOF &&
-setup: git_dir: $TRASH_DIRECTORY/31.git
-setup: worktree: $TRASH_DIRECTORY
-setup: cwd: $TRASH_DIRECTORY
-setup: prefix: 31/sub/sub/
-EOF
- test_repo 31/sub/sub "$TRASH_DIRECTORY/31/.git" "$TRASH_DIRECTORY"
+ setup_repo 31 non-existent gitfile true &&
+ mkdir -p 31/sub/sub 31/wt/sub
'
+run_wt_tests 31 gitfile
test_done
diff --git a/t/t2011-checkout-invalid-head.sh b/t/t2011-checkout-invalid-head.sh
index 15ebdc26eb..300f8bf25c 100755
--- a/t/t2011-checkout-invalid-head.sh
+++ b/t/t2011-checkout-invalid-head.sh
@@ -15,7 +15,7 @@ test_expect_success 'checkout should not start branch from a tree' '
'
test_expect_success 'checkout master from invalid HEAD' '
- echo 0000000000000000000000000000000000000000 >.git/HEAD &&
+ echo $_z40 >.git/HEAD &&
git checkout master --
'
diff --git a/t/t2019-checkout-ambiguous-ref.sh b/t/t2019-checkout-ambiguous-ref.sh
new file mode 100755
index 0000000000..cc34e5535b
--- /dev/null
+++ b/t/t2019-checkout-ambiguous-ref.sh
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+test_description='checkout handling of ambiguous (branch/tag) refs'
+. ./test-lib.sh
+
+test_expect_success 'setup ambiguous refs' '
+ test_commit branch file &&
+ git branch ambiguity &&
+ git branch vagueness &&
+ test_commit tag file &&
+ git tag ambiguity &&
+ git tag vagueness HEAD:file &&
+ test_commit other file
+'
+
+test_expect_success 'checkout ambiguous ref succeeds' '
+ git checkout ambiguity >stdout 2>stderr
+'
+
+test_expect_success 'checkout produces ambiguity warning' '
+ grep "warning.*ambiguous" stderr
+'
+
+test_expect_success 'checkout chooses branch over tag' '
+ echo refs/heads/ambiguity >expect &&
+ git symbolic-ref HEAD >actual &&
+ test_cmp expect actual &&
+ echo branch >expect &&
+ test_cmp expect file
+'
+
+test_expect_success C_LOCALE_OUTPUT 'checkout reports switch to branch' '
+ grep "Switched to branch" stderr &&
+ ! grep "^HEAD is now at" stderr
+'
+
+test_expect_success 'checkout vague ref succeeds' '
+ git checkout vagueness >stdout 2>stderr &&
+ test_set_prereq VAGUENESS_SUCCESS
+'
+
+test_expect_success VAGUENESS_SUCCESS 'checkout produces ambiguity warning' '
+ grep "warning.*ambiguous" stderr
+'
+
+test_expect_success VAGUENESS_SUCCESS 'checkout chooses branch over tag' '
+ echo refs/heads/vagueness >expect &&
+ git symbolic-ref HEAD >actual &&
+ test_cmp expect actual &&
+ echo branch >expect &&
+ test_cmp expect file
+'
+
+test_expect_success VAGUENESS_SUCCESS,C_LOCALE_OUTPUT 'checkout reports switch to branch' '
+ grep "Switched to branch" stderr &&
+ ! grep "^HEAD is now at" stderr
+'
+
+test_done
diff --git a/t/t2020-checkout-detach.sh b/t/t2020-checkout-detach.sh
new file mode 100755
index 0000000000..569b27fe8d
--- /dev/null
+++ b/t/t2020-checkout-detach.sh
@@ -0,0 +1,142 @@
+#!/bin/sh
+
+test_description='checkout into detached HEAD state'
+. ./test-lib.sh
+
+check_detached () {
+ test_must_fail git symbolic-ref -q HEAD >/dev/null
+}
+
+check_not_detached () {
+ git symbolic-ref -q HEAD >/dev/null
+}
+
+ORPHAN_WARNING='you are leaving .* commit.*behind'
+check_orphan_warning() {
+ grep "$ORPHAN_WARNING" "$1"
+}
+check_no_orphan_warning() {
+ ! grep "$ORPHAN_WARNING" "$1"
+}
+
+reset () {
+ git checkout master &&
+ check_not_detached
+}
+
+test_expect_success 'setup' '
+ test_commit one &&
+ test_commit two &&
+ test_commit three && git tag -d three &&
+ test_commit four && git tag -d four &&
+ git branch branch &&
+ git tag tag
+'
+
+test_expect_success 'checkout branch does not detach' '
+ reset &&
+ git checkout branch &&
+ check_not_detached
+'
+
+test_expect_success 'checkout tag detaches' '
+ reset &&
+ git checkout tag &&
+ check_detached
+'
+
+test_expect_success 'checkout branch by full name detaches' '
+ reset &&
+ git checkout refs/heads/branch &&
+ check_detached
+'
+
+test_expect_success 'checkout non-ref detaches' '
+ reset &&
+ git checkout branch^ &&
+ check_detached
+'
+
+test_expect_success 'checkout ref^0 detaches' '
+ reset &&
+ git checkout branch^0 &&
+ check_detached
+'
+
+test_expect_success 'checkout --detach detaches' '
+ reset &&
+ git checkout --detach branch &&
+ check_detached
+'
+
+test_expect_success 'checkout --detach without branch name' '
+ reset &&
+ git checkout --detach &&
+ check_detached
+'
+
+test_expect_success 'checkout --detach errors out for non-commit' '
+ reset &&
+ test_must_fail git checkout --detach one^{tree} &&
+ check_not_detached
+'
+
+test_expect_success 'checkout --detach errors out for extra argument' '
+ reset &&
+ git checkout master &&
+ test_must_fail git checkout --detach tag one.t &&
+ check_not_detached
+'
+
+test_expect_success 'checkout --detached and -b are incompatible' '
+ reset &&
+ test_must_fail git checkout --detach -b newbranch tag &&
+ check_not_detached
+'
+
+test_expect_success 'checkout --detach moves HEAD' '
+ reset &&
+ git checkout one &&
+ git checkout --detach two &&
+ git diff --exit-code HEAD &&
+ git diff --exit-code two
+'
+
+test_expect_success 'checkout warns on orphan commits' '
+ reset &&
+ git checkout --detach two &&
+ echo content >orphan &&
+ git add orphan &&
+ git commit -a -m orphan &&
+ git checkout master 2>stderr &&
+ check_orphan_warning stderr
+'
+
+test_expect_success 'checkout does not warn leaving ref tip' '
+ reset &&
+ git checkout --detach two &&
+ git checkout master 2>stderr &&
+ check_no_orphan_warning stderr
+'
+
+test_expect_success 'checkout does not warn leaving reachable commit' '
+ reset &&
+ git checkout --detach HEAD^ &&
+ git checkout master 2>stderr &&
+ check_no_orphan_warning stderr
+'
+
+cat >expect <<'EOF'
+Your branch is behind 'master' by 1 commit, and can be fast-forwarded.
+EOF
+test_expect_success 'tracking count is accurate after orphan check' '
+ reset &&
+ git branch child master^ &&
+ git config branch.child.remote . &&
+ git config branch.child.merge refs/heads/master &&
+ git checkout child^ &&
+ git checkout child >stdout &&
+ test_cmp expect stdout
+'
+
+test_done
diff --git a/t/t2021-checkout-overwrite.sh b/t/t2021-checkout-overwrite.sh
new file mode 100755
index 0000000000..5da63e9fa2
--- /dev/null
+++ b/t/t2021-checkout-overwrite.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+test_description='checkout must not overwrite an untracked objects'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+ mkdir -p a/b/c &&
+ >a/b/c/d &&
+ git add -A &&
+ git commit -m base &&
+ git tag start
+'
+
+test_expect_success 'create a commit where dir a/b changed to file' '
+
+ git checkout -b file &&
+ rm -rf a/b &&
+ >a/b &&
+ git add -A &&
+ git commit -m "dir to file"
+'
+
+test_expect_success 'checkout commit with dir must not remove untracked a/b' '
+
+ git rm --cached a/b &&
+ git commit -m "un-track the file" &&
+ test_must_fail git checkout start &&
+ test -f a/b
+'
+
+test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink' '
+
+ rm -rf a/b && # cleanup if previous test failed
+ git checkout -f -b symlink start &&
+ rm -rf a/b &&
+ ln -s foo a/b &&
+ git add -A &&
+ git commit -m "dir to symlink"
+'
+
+test_expect_success SYMLINKS 'checkout commit with dir must not remove untracked a/b' '
+
+ git rm --cached a/b &&
+ git commit -m "un-track the symlink" &&
+ test_must_fail git checkout start &&
+ test -h a/b
+'
+
+test_done
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index 0692427cb6..7206c13741 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -111,7 +111,7 @@ test_expect_success 'touch and then add explicitly' '
'
-test_expect_success 'add -n -u should not add but just report' '
+test_expect_success C_LOCALE_OUTPUT 'add -n -u should not add but just report' '
(
echo "add '\''check'\''" &&
@@ -149,31 +149,21 @@ test_expect_success 'add -u resolves unmerged paths' '
echo 3 >path1 &&
echo 2 >path3 &&
echo 2 >path5 &&
- git add -u &&
- git ls-files -s path1 path2 path3 path4 path5 path6 >actual &&
- {
- echo "100644 $three 0 path1"
- echo "100644 $one 1 path3"
- echo "100644 $one 1 path4"
- echo "100644 $one 3 path5"
- echo "100644 $one 3 path6"
- } >expect &&
- test_cmp expect actual &&
- # Bonus tests. Explicit resolving
- git add path3 path5 &&
+ # Explicit resolving by adding removed paths should fail
test_must_fail git add path4 &&
test_must_fail git add path6 &&
- git rm path4 &&
- git rm path6 &&
- git ls-files -s "path?" >actual &&
+ # "add -u" should notice removals no matter what stages
+ # the index entries are in.
+ git add -u &&
+ git ls-files -s path1 path2 path3 path4 path5 path6 >actual &&
{
echo "100644 $three 0 path1"
echo "100644 $two 0 path3"
echo "100644 $two 0 path5"
- } >expect
-
+ } >expect &&
+ test_cmp expect actual
'
test_expect_success '"add -u non-existent" should fail' '
diff --git a/t/t2201-add-update-typechange.sh b/t/t2201-add-update-typechange.sh
index 2e8f702452..954fc51e5b 100755
--- a/t/t2201-add-update-typechange.sh
+++ b/t/t2201-add-update-typechange.sh
@@ -4,8 +4,6 @@ test_description='more git add -u'
. ./test-lib.sh
-_z40=0000000000000000000000000000000000000000
-
test_expect_success setup '
>xyzzy &&
_empty=$(git hash-object --stdin <xyzzy) &&
diff --git a/t/t2204-add-ignored.sh b/t/t2204-add-ignored.sh
index 24afdabab7..49753362f0 100755
--- a/t/t2204-add-ignored.sh
+++ b/t/t2204-add-ignored.sh
@@ -31,18 +31,21 @@ do
rm -f .git/index &&
test_must_fail git add "$i" 2>err &&
git ls-files "$i" >out &&
- ! test -s out &&
- grep -e "Use -f if" err &&
- cat err
+ ! test -s out
+ '
+
+ test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i output" '
+ grep -e "Use -f if" err
'
test_expect_success "complaints for ignored $i with unignored file" '
rm -f .git/index &&
test_must_fail git add "$i" file 2>err &&
git ls-files "$i" >out &&
- ! test -s out &&
- grep -e "Use -f if" err &&
- cat err
+ ! test -s out
+ '
+ test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i with unignored file output" '
+ grep -e "Use -f if" err
'
done
@@ -54,9 +57,14 @@ do
cd dir &&
test_must_fail git add "$i" 2>err &&
git ls-files "$i" >out &&
- ! test -s out &&
- grep -e "Use -f if" err &&
- cat err
+ ! test -s out
+ )
+ '
+
+ test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in dir output" '
+ (
+ cd dir &&
+ grep -e "Use -f if" err
)
'
done
@@ -69,9 +77,14 @@ do
cd sub &&
test_must_fail git add "$i" 2>err &&
git ls-files "$i" >out &&
- ! test -s out &&
- grep -e "Use -f if" err &&
- cat err
+ ! test -s out
+ )
+ '
+
+ test_expect_success C_LOCALE_OUTPUT "complaints for ignored $i in sub output" '
+ (
+ cd sub &&
+ grep -e "Use -f if" err
)
'
done
diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh
index 34794f8a70..806fdccce1 100755
--- a/t/t3030-merge-recursive.sh
+++ b/t/t3030-merge-recursive.sh
@@ -312,7 +312,7 @@ test_expect_success 'merge-recursive result' '
'
-test_expect_success 'fail if the index has unresolved entries' '
+test_expect_success C_LOCALE_OUTPUT 'fail if the index has unresolved entries' '
rm -fr [abcd] &&
git checkout -f "$c1" &&
diff --git a/t/t3032-merge-recursive-options.sh b/t/t3032-merge-recursive-options.sh
index 44f5421be4..2b17311cb0 100755
--- a/t/t3032-merge-recursive-options.sh
+++ b/t/t3032-merge-recursive-options.sh
@@ -110,6 +110,20 @@ test_expect_success '--ignore-space-change makes merge succeed' '
git merge-recursive --ignore-space-change HEAD^ -- HEAD remote
'
+test_expect_success 'naive cherry-pick fails' '
+ git read-tree --reset -u HEAD &&
+ test_must_fail git cherry-pick --no-commit remote &&
+ git read-tree --reset -u HEAD &&
+ test_must_fail git cherry-pick remote &&
+ test_must_fail git update-index --refresh &&
+ grep "<<<<<<" text.txt
+'
+
+test_expect_success '-Xignore-space-change makes cherry-pick succeed' '
+ git read-tree --reset -u HEAD &&
+ git cherry-pick --no-commit -Xignore-space-change remote
+'
+
test_expect_success '--ignore-space-change: our w/s-only change wins' '
q_to_cr <<-\EOF >expected &&
justice and holiness and is the nurse of his age and theQ
diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh
index f308235f5d..463ef1909f 100755
--- a/t/t3200-branch.sh
+++ b/t/t3200-branch.sh
@@ -46,7 +46,7 @@ test_expect_success \
'git branch a/b/c && test -f .git/refs/heads/a/b/c'
cat >expect <<EOF
-0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
+$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
EOF
test_expect_success \
'git branch -l d/e/f should create a branch and a log' \
@@ -203,7 +203,7 @@ test_expect_success 'test deleting branch deletes branch config' \
test -z "$(git config branch.my7.remote)" &&
test -z "$(git config branch.my7.merge)"'
-test_expect_success 'test deleting branch without config' \
+test_expect_success C_LOCALE_OUTPUT 'test deleting branch without config' \
'git branch my7 s &&
sha1=$(git rev-parse my7 | cut -c 1-7) &&
test "$(git branch -d my7 2>&1)" = "Deleted branch my7 (was $sha1)."'
@@ -223,9 +223,14 @@ test_expect_success \
'branch from non-branch HEAD w/--track causes failure' \
'test_must_fail git branch --track my10 HEAD^'
+test_expect_success \
+ 'branch from tag w/--track causes failure' \
+ 'git tag foobar &&
+ test_must_fail git branch --track my11 foobar'
+
# Keep this test last, as it changes the current branch
cat >expect <<EOF
-0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
+$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
EOF
test_expect_success \
'git checkout -b g/h/i -l should create a branch and a log' \
@@ -488,6 +493,15 @@ test_expect_success 'autosetuprebase always on an untracked remote branch' '
test "z$(git config branch.myr20.rebase)" = z
'
+test_expect_success 'autosetuprebase always on detached HEAD' '
+ git config branch.autosetupmerge always &&
+ test_when_finished git checkout master &&
+ git checkout HEAD^0 &&
+ git branch my11 &&
+ test -z "$(git config branch.my11.remote)" &&
+ test -z "$(git config branch.my11.merge)"
+'
+
test_expect_success 'detect misconfigured autosetuprebase (bad value)' '
git config branch.autosetuprebase garbage &&
test_must_fail git branch
diff --git a/t/t3203-branch-output.sh b/t/t3203-branch-output.sh
index 6028748c6c..4ef7d09115 100755
--- a/t/t3203-branch-output.sh
+++ b/t/t3203-branch-output.sh
@@ -72,7 +72,7 @@ cat >expect <<'EOF'
branch-two
master
EOF
-test_expect_success 'git branch shows detached HEAD properly' '
+test_expect_success C_LOCALE_OUTPUT 'git branch shows detached HEAD properly' '
git checkout HEAD^0 &&
git branch >actual &&
test_cmp expect actual
diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh
index c4282179b3..86bf909ee3 100755
--- a/t/t3306-notes-prune.sh
+++ b/t/t3306-notes-prune.sh
@@ -20,6 +20,9 @@ test_expect_success 'setup: create a few commits with notes' '
git add file3 &&
test_tick &&
git commit -m 3rd &&
+ COMMIT_FILE=.git/objects/5e/e1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+ test -f $COMMIT_FILE &&
+ test-chmtime =+0 $COMMIT_FILE &&
git notes add -m "Note #3"
'
diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh
index 19341e5ca1..08201e2331 100755
--- a/t/t3409-rebase-preserve-merges.sh
+++ b/t/t3409-rebase-preserve-merges.sh
@@ -27,7 +27,17 @@ export GIT_AUTHOR_EMAIL
# \
# B2 <-- origin/topic
#
-# In both cases, 'topic' is rebased onto 'origin/topic'.
+# Clone 3 (no-ff merge):
+#
+# A1--A2--B3 <-- origin/master
+# \
+# B1------M <-- topic
+# \ /
+# \--A3 <-- topic2
+# \
+# B2 <-- origin/topic
+#
+# In all cases, 'topic' is rebased onto 'origin/topic'.
test_expect_success 'setup for merge-preserving rebase' \
'echo First > A &&
@@ -61,6 +71,16 @@ test_expect_success 'setup for merge-preserving rebase' \
git commit -m "Merge origin/master into topic"
) &&
+ git clone ./. clone3 &&
+ (
+ cd clone3 &&
+ git checkout -b topic2 origin/topic &&
+ echo Sixth > A &&
+ git commit -a -m "Modify A3" &&
+ git checkout -b topic origin/topic &&
+ git merge --no-ff topic2
+ ) &&
+
git checkout topic &&
echo Fourth >> B &&
git commit -a -m "Modify B2"
@@ -93,4 +113,14 @@ test_expect_success '--continue works after a conflict' '
)
'
+test_expect_success 'rebase -p preserves no-ff merges' '
+ (
+ cd clone3 &&
+ git fetch &&
+ git rebase -p origin/topic &&
+ test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) &&
+ test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l)
+ )
+'
+
test_done
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
index 043954422c..753a6c972c 100755
--- a/t/t3501-revert-cherry-pick.sh
+++ b/t/t3501-revert-cherry-pick.sh
@@ -91,7 +91,7 @@ test_expect_success 'cherry-pick on stat-dirty working tree' '
)
'
-test_expect_success 'revert forbidden on dirty working tree' '
+test_expect_success C_LOCALE_OUTPUT 'revert forbidden on dirty working tree' '
echo content >extra_file &&
git add extra_file &&
diff --git a/t/t3503-cherry-pick-root.sh b/t/t3503-cherry-pick-root.sh
index b0faa29918..9aefe3a1be 100755
--- a/t/t3503-cherry-pick-root.sh
+++ b/t/t3503-cherry-pick-root.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-test_description='test cherry-picking a root commit'
+test_description='test cherry-picking (and reverting) a root commit'
. ./test-lib.sh
@@ -23,7 +23,30 @@ test_expect_success setup '
test_expect_success 'cherry-pick a root commit' '
git cherry-pick master &&
- test first = $(cat file1)
+ echo first >expect &&
+ test_cmp expect file1
+
+'
+
+test_expect_success 'revert a root commit' '
+
+ git revert master &&
+ test_path_is_missing file1
+
+'
+
+test_expect_success 'cherry-pick a root commit with an external strategy' '
+
+ git cherry-pick --strategy=resolve master &&
+ echo first >expect &&
+ test_cmp expect file1
+
+'
+
+test_expect_success 'revert a root commit with an external strategy' '
+
+ git revert --strategy=resolve master &&
+ test_path_is_missing file1
'
diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
index 607bf25d8f..c0c8330c20 100755
--- a/t/t3507-cherry-pick-conflict.sh
+++ b/t/t3507-cherry-pick-conflict.sh
@@ -11,6 +11,18 @@ test_description='test cherry-pick and revert with conflicts
. ./test-lib.sh
+test_cmp_rev () {
+ git rev-parse --verify "$1" >expect.rev &&
+ git rev-parse --verify "$2" >actual.rev &&
+ test_cmp expect.rev actual.rev
+}
+
+pristine_detach () {
+ git checkout -f "$1^0" &&
+ git read-tree -u --reset HEAD &&
+ git clean -d -f -f -q -x
+}
+
test_expect_success setup '
echo unrelated >unrelated &&
@@ -23,13 +35,7 @@ test_expect_success setup '
'
test_expect_success 'failed cherry-pick does not advance HEAD' '
-
- git checkout -f initial^0 &&
- git read-tree -u --reset HEAD &&
- git clean -d -f -f -q -x &&
-
- git update-index --refresh &&
- git diff-index --exit-code HEAD &&
+ pristine_detach initial &&
head=$(git rev-parse HEAD) &&
test_must_fail git cherry-pick picked &&
@@ -38,34 +44,97 @@ test_expect_success 'failed cherry-pick does not advance HEAD' '
test "$head" = "$newhead"
'
-test_expect_success 'advice from failed cherry-pick' "
- git checkout -f initial^0 &&
- git read-tree -u --reset HEAD &&
- git clean -d -f -f -q -x &&
-
- git update-index --refresh &&
- git diff-index --exit-code HEAD &&
+test_expect_success C_LOCALE_OUTPUT 'advice from failed cherry-pick' "
+ pristine_detach initial &&
picked=\$(git rev-parse --short picked) &&
cat <<-EOF >expected &&
error: could not apply \$picked... picked
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
- hint: and commit the result with 'git commit -c \$picked'
+ hint: and commit the result with 'git commit'
EOF
test_must_fail git cherry-pick picked 2>actual &&
test_cmp expected actual
"
-test_expect_success 'failed cherry-pick produces dirty index' '
+test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '
+ pristine_detach initial &&
+ test_must_fail git cherry-pick picked &&
+ test_cmp_rev picked CHERRY_PICK_HEAD
+'
- git checkout -f initial^0 &&
- git read-tree -u --reset HEAD &&
- git clean -d -f -f -q -x &&
+test_expect_success 'successful cherry-pick does not set CHERRY_PICK_HEAD' '
+ pristine_detach initial &&
+ git cherry-pick base &&
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
+test_expect_success 'cherry-pick --no-commit does not set CHERRY_PICK_HEAD' '
+ pristine_detach initial &&
+ git cherry-pick --no-commit base &&
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
+test_expect_success 'GIT_CHERRY_PICK_HELP suppresses CHERRY_PICK_HEAD' '
+ pristine_detach initial &&
+ (
+ GIT_CHERRY_PICK_HELP="and then do something else" &&
+ export GIT_CHERRY_PICK_HELP &&
+ test_must_fail git cherry-pick picked
+ ) &&
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
+test_expect_success 'git reset clears CHERRY_PICK_HEAD' '
+ pristine_detach initial &&
+
+ test_must_fail git cherry-pick picked &&
+ git reset &&
+
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
+test_expect_success 'failed commit does not clear CHERRY_PICK_HEAD' '
+ pristine_detach initial &&
+
+ test_must_fail git cherry-pick picked &&
+ test_must_fail git commit &&
+
+ test_cmp_rev picked CHERRY_PICK_HEAD
+'
+
+test_expect_success 'cancelled commit does not clear CHERRY_PICK_HEAD' '
+ pristine_detach initial &&
- git update-index --refresh &&
- git diff-index --exit-code HEAD &&
+ test_must_fail git cherry-pick picked &&
+ echo resolved >foo &&
+ git add foo &&
+ git update-index --refresh -q &&
+ test_must_fail git diff-index --exit-code HEAD &&
+ (
+ GIT_EDITOR=false &&
+ export GIT_EDITOR &&
+ test_must_fail git commit
+ ) &&
+
+ test_cmp_rev picked CHERRY_PICK_HEAD
+'
+
+test_expect_success 'successful commit clears CHERRY_PICK_HEAD' '
+ pristine_detach initial &&
+
+ test_must_fail git cherry-pick picked &&
+ echo resolved >foo &&
+ git add foo &&
+ git commit &&
+
+ test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
+'
+
+test_expect_success 'failed cherry-pick produces dirty index' '
+ pristine_detach initial &&
test_must_fail git cherry-pick picked &&
@@ -74,9 +143,7 @@ test_expect_success 'failed cherry-pick produces dirty index' '
'
test_expect_success 'failed cherry-pick registers participants in index' '
-
- git read-tree -u --reset HEAD &&
- git clean -d -f -f -q -x &&
+ pristine_detach initial &&
{
git checkout base -- foo &&
git ls-files --stage foo &&
@@ -90,10 +157,7 @@ test_expect_success 'failed cherry-pick registers participants in index' '
2 s/ 0 / 2 /
3 s/ 0 / 3 /
" < stages > expected &&
- git checkout -f initial^0 &&
-
- git update-index --refresh &&
- git diff-index --exit-code HEAD &&
+ git read-tree -u --reset HEAD &&
test_must_fail git cherry-pick picked &&
git ls-files --stage --unmerged > actual &&
@@ -102,10 +166,7 @@ test_expect_success 'failed cherry-pick registers participants in index' '
'
test_expect_success 'failed cherry-pick describes conflict in work tree' '
-
- git checkout -f initial^0 &&
- git read-tree -u --reset HEAD &&
- git clean -d -f -f -q -x &&
+ pristine_detach initial &&
cat <<-EOF > expected &&
<<<<<<< HEAD
a
@@ -114,9 +175,6 @@ test_expect_success 'failed cherry-pick describes conflict in work tree' '
>>>>>>> objid picked
EOF
- git update-index --refresh &&
- git diff-index --exit-code HEAD &&
-
test_must_fail git cherry-pick picked &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
@@ -124,11 +182,8 @@ test_expect_success 'failed cherry-pick describes conflict in work tree' '
'
test_expect_success 'diff3 -m style' '
-
+ pristine_detach initial &&
git config merge.conflictstyle diff3 &&
- git checkout -f initial^0 &&
- git read-tree -u --reset HEAD &&
- git clean -d -f -f -q -x &&
cat <<-EOF > expected &&
<<<<<<< HEAD
a
@@ -139,9 +194,6 @@ test_expect_success 'diff3 -m style' '
>>>>>>> objid picked
EOF
- git update-index --refresh &&
- git diff-index --exit-code HEAD &&
-
test_must_fail git cherry-pick picked &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
@@ -149,10 +201,8 @@ test_expect_success 'diff3 -m style' '
'
test_expect_success 'revert also handles conflicts sanely' '
-
git config --unset merge.conflictstyle &&
- git read-tree -u --reset HEAD &&
- git clean -d -f -f -q -x &&
+ pristine_detach initial &&
cat <<-EOF > expected &&
<<<<<<< HEAD
a
@@ -173,10 +223,7 @@ test_expect_success 'revert also handles conflicts sanely' '
2 s/ 0 / 2 /
3 s/ 0 / 3 /
" < stages > expected-stages &&
- git checkout -f initial^0 &&
-
- git update-index --refresh &&
- git diff-index --exit-code HEAD &&
+ git read-tree -u --reset HEAD &&
head=$(git rev-parse HEAD) &&
test_must_fail git revert picked &&
@@ -192,10 +239,8 @@ test_expect_success 'revert also handles conflicts sanely' '
'
test_expect_success 'revert conflict, diff3 -m style' '
+ pristine_detach initial &&
git config merge.conflictstyle diff3 &&
- git checkout -f initial^0 &&
- git read-tree -u --reset HEAD &&
- git clean -d -f -f -q -x &&
cat <<-EOF > expected &&
<<<<<<< HEAD
a
@@ -206,9 +251,6 @@ test_expect_success 'revert conflict, diff3 -m style' '
>>>>>>> parent of objid picked
EOF
- git update-index --refresh &&
- git diff-index --exit-code HEAD &&
-
test_must_fail git revert picked &&
sed "s/[a-f0-9]*\.\.\./objid/" foo > actual &&
diff --git a/t/t3509-cherry-pick-merge-df.sh b/t/t3509-cherry-pick-merge-df.sh
index 948ca1bce6..df921d1f33 100755
--- a/t/t3509-cherry-pick-merge-df.sh
+++ b/t/t3509-cherry-pick-merge-df.sh
@@ -3,12 +3,14 @@
test_description='Test cherry-pick with directory/file conflicts'
. ./test-lib.sh
-test_expect_success SYMLINKS 'Setup rename across paths each below D/F conflicts' '
+test_expect_success 'Initialize repository' '
mkdir a &&
>a/f &&
git add a &&
- git commit -m a &&
+ git commit -m a
+'
+test_expect_success SYMLINKS 'Setup rename across paths each below D/F conflicts' '
mkdir b &&
ln -s ../a b/a &&
git add b &&
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index cd093bd347..9fd28bcf34 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -240,11 +240,10 @@ test_expect_success 'refresh index before checking if it is up-to-date' '
test_expect_success 'choking "git rm" should not let it die with cruft' '
git reset -q --hard &&
- H=0000000000000000000000000000000000000000 &&
i=0 &&
while test $i -lt 12000
do
- echo "100644 $H 0 some-file-$i"
+ echo "100644 $_z40 0 some-file-$i"
i=$(( $i + 1 ))
done | git update-index --index-info &&
git rm -n "some-file-*" | :;
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index ec7108358e..7de42faf48 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -268,8 +268,12 @@ test_expect_success 'git add --dry-run of existing changed file' "
test_expect_success 'git add --dry-run of non-existing file' "
echo ignored-file >>.gitignore &&
- test_must_fail git add --dry-run track-this ignored-file >actual 2>&1 &&
- echo \"fatal: pathspec 'ignored-file' did not match any files\" | test_cmp - actual
+ test_must_fail git add --dry-run track-this ignored-file >actual 2>&1
+"
+
+test_expect_success C_LOCALE_OUTPUT 'git add --dry-run of an existing file output' "
+ echo \"fatal: pathspec 'ignored-file' did not match any files\" >expect &&
+ test_cmp expect actual
"
cat >expect.err <<\EOF
@@ -283,7 +287,10 @@ add 'track-this'
EOF
test_expect_success 'git add --dry-run --ignore-missing of non-existing file' '
- test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err &&
+ test_must_fail git add --dry-run --ignore-missing track-this ignored-file >actual.out 2>actual.err
+'
+
+test_expect_success C_LOCALE_OUTPUT 'git add --dry-run --ignore-missing of non-existing file output' '
test_cmp expect.out actual.out &&
test_cmp expect.err actual.err
'
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index d6327e7c74..9e236f9cc0 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -82,10 +82,9 @@ EOF
'
test_expect_success PERL 'setup fake editor' '
- cat >fake_editor.sh <<EOF
- EOF
+ >fake_editor.sh &&
chmod a+x fake_editor.sh &&
- test_set_editor "$(pwd)/fake_editor.sh" &&
+ test_set_editor "$(pwd)/fake_editor.sh"
'
test_expect_success PERL 'dummy edit works' '
@@ -295,4 +294,40 @@ test_expect_success PERL 'deleting an empty file' '
test_cmp expected diff
'
+test_expect_success PERL 'split hunk setup' '
+ git reset --hard &&
+ for i in 10 20 30 40 50 60
+ do
+ echo $i
+ done >test &&
+ git add test &&
+ test_tick &&
+ git commit -m test &&
+
+ for i in 10 15 20 21 22 23 24 30 40 50 60
+ do
+ echo $i
+ done >test
+'
+
+test_expect_success PERL 'split hunk "add -p (edit)"' '
+ # Split, say Edit and do nothing. Then:
+ #
+ # 1. Broken version results in a patch that does not apply and
+ # only takes [y/n] (edit again) so the first q is discarded
+ # and then n attempts to discard the edit. Repeat q enough
+ # times to get out.
+ #
+ # 2. Correct version applies the (not)edited version, and asks
+ # about the next hunk, against wich we say q and program
+ # exits.
+ for a in s e q n q q
+ do
+ echo $a
+ done |
+ EDITOR=: git add -p &&
+ git diff >actual &&
+ ! grep "^+15" actual
+'
+
test_done
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 6fd560ccf1..5c72540642 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -37,14 +37,32 @@ test_expect_success 'parents of stash' '
test_cmp output expect
'
-test_expect_success 'apply needs clean working directory' '
- echo 4 > other-file &&
+test_expect_success 'applying bogus stash does nothing' '
+ test_must_fail git stash apply stash@{1} &&
+ echo 1 >expect &&
+ test_cmp expect file
+'
+
+test_expect_success 'apply does not need clean working directory' '
+ echo 4 >other-file &&
git add other-file &&
- echo 5 > other-file &&
- test_must_fail git stash apply
+ echo 5 >other-file &&
+ git stash apply &&
+ echo 3 >expect &&
+ test_cmp expect file
+'
+
+test_expect_success 'apply does not clobber working directory changes' '
+ git reset --hard &&
+ echo 4 >file &&
+ test_must_fail git stash apply &&
+ echo 4 >expect &&
+ test_cmp expect file
'
test_expect_success 'apply stashed changes' '
+ git reset --hard &&
+ echo 5 >other-file &&
git add other-file &&
test_tick &&
git commit -m other-file &&
@@ -218,6 +236,14 @@ test_expect_success 'stash -k' '
test bar,bar4 = $(cat file),$(cat file2)
'
+test_expect_success 'stash --no-keep-index' '
+ echo bar33 > file &&
+ echo bar44 > file2 &&
+ git add file2 &&
+ git stash --no-keep-index &&
+ test bar,bar2 = $(cat file),$(cat file2)
+'
+
test_expect_success 'stash --invalid-option' '
echo bar5 > file &&
echo bar6 > file2 &&
@@ -537,11 +563,11 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '
echo bar6 > file2 &&
git add file2 &&
git stash &&
- test_must_fail git drop stash@{1} &&
- test_must_fail git pop stash@{1} &&
- test_must_fail git apply stash@{1} &&
- test_must_fail git show stash@{1} &&
- test_must_fail git branch tmp stash@{1} &&
+ test_must_fail git stash drop stash@{1} &&
+ test_must_fail git stash pop stash@{1} &&
+ test_must_fail git stash apply stash@{1} &&
+ test_must_fail git stash show stash@{1} &&
+ test_must_fail git stash branch tmp stash@{1} &&
git stash drop
'
@@ -556,4 +582,23 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
git rev-parse stash@{0} --
'
+test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
+ git stash clear &&
+ echo 1 >subdir/subfile1 &&
+ echo 2 >subdir/subfile2 &&
+ git add subdir/subfile1 &&
+ git commit -m subdir &&
+ (
+ cd subdir &&
+ echo x >subfile1 &&
+ echo x >../file &&
+ git status >../expect &&
+ git stash &&
+ sane_unset GIT_MERGE_VERBOSITY &&
+ git stash apply
+ ) |
+ sed -e 1,2d >actual && # drop "Saved..." and "HEAD is now..."
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t3904-stash-patch.sh b/t/t3904-stash-patch.sh
index 1e7193ac0b..781fd71681 100755
--- a/t/t3904-stash-patch.sh
+++ b/t/t3904-stash-patch.sh
@@ -48,6 +48,18 @@ test_expect_success PERL 'git stash -p --no-keep-index' '
verify_state bar dummy bar_index
'
+test_expect_success PERL 'git stash --no-keep-index -p' '
+ set_state dir/foo work index &&
+ set_state bar bar_work bar_index &&
+ (echo n; echo y) | git stash save --no-keep-index -p &&
+ verify_state dir/foo head head &&
+ verify_state bar bar_work dummy &&
+ git reset --hard &&
+ git stash apply --index &&
+ verify_state dir/foo work index &&
+ verify_state bar dummy bar_index
+'
+
test_expect_success PERL 'none of this moved HEAD' '
verify_saved_head
'
diff --git a/t/t4001-diff-rename.sh b/t/t4001-diff-rename.sh
index 71bac83dd5..cad85450b7 100755
--- a/t/t4001-diff-rename.sh
+++ b/t/t4001-diff-rename.sh
@@ -64,7 +64,7 @@ test_expect_success \
'validate the output.' \
'compare_diff_patch current expected'
-test_expect_success 'favour same basenames over different ones' '
+test_expect_success C_LOCALE_OUTPUT 'favour same basenames over different ones' '
cp path1 another-path &&
git add another-path &&
git commit -m 1 &&
@@ -73,7 +73,7 @@ test_expect_success 'favour same basenames over different ones' '
git mv another-path subdir/path1 &&
git status | grep "renamed: .*path1 -> subdir/path1"'
-test_expect_success 'favour same basenames even with minor differences' '
+test_expect_success C_LOCALE_OUTPUT 'favour same basenames even with minor differences' '
git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
git status | grep "renamed: .*path1 -> subdir/path1"'
diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh
index 9fb8ca06a8..a5e8b83083 100755
--- a/t/t4002-diff-basic.sh
+++ b/t/t4002-diff-basic.sh
@@ -126,15 +126,12 @@ cat >.test-recursive-AB <<\EOF
:100644 100644 3fdbe17fd013303a2e981e1ca1c6cd6e72789087 7e09d6a3a14bd630913e8c75693cea32157b606d M Z/NM
EOF
-x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-x40="$x40$x40$x40$x40$x40$x40$x40$x40"
-z40='0000000000000000000000000000000000000000'
cmp_diff_files_output () {
# diff-files never reports additions. Also it does not fill in the
# object ID for the changed files because it wants you to look at the
# filesystem.
sed <"$2" >.test-tmp \
- -e '/^:000000 /d;s/'$x40'\( [MCRNDU][0-9]*\) /'$z40'\1 /' &&
+ -e '/^:000000 /d;s/'$_x40'\( [MCRNDU][0-9]*\) /'$_z40'\1 /' &&
test_cmp "$1" .test-tmp
}
diff --git a/t/t4003-diff-rename-1.sh b/t/t4003-diff-rename-1.sh
index c6130c4019..bfa8835638 100755
--- a/t/t4003-diff-rename-1.sh
+++ b/t/t4003-diff-rename-1.sh
@@ -29,7 +29,7 @@ test_expect_success \
# copy-and-edit one, and rename-and-edit the other. We do not say
# anything about rezrov.
-GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current
+GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current
cat >expected <<\EOF
diff --git a/COPYING b/COPYING.1
copy from COPYING
diff --git a/t/t4004-diff-rename-symlink.sh b/t/t4004-diff-rename-symlink.sh
index 92a65f4852..6e562c80d1 100755
--- a/t/t4004-diff-rename-symlink.sh
+++ b/t/t4004-diff-rename-symlink.sh
@@ -35,7 +35,7 @@ test_expect_success SYMLINKS \
# a new creation.
test_expect_success SYMLINKS 'setup diff output' "
- GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current &&
+ GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current &&
cat >expected <<\EOF
diff --git a/bozbar b/bozbar
new file mode 120000
diff --git a/t/t4005-diff-rename-2.sh b/t/t4005-diff-rename-2.sh
index 1ba359d478..77d7f4946f 100755
--- a/t/t4005-diff-rename-2.sh
+++ b/t/t4005-diff-rename-2.sh
@@ -29,7 +29,7 @@ test_expect_success \
# and COPYING.2 are based on COPYING, and do not say anything about
# rezrov.
-git diff-index -M $tree >current
+git diff-index -C $tree >current
cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh
index d79d9e1e71..73b4a24f5e 100755
--- a/t/t4008-diff-break-rewrite.sh
+++ b/t/t4008-diff-break-rewrite.sh
@@ -173,8 +173,8 @@ test_expect_success \
'compare_diff_raw expected current'
test_expect_success \
- 'run diff with -B -M' \
- 'git diff-index -B -M "$tree" >current'
+ 'run diff with -B -C' \
+ 'git diff-index -B -C "$tree" >current'
cat >expected <<\EOF
:100644 100644 f5deac7be59e7eeab8657fd9ae706fd6a57daed2 08bb2fb671deff4c03a4d4a0a1315dff98d5732c C095 file0 file1
diff --git a/t/t4009-diff-rename-4.sh b/t/t4009-diff-rename-4.sh
index de3f17478e..f22c8e3dba 100755
--- a/t/t4009-diff-rename-4.sh
+++ b/t/t4009-diff-rename-4.sh
@@ -29,7 +29,7 @@ test_expect_success \
# and COPYING.2 are based on COPYING, and do not say anything about
# rezrov.
-git diff-index -z -M $tree >current
+git diff-index -z -C $tree >current
cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh
index 94df7ae53a..fbc8cd8f05 100755
--- a/t/t4010-diff-pathspec.sh
+++ b/t/t4010-diff-pathspec.sh
@@ -70,4 +70,36 @@ test_expect_success 'diff-tree pathspec' '
test_cmp expected current
'
+EMPTY_TREE=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+
+test_expect_success 'diff-tree with wildcard shows dir also matches' '
+ git diff-tree --name-only $EMPTY_TREE $tree -- "f*" >result &&
+ echo file0 >expected &&
+ test_cmp expected result
+'
+
+test_expect_success 'diff-tree -r with wildcard' '
+ git diff-tree -r --name-only $EMPTY_TREE $tree -- "*file1" >result &&
+ echo path1/file1 >expected &&
+ test_cmp expected result
+'
+
+test_expect_success 'diff-tree with wildcard shows dir also matches' '
+ git diff-tree --name-only $tree $tree2 -- "path1/f*" >result &&
+ echo path1 >expected &&
+ test_cmp expected result
+'
+
+test_expect_success 'diff-tree -r with wildcard from beginning' '
+ git diff-tree -r --name-only $tree $tree2 -- "path1/*file1" >result &&
+ echo path1/file1 >expected &&
+ test_cmp expected result
+'
+
+test_expect_success 'diff-tree -r with wildcard' '
+ git diff-tree -r --name-only $tree $tree2 -- "path1/f*" >result &&
+ echo path1/file1 >expected &&
+ test_cmp expected result
+'
+
test_done
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index 9a66520588..93a6f20871 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -80,18 +80,31 @@ test_expect_success setup '
git config log.showroot false &&
git commit --amend &&
+
+ GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
+ GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
+ export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
+ git checkout -b rearrange initial &&
+ for i in B A; do echo $i; done >dir/sub &&
+ git add dir/sub &&
+ git commit -m "Rearranged lines in dir/sub" &&
+ git checkout master &&
+
git show-branch
'
: <<\EOF
! [initial] Initial
* [master] Merge branch 'side'
- ! [side] Side
----
- - [master] Merge branch 'side'
- *+ [side] Side
- * [master^] Second
-+*+ [initial] Initial
+ ! [rearrange] Rearranged lines in dir/sub
+ ! [side] Side
+----
+ + [rearrange] Rearranged lines in dir/sub
+ - [master] Merge branch 'side'
+ * + [side] Side
+ * [master^] Third
+ * [master~2] Second
++*++ [initial] Initial
EOF
V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
@@ -210,6 +223,9 @@ log -m -p master
log -SF master
log -S F master
log -SF -p master
+log -SF master --max-count=0
+log -SF master --max-count=1
+log -SF master --max-count=2
log -GF master
log -GF -p master
log -GF -p --pickaxe-all master
@@ -284,10 +300,23 @@ diff --no-index --name-status -- dir2 dir
diff --no-index dir dir3
diff master master^ side
diff --dirstat master~1 master~2
+diff --dirstat initial rearrange
+diff --dirstat-by-file initial rearrange
EOF
test_expect_success 'log -S requires an argument' '
test_must_fail git log -S
'
+test_expect_success 'diff --cached on unborn branch' '
+ echo ref: refs/heads/unborn >.git/HEAD &&
+ git diff --cached >result &&
+ test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached" result
+'
+
+test_expect_success 'diff --cached -- file on unborn branch' '
+ git diff --cached -- file0 >result &&
+ test_cmp "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" result
+'
+
test_done
diff --git a/t/t4013/diff.diff_--cached b/t/t4013/diff.diff_--cached
new file mode 100644
index 0000000000..ff16e83e7c
--- /dev/null
+++ b/t/t4013/diff.diff_--cached
@@ -0,0 +1,38 @@
+diff --git a/dir/sub b/dir/sub
+new file mode 100644
+index 0000000..992913c
+--- /dev/null
++++ b/dir/sub
+@@ -0,0 +1,8 @@
++A
++B
++C
++D
++E
++F
++1
++2
+diff --git a/file0 b/file0
+new file mode 100644
+index 0000000..10a8a9f
+--- /dev/null
++++ b/file0
+@@ -0,0 +1,9 @@
++1
++2
++3
++4
++5
++6
++A
++B
++C
+diff --git a/file1 b/file1
+new file mode 100644
+index 0000000..b1e6722
+--- /dev/null
++++ b/file1
+@@ -0,0 +1,3 @@
++A
++B
++C
diff --git a/t/t4013/diff.diff_--cached_--_file0 b/t/t4013/diff.diff_--cached_--_file0
new file mode 100644
index 0000000000..b9bb858a03
--- /dev/null
+++ b/t/t4013/diff.diff_--cached_--_file0
@@ -0,0 +1,15 @@
+diff --git a/file0 b/file0
+new file mode 100644
+index 0000000..10a8a9f
+--- /dev/null
++++ b/file0
+@@ -0,0 +1,9 @@
++1
++2
++3
++4
++5
++6
++A
++B
++C
diff --git a/t/t4013/diff.diff_--dirstat-by-file_initial_rearrange b/t/t4013/diff.diff_--dirstat-by-file_initial_rearrange
new file mode 100644
index 0000000000..e48e33f678
--- /dev/null
+++ b/t/t4013/diff.diff_--dirstat-by-file_initial_rearrange
@@ -0,0 +1,3 @@
+$ git diff --dirstat-by-file initial rearrange
+ 100.0% dir/
+$
diff --git a/t/t4013/diff.diff_--dirstat_initial_rearrange b/t/t4013/diff.diff_--dirstat_initial_rearrange
new file mode 100644
index 0000000000..5fb02c13bc
--- /dev/null
+++ b/t/t4013/diff.diff_--dirstat_initial_rearrange
@@ -0,0 +1,3 @@
+$ git diff --dirstat initial rearrange
+ 100.0% dir/
+$
diff --git a/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^
index 1f0f9ad44b..3b4e113012 100644
--- a/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^
+++ b/t/t4013/diff.format-patch_--stdout_--cover-letter_-n_initial..master^
@@ -1,7 +1,7 @@
$ git format-patch --stdout --cover-letter -n initial..master^
From 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0 Mon Sep 17 00:00:00 2001
From: C O Mitter <committer@example.com>
-Date: Mon, 26 Jun 2006 00:05:00 +0000
+Date: Mon, 26 Jun 2006 00:06:00 +0000
Subject: [DIFFERENT_PREFIX 0/2] *** SUBJECT HERE ***
*** BLURB HERE ***
diff --git a/t/t4013/diff.log_--decorate=full_--all b/t/t4013/diff.log_--decorate=full_--all
index d155e0bab2..44d45257da 100644
--- a/t/t4013/diff.log_--decorate=full_--all
+++ b/t/t4013/diff.log_--decorate=full_--all
@@ -1,4 +1,10 @@
$ git log --decorate=full --all
+commit cd4e72fd96faed3f0ba949dc42967430374e2290 (refs/heads/rearrange)
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:06:00 2006 +0000
+
+ Rearranged lines in dir/sub
+
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD, refs/heads/master)
Merge: 9a6d494 c7a2ab9
Author: A U Thor <author@example.com>
diff --git a/t/t4013/diff.log_--decorate_--all b/t/t4013/diff.log_--decorate_--all
index fd7c3e6439..27d3eabc26 100644
--- a/t/t4013/diff.log_--decorate_--all
+++ b/t/t4013/diff.log_--decorate_--all
@@ -1,4 +1,10 @@
$ git log --decorate --all
+commit cd4e72fd96faed3f0ba949dc42967430374e2290 (rearrange)
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:06:00 2006 +0000
+
+ Rearranged lines in dir/sub
+
commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (HEAD, master)
Merge: 9a6d494 c7a2ab9
Author: A U Thor <author@example.com>
diff --git a/t/t4013/diff.log_-SF_master_--max-count=0 b/t/t4013/diff.log_-SF_master_--max-count=0
new file mode 100644
index 0000000000..c1fc6c8731
--- /dev/null
+++ b/t/t4013/diff.log_-SF_master_--max-count=0
@@ -0,0 +1,2 @@
+$ git log -SF master --max-count=0
+$
diff --git a/t/t4013/diff.log_-SF_master_--max-count=1 b/t/t4013/diff.log_-SF_master_--max-count=1
new file mode 100644
index 0000000000..c981a03814
--- /dev/null
+++ b/t/t4013/diff.log_-SF_master_--max-count=1
@@ -0,0 +1,7 @@
+$ git log -SF master --max-count=1
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:02:00 2006 +0000
+
+ Third
+$
diff --git a/t/t4013/diff.log_-SF_master_--max-count=2 b/t/t4013/diff.log_-SF_master_--max-count=2
new file mode 100644
index 0000000000..a6c55fd482
--- /dev/null
+++ b/t/t4013/diff.log_-SF_master_--max-count=2
@@ -0,0 +1,7 @@
+$ git log -SF master --max-count=2
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:02:00 2006 +0000
+
+ Third
+$
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index 027c13d52c..dd406c44b5 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -614,7 +614,7 @@ echo "fatal: --name-only does not make sense" > expect.name-only
echo "fatal: --name-status does not make sense" > expect.name-status
echo "fatal: --check does not make sense" > expect.check
-test_expect_success 'options no longer allowed for format-patch' '
+test_expect_success C_LOCALE_OUTPUT 'options no longer allowed for format-patch' '
test_must_fail git format-patch --name-only 2> output &&
test_cmp expect.name-only output &&
test_must_fail git format-patch --name-status 2> output &&
@@ -709,4 +709,130 @@ test_expect_success TTY 'format-patch --stdout paginates' '
test_path_is_missing .git/pager_used
'
+test_expect_success 'format-patch handles multi-line subjects' '
+ rm -rf patches/ &&
+ echo content >>file &&
+ for i in one two three; do echo $i; done >msg &&
+ git add file &&
+ git commit -F msg &&
+ git format-patch -o patches -1 &&
+ grep ^Subject: patches/0001-one.patch >actual &&
+ echo "Subject: [PATCH] one two three" >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'format-patch handles multi-line encoded subjects' '
+ rm -rf patches/ &&
+ echo content >>file &&
+ for i in en två tre; do echo $i; done >msg &&
+ git add file &&
+ git commit -F msg &&
+ git format-patch -o patches -1 &&
+ grep ^Subject: patches/0001-en.patch >actual &&
+ echo "Subject: [PATCH] =?UTF-8?q?en=20tv=C3=A5=20tre?=" >expect &&
+ test_cmp expect actual
+'
+
+M8="foo bar "
+M64=$M8$M8$M8$M8$M8$M8$M8$M8
+M512=$M64$M64$M64$M64$M64$M64$M64$M64
+cat >expect <<'EOF'
+Subject: [PATCH] foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo
+ bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
+ foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo
+ bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
+ foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo
+ bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
+ foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo
+ bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar
+ foo bar foo bar foo bar foo bar
+EOF
+test_expect_success 'format-patch wraps extremely long headers (ascii)' '
+ echo content >>file &&
+ git add file &&
+ git commit -m "$M512" &&
+ git format-patch --stdout -1 >patch &&
+ sed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&
+ test_cmp expect subject
+'
+
+M8="föö bar "
+M64=$M8$M8$M8$M8$M8$M8$M8$M8
+M512=$M64$M64$M64$M64$M64$M64$M64$M64
+cat >expect <<'EOF'
+Subject: [PATCH] =?UTF-8?q?f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=
+ =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=
+EOF
+test_expect_success 'format-patch wraps extremely long headers (rfc2047)' '
+ rm -rf patches/ &&
+ echo content >>file &&
+ git add file &&
+ git commit -m "$M512" &&
+ git format-patch --stdout -1 >patch &&
+ sed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&
+ test_cmp expect subject
+'
+
+check_author() {
+ echo content >>file &&
+ git add file &&
+ GIT_AUTHOR_NAME=$1 git commit -m author-check &&
+ git format-patch --stdout -1 >patch &&
+ grep ^From: patch >actual &&
+ test_cmp expect actual
+}
+
+cat >expect <<'EOF'
+From: "Foo B. Bar" <author@example.com>
+EOF
+test_expect_success 'format-patch quotes dot in headers' '
+ check_author "Foo B. Bar"
+'
+
+cat >expect <<'EOF'
+From: "Foo \"The Baz\" Bar" <author@example.com>
+EOF
+test_expect_success 'format-patch quotes double-quote in headers' '
+ check_author "Foo \"The Baz\" Bar"
+'
+
+cat >expect <<'EOF'
+From: =?UTF-8?q?"F=C3=B6o=20B.=20Bar"?= <author@example.com>
+EOF
+test_expect_success 'rfc2047-encoded headers also double-quote 822 specials' '
+ check_author "Föo B. Bar"
+'
+
+cat >expect <<'EOF'
+Subject: header with . in it
+EOF
+test_expect_success 'subject lines do not have 822 atom-quoting' '
+ echo content >>file &&
+ git add file &&
+ git commit -m "header with . in it" &&
+ git format-patch -k -1 --stdout >patch &&
+ grep ^Subject: patch >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index a7602cf923..083f62d1d6 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -4,8 +4,6 @@ test_description='external diff interface test'
. ./test-lib.sh
-_z40=0000000000000000000000000000000000000000
-
test_expect_success setup '
test_tick &&
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 241a74d2a2..518bf9524e 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -5,7 +5,6 @@ test_description='difference in submodules'
. ./test-lib.sh
. "$TEST_DIRECTORY"/diff-lib.sh
-_z40=0000000000000000000000000000000000000000
test_expect_success setup '
test_tick &&
test_create_repo sub &&
diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh
index 7e7b307a24..7d7470f21b 100755
--- a/t/t4031-diff-rewrite-binary.sh
+++ b/t/t4031-diff-rewrite-binary.sh
@@ -44,6 +44,13 @@ test_expect_success 'rewrite diff can show binary patch' '
grep "GIT binary patch" diff
'
+test_expect_success 'rewrite diff --stat shows binary changes' '
+ git diff -B --stat --summary >diff &&
+ grep "Bin" diff &&
+ grep "0 insertions.*0 deletions" diff &&
+ grep " rewrite file" diff
+'
+
{
echo "#!$SHELL_PATH"
cat <<'EOF'
diff --git a/t/t4040-whitespace-status.sh b/t/t4040-whitespace-status.sh
index a30b03bcf2..abc49348b1 100755
--- a/t/t4040-whitespace-status.sh
+++ b/t/t4040-whitespace-status.sh
@@ -60,4 +60,11 @@ test_expect_success 'diff-files -b -p --exit-code' '
git diff-files -b -p --exit-code
'
+test_expect_success 'diff-files --diff-filter --quiet' '
+ git reset --hard &&
+ rm a/d &&
+ echo x >>b/e &&
+ test_must_fail git diff-files --diff-filter=M --quiet
+'
+
test_done
diff --git a/t/t4046-diff-unmerged.sh b/t/t4046-diff-unmerged.sh
new file mode 100755
index 0000000000..25d50a654a
--- /dev/null
+++ b/t/t4046-diff-unmerged.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+
+test_description='diff with unmerged index entries'
+. ./test-lib.sh
+
+test_expect_success setup '
+ for i in 0 1 2 3
+ do
+ blob=$(echo $i | git hash-object --stdin) &&
+ eval "blob$i=$blob" &&
+ eval "m$i=\"100644 \$blob$i $i\"" || break
+ done &&
+ paths= &&
+ for b in o x
+ do
+ for o in o x
+ do
+ for t in o x
+ do
+ path="$b$o$t" &&
+ case "$path" in ooo) continue ;; esac
+ paths="$paths$path " &&
+ p=" $path" &&
+ case "$b" in x) echo "$m1$p" ;; esac &&
+ case "$o" in x) echo "$m2$p" ;; esac &&
+ case "$t" in x) echo "$m3$p" ;; esac ||
+ break
+ done || break
+ done || break
+ done >ls-files-s.expect &&
+ git update-index --index-info <ls-files-s.expect &&
+ git ls-files -s >ls-files-s.actual &&
+ test_cmp ls-files-s.expect ls-files-s.actual
+'
+
+test_expect_success 'diff-files -0' '
+ for path in $paths
+ do
+ >"$path" &&
+ echo ":000000 100644 $_z40 $_z40 U $path"
+ done >diff-files-0.expect &&
+ git diff-files -0 >diff-files-0.actual &&
+ test_cmp diff-files-0.expect diff-files-0.actual
+'
+
+test_expect_success 'diff-files -1' '
+ for path in $paths
+ do
+ >"$path" &&
+ echo ":000000 100644 $_z40 $_z40 U $path" &&
+ case "$path" in
+ x??) echo ":100644 100644 $blob1 $_z40 M $path"
+ esac
+ done >diff-files-1.expect &&
+ git diff-files -1 >diff-files-1.actual &&
+ test_cmp diff-files-1.expect diff-files-1.actual
+'
+
+test_expect_success 'diff-files -2' '
+ for path in $paths
+ do
+ >"$path" &&
+ echo ":000000 100644 $_z40 $_z40 U $path" &&
+ case "$path" in
+ ?x?) echo ":100644 100644 $blob2 $_z40 M $path"
+ esac
+ done >diff-files-2.expect &&
+ git diff-files -2 >diff-files-2.actual &&
+ test_cmp diff-files-2.expect diff-files-2.actual &&
+ git diff-files >diff-files-default-2.actual &&
+ test_cmp diff-files-2.expect diff-files-default-2.actual
+'
+
+test_expect_success 'diff-files -3' '
+ for path in $paths
+ do
+ >"$path" &&
+ echo ":000000 100644 $_z40 $_z40 U $path" &&
+ case "$path" in
+ ??x) echo ":100644 100644 $blob3 $_z40 M $path"
+ esac
+ done >diff-files-3.expect &&
+ git diff-files -3 >diff-files-3.actual &&
+ test_cmp diff-files-3.expect diff-files-3.actual
+'
+
+test_done
diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh
index 579c9e6105..a33d510bf6 100755
--- a/t/t4120-apply-popt.sh
+++ b/t/t4120-apply-popt.sh
@@ -6,6 +6,7 @@
test_description='git apply -p handling.'
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
test_expect_success setup '
mkdir sub &&
@@ -62,8 +63,12 @@ test_expect_success 'apply (-p2) diff, mode change only' '
old mode 100644
new mode 100755
EOF
- chmod 644 file1 &&
- git apply -p2 patch.chmod &&
+ test_chmod -x file1 &&
+ git apply --index -p2 patch.chmod &&
+ case $(git ls-files -s file1) in 100755*) : good;; *) false;; esac
+'
+
+test_expect_success FILEMODE 'file mode was changed' '
test -x file1
'
diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
index 68e2652814..d2c930de87 100755
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
@@ -63,4 +63,40 @@ test_expect_success 'patch-id supports git-format-patch MIME output' '
test_cmp patch-id_master patch-id_same
'
+cat >nonl <<\EOF
+diff --git i/a w/a
+index e69de29..2e65efe 100644
+--- i/a
++++ w/a
+@@ -0,0 +1 @@
++a
+\ No newline at end of file
+diff --git i/b w/b
+index e69de29..6178079 100644
+--- i/b
++++ w/b
+@@ -0,0 +1 @@
++b
+EOF
+
+cat >withnl <<\EOF
+diff --git i/a w/a
+index e69de29..7898192 100644
+--- i/a
++++ w/a
+@@ -0,0 +1 @@
++a
+diff --git i/b w/b
+index e69de29..6178079 100644
+--- i/b
++++ w/b
+@@ -0,0 +1 @@
++b
+EOF
+
+test_expect_success 'patch-id handles no-nl-at-eof markers' '
+ cat nonl | calc_patch_id nonl &&
+ cat withnl | calc_patch_id withnl &&
+ test_cmp patch-id_nonl patch-id_withnl
+'
test_done
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
index e2ed13dba2..d645328609 100755
--- a/t/t5304-prune.sh
+++ b/t/t5304-prune.sh
@@ -14,7 +14,8 @@ add_blob() {
BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
- test -f $BLOB_FILE
+ test -f $BLOB_FILE &&
+ test-chmtime =+0 $BLOB_FILE
}
test_expect_success setup '
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index b0b2684a1f..0eace37a03 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -190,7 +190,7 @@ test_expect_success 'pushing explicit refspecs respects forcing' '
+refs/heads/master:refs/heads/master
) &&
parent_head=$(cd parent && git rev-parse --verify master) &&
- child_head=$(cd parent && git rev-parse --verify master) &&
+ child_head=$(cd child && git rev-parse --verify master) &&
test "$parent_head" = "$child_head"
'
@@ -210,7 +210,7 @@ test_expect_success 'pushing wildcard refspecs respects forcing' '
"+refs/heads/*:refs/heads/*"
) &&
parent_head=$(cd parent && git rev-parse --verify master) &&
- child_head=$(cd parent && git rev-parse --verify master) &&
+ child_head=$(cd child && git rev-parse --verify master) &&
test "$parent_head" = "$child_head"
'
diff --git a/t/t5501-fetch-push-alternates.sh b/t/t5501-fetch-push-alternates.sh
new file mode 100755
index 0000000000..b5ced8483a
--- /dev/null
+++ b/t/t5501-fetch-push-alternates.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+
+test_description='fetch/push involving alternates'
+. ./test-lib.sh
+
+count_objects () {
+ loose=0 inpack=0
+ eval "$(
+ git count-objects -v |
+ sed -n -e 's/^count: \(.*\)/loose=\1/p' \
+ -e 's/^in-pack: \(.*\)/inpack=\1/p'
+ )" &&
+ echo $(( $loose + $inpack ))
+}
+
+
+test_expect_success setup '
+ (
+ git init original &&
+ cd original &&
+ i=0 &&
+ while test $i -le 100
+ do
+ echo "$i" >count &&
+ git add count &&
+ git commit -m "$i" || exit
+ i=$(($i + 1))
+ done
+ ) &&
+ (
+ git clone --reference=original "file:///$(pwd)/original" one &&
+ cd one &&
+ echo Z >count &&
+ git add count &&
+ git commit -m Z &&
+ count_objects >../one.count
+ ) &&
+ A=$(pwd)/original/.git/objects &&
+ git init receiver &&
+ echo "$A" >receiver/.git/objects/info/alternates &&
+ git init fetcher &&
+ echo "$A" >fetcher/.git/objects/info/alternates
+'
+
+test_expect_success 'pushing into a repository with the same alternate' '
+ (
+ cd one &&
+ git push ../receiver master:refs/heads/it
+ ) &&
+ (
+ cd receiver &&
+ count_objects >../receiver.count
+ ) &&
+ test_cmp one.count receiver.count
+'
+
+test_expect_success 'fetching from a repository with the same alternate' '
+ (
+ cd fetcher &&
+ git fetch ../one master:refs/heads/it &&
+ count_objects >../fetcher.count
+ ) &&
+ test_cmp one.count fetcher.count
+'
+
+test_done
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index d189add2d0..4e69c907d8 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -304,6 +304,84 @@ test_expect_success 'add --mirror && prune' '
git rev-parse --verify refs/heads/side)
'
+test_expect_success 'add --mirror=fetch' '
+ mkdir mirror-fetch &&
+ git init mirror-fetch/parent &&
+ (cd mirror-fetch/parent &&
+ test_commit one) &&
+ git init --bare mirror-fetch/child &&
+ (cd mirror-fetch/child &&
+ git remote add --mirror=fetch -f parent ../parent)
+'
+
+test_expect_success 'fetch mirrors act as mirrors during fetch' '
+ (cd mirror-fetch/parent &&
+ git branch new &&
+ git branch -m master renamed
+ ) &&
+ (cd mirror-fetch/child &&
+ git fetch parent &&
+ git rev-parse --verify refs/heads/new &&
+ git rev-parse --verify refs/heads/renamed
+ )
+'
+
+test_expect_success 'fetch mirrors can prune' '
+ (cd mirror-fetch/child &&
+ git remote prune parent &&
+ test_must_fail git rev-parse --verify refs/heads/master
+ )
+'
+
+test_expect_success 'fetch mirrors do not act as mirrors during push' '
+ (cd mirror-fetch/parent &&
+ git checkout HEAD^0
+ ) &&
+ (cd mirror-fetch/child &&
+ git branch -m renamed renamed2 &&
+ git push parent
+ ) &&
+ (cd mirror-fetch/parent &&
+ git rev-parse --verify renamed &&
+ test_must_fail git rev-parse --verify refs/heads/renamed2
+ )
+'
+
+test_expect_success 'add --mirror=push' '
+ mkdir mirror-push &&
+ git init --bare mirror-push/public &&
+ git init mirror-push/private &&
+ (cd mirror-push/private &&
+ test_commit one &&
+ git remote add --mirror=push public ../public
+ )
+'
+
+test_expect_success 'push mirrors act as mirrors during push' '
+ (cd mirror-push/private &&
+ git branch new &&
+ git branch -m master renamed &&
+ git push public
+ ) &&
+ (cd mirror-push/private &&
+ git rev-parse --verify refs/heads/new &&
+ git rev-parse --verify refs/heads/renamed &&
+ test_must_fail git rev-parse --verify refs/heads/master
+ )
+'
+
+test_expect_success 'push mirrors do not act as mirrors during fetch' '
+ (cd mirror-push/public &&
+ git branch -m renamed renamed2 &&
+ git symbolic-ref HEAD refs/heads/renamed2
+ ) &&
+ (cd mirror-push/private &&
+ git fetch public &&
+ git rev-parse --verify refs/heads/renamed &&
+ test_must_fail git rev-parse --verify refs/heads/renamed2
+ )
+'
+
test_expect_success 'add alt && prune' '
(mkdir alttst &&
cd alttst &&
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 0470a81be0..0e5eb678ce 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -46,6 +46,17 @@ test_expect_success 'pulling into void using master:master' '
test_cmp file cloned-uho/file
'
+test_expect_success 'pulling into void does not overwrite untracked files' '
+ git init cloned-untracked &&
+ (
+ cd cloned-untracked &&
+ echo untracked >file &&
+ test_must_fail git pull .. master &&
+ echo untracked >expect &&
+ test_cmp expect file
+ )
+'
+
test_expect_success 'test . as a remote' '
git branch copy master &&
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index 884a5e567c..af78e21ba9 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -66,7 +66,10 @@ test_expect_success "fetch --recurse-submodules recurses into submodules" '
(
cd downstream &&
git fetch --recurse-submodules >../actual.out 2>../actual.err
- ) &&
+ )
+'
+
+test_expect_success C_LOCALE_OUTPUT "fetch --recurse-submodules recurses into submodules: output" '
test_cmp expect.out actual.out &&
test_cmp expect.err actual.err
'
@@ -95,7 +98,10 @@ test_expect_success "using fetchRecurseSubmodules=true in .gitmodules recurses i
cd downstream &&
git config -f .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
git fetch >../actual.out 2>../actual.err
- ) &&
+ )
+'
+
+test_expect_success C_LOCALE_OUTPUT "using fetchRecurseSubmodules=true in .gitmodules recurses into submodules" '
test_cmp expect.out actual.out &&
test_cmp expect.err actual.err
'
@@ -124,9 +130,12 @@ test_expect_success "--recurse-submodules overrides fetchRecurseSubmodules setti
(
cd downstream &&
git fetch --recurse-submodules >../actual.out 2>../actual.err &&
- git config -f --unset .gitmodules submodule.submodule.fetchRecurseSubmodules true &&
+ git config --unset -f .gitmodules submodule.submodule.fetchRecurseSubmodules &&
git config --unset submodule.submodule.fetchRecurseSubmodules
- ) &&
+ )
+'
+
+test_expect_success C_LOCALE_OUTPUT "--recurse-submodules overrides fetchRecurseSubmodules setting from .git/config: output" '
test_cmp expect.out actual.out &&
test_cmp expect.err actual.err
'
@@ -145,13 +154,22 @@ test_expect_success "--dry-run propagates to submodules" '
(
cd downstream &&
git fetch --recurse-submodules --dry-run >../actual.out 2>../actual.err
- ) &&
+ )
+'
+
+test_expect_success C_LOCALE_OUTPUT "--dry-run propagates to submodules: output" '
test_cmp expect.out actual.out &&
- test_cmp expect.err actual.err &&
+ test_cmp expect.err actual.err
+'
+
+test_expect_success "Without --dry-run propagates to submodules" '
(
cd downstream &&
git fetch --recurse-submodules >../actual.out 2>../actual.err
- ) &&
+ )
+'
+
+test_expect_success C_LOCALE_OUTPUT "Without --dry-run propagates to submodules: output" '
test_cmp expect.out actual.out &&
test_cmp expect.err actual.err
'
@@ -162,7 +180,10 @@ test_expect_success "recurseSubmodules=true propagates into submodules" '
cd downstream &&
git config fetch.recurseSubmodules true
git fetch >../actual.out 2>../actual.err
- ) &&
+ )
+'
+
+test_expect_success C_LOCALE_OUTPUT "recurseSubmodules=true propagates into submodules: output" '
test_cmp expect.out actual.out &&
test_cmp expect.err actual.err
'
@@ -176,7 +197,10 @@ test_expect_success "--recurse-submodules overrides config in submodule" '
git config fetch.recurseSubmodules false
) &&
git fetch --recurse-submodules >../actual.out 2>../actual.err
- ) &&
+ )
+'
+
+test_expect_success C_LOCALE_OUTPUT "--recurse-submodules overrides config in submodule: output" '
test_cmp expect.out actual.out &&
test_cmp expect.err actual.err
'
@@ -192,4 +216,259 @@ test_expect_success "--no-recurse-submodules overrides config setting" '
! test -s actual.err
'
+test_expect_success "Recursion doesn't happen when no new commits are fetched in the superproject" '
+ (
+ cd downstream &&
+ (
+ cd submodule &&
+ git config --unset fetch.recurseSubmodules
+ ) &&
+ git config --unset fetch.recurseSubmodules
+ git fetch >../actual.out 2>../actual.err
+ ) &&
+ ! test -s actual.out &&
+ ! test -s actual.err
+'
+
+test_expect_success "Recursion stops when no new submodule commits are fetched" '
+ head1=$(git rev-parse --short HEAD) &&
+ git add submodule &&
+ git commit -m "new submodule" &&
+ head2=$(git rev-parse --short HEAD) &&
+ echo "Fetching submodule submodule" > expect.out.sub &&
+ echo "From $pwd/." > expect.err.sub &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err.sub
+ head -2 expect.err >> expect.err.sub &&
+ (
+ cd downstream &&
+ git fetch >../actual.out 2>../actual.err
+ ) &&
+ test_cmp expect.err.sub actual.err &&
+ test_cmp expect.out.sub actual.out
+'
+
+test_expect_success "Recursion doesn't happen when new superproject commits don't change any submodules" '
+ add_upstream_commit &&
+ head1=$(git rev-parse --short HEAD) &&
+ echo a > file &&
+ git add file &&
+ git commit -m "new file" &&
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/." > expect.err.file &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err.file &&
+ (
+ cd downstream &&
+ git fetch >../actual.out 2>../actual.err
+ ) &&
+ ! test -s actual.out &&
+ test_cmp expect.err.file actual.err
+'
+
+test_expect_success "Recursion picks up config in submodule" '
+ (
+ cd downstream &&
+ git fetch --recurse-submodules &&
+ (
+ cd submodule &&
+ git config fetch.recurseSubmodules true
+ )
+ ) &&
+ add_upstream_commit &&
+ head1=$(git rev-parse --short HEAD) &&
+ git add submodule &&
+ git commit -m "new submodule" &&
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/." > expect.err.sub &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err.sub &&
+ cat expect.err >> expect.err.sub &&
+ (
+ cd downstream &&
+ git fetch >../actual.out 2>../actual.err &&
+ (
+ cd submodule &&
+ git config --unset fetch.recurseSubmodules
+ )
+ ) &&
+ test_cmp expect.err.sub actual.err &&
+ test_cmp expect.out actual.out
+'
+
+test_expect_success "Recursion picks up all submodules when necessary" '
+ add_upstream_commit &&
+ (
+ cd submodule &&
+ (
+ cd deepsubmodule &&
+ git fetch &&
+ git checkout -q FETCH_HEAD
+ ) &&
+ head1=$(git rev-parse --short HEAD^) &&
+ git add deepsubmodule &&
+ git commit -m "new deepsubmodule"
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/submodule" > ../expect.err.sub &&
+ echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub
+ ) &&
+ head1=$(git rev-parse --short HEAD) &&
+ git add submodule &&
+ git commit -m "new submodule" &&
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/." > expect.err.2 &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err.2 &&
+ cat expect.err.sub >> expect.err.2 &&
+ tail -2 expect.err >> expect.err.2 &&
+ (
+ cd downstream &&
+ git fetch >../actual.out 2>../actual.err
+ ) &&
+ test_cmp expect.err.2 actual.err &&
+ test_cmp expect.out actual.out
+'
+
+test_expect_success "'--recurse-submodules=on-demand' doesn't recurse when no new commits are fetched in the superproject (and ignores config)" '
+ add_upstream_commit &&
+ (
+ cd submodule &&
+ (
+ cd deepsubmodule &&
+ git fetch &&
+ git checkout -q FETCH_HEAD
+ ) &&
+ head1=$(git rev-parse --short HEAD^) &&
+ git add deepsubmodule &&
+ git commit -m "new deepsubmodule"
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/submodule" > ../expect.err.sub &&
+ echo " $head1..$head2 master -> origin/master" >> ../expect.err.sub
+ ) &&
+ (
+ cd downstream &&
+ git config fetch.recurseSubmodules true &&
+ git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
+ git config --unset fetch.recurseSubmodules
+ ) &&
+ ! test -s actual.out &&
+ ! test -s actual.err
+'
+
+test_expect_success "'--recurse-submodules=on-demand' recurses as deep as necessary (and ignores config)" '
+ head1=$(git rev-parse --short HEAD) &&
+ git add submodule &&
+ git commit -m "new submodule" &&
+ head2=$(git rev-parse --short HEAD) &&
+ tail -2 expect.err > expect.err.deepsub &&
+ echo "From $pwd/." > expect.err &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err
+ cat expect.err.sub >> expect.err &&
+ cat expect.err.deepsub >> expect.err &&
+ (
+ cd downstream &&
+ git config fetch.recurseSubmodules false &&
+ (
+ cd submodule &&
+ git config -f .gitmodules submodule.deepsubmodule.fetchRecursive false
+ ) &&
+ git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err &&
+ git config --unset fetch.recurseSubmodules
+ (
+ cd submodule &&
+ git config --unset -f .gitmodules submodule.deepsubmodule.fetchRecursive
+ )
+ ) &&
+ test_cmp expect.out actual.out &&
+ test_cmp expect.err actual.err
+'
+
+test_expect_success "'--recurse-submodules=on-demand' stops when no new submodule commits are found in the superproject (and ignores config)" '
+ add_upstream_commit &&
+ head1=$(git rev-parse --short HEAD) &&
+ echo a >> file &&
+ git add file &&
+ git commit -m "new file" &&
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/." > expect.err.file &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err.file &&
+ (
+ cd downstream &&
+ git fetch --recurse-submodules=on-demand >../actual.out 2>../actual.err
+ ) &&
+ ! test -s actual.out &&
+ test_cmp expect.err.file actual.err
+'
+
+test_expect_success "'fetch.recurseSubmodules=on-demand' overrides global config" '
+ (
+ cd downstream &&
+ git fetch --recurse-submodules
+ ) &&
+ add_upstream_commit &&
+ git config --global fetch.recurseSubmodules false &&
+ head1=$(git rev-parse --short HEAD) &&
+ git add submodule &&
+ git commit -m "new submodule" &&
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/." > expect.err.2 &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err.2
+ head -2 expect.err >> expect.err.2 &&
+ (
+ cd downstream &&
+ git config fetch.recurseSubmodules on-demand &&
+ git fetch >../actual.out 2>../actual.err
+ ) &&
+ git config --global --unset fetch.recurseSubmodules &&
+ (
+ cd downstream &&
+ git config --unset fetch.recurseSubmodules
+ ) &&
+ test_cmp expect.out.sub actual.out &&
+ test_cmp expect.err.2 actual.err
+'
+
+test_expect_success "'submodule.<sub>.fetchRecurseSubmodules=on-demand' overrides fetch.recurseSubmodules" '
+ (
+ cd downstream &&
+ git fetch --recurse-submodules
+ ) &&
+ add_upstream_commit &&
+ git config fetch.recurseSubmodules false &&
+ head1=$(git rev-parse --short HEAD) &&
+ git add submodule &&
+ git commit -m "new submodule" &&
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/." > expect.err.2 &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err.2
+ head -2 expect.err >> expect.err.2 &&
+ (
+ cd downstream &&
+ git config submodule.submodule.fetchRecurseSubmodules on-demand &&
+ git fetch >../actual.out 2>../actual.err
+ ) &&
+ git config --unset fetch.recurseSubmodules &&
+ (
+ cd downstream &&
+ git config --unset submodule.submodule.fetchRecurseSubmodules
+ ) &&
+ test_cmp expect.out.sub actual.out &&
+ test_cmp expect.err.2 actual.err
+'
+
+test_expect_success "don't fetch submodule when newly recorded commits are already present" '
+ (
+ cd submodule &&
+ git checkout -q HEAD^^
+ ) &&
+ head1=$(git rev-parse --short HEAD) &&
+ git add submodule &&
+ git commit -m "submodule rewound" &&
+ head2=$(git rev-parse --short HEAD) &&
+ echo "From $pwd/." > expect.err &&
+ echo " $head1..$head2 master -> origin/master" >> expect.err &&
+ (
+ cd downstream &&
+ git fetch >../actual.out 2>../actual.err
+ ) &&
+ ! test -s actual.out &&
+ test_cmp expect.err actual.err
+'
+
test_done
diff --git a/t/t5532-fetch-proxy.sh b/t/t5532-fetch-proxy.sh
new file mode 100755
index 0000000000..62f2460047
--- /dev/null
+++ b/t/t5532-fetch-proxy.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+test_description='fetching via git:// using core.gitproxy'
+. ./test-lib.sh
+
+test_expect_success 'setup remote repo' '
+ git init remote &&
+ (cd remote &&
+ echo content >file &&
+ git add file &&
+ git commit -m one
+ )
+'
+
+cat >proxy <<'EOF'
+#!/bin/sh
+echo >&2 "proxying for $*"
+cmd=`perl -e '
+ read(STDIN, $buf, 4);
+ my $n = hex($buf) - 4;
+ read(STDIN, $buf, $n);
+ my ($cmd, $other) = split /\0/, $buf;
+ # drop absolute-path on repo name
+ $cmd =~ s{ /}{ };
+ print $cmd;
+'`
+echo >&2 "Running '$cmd'"
+exec $cmd
+EOF
+chmod +x proxy
+test_expect_success 'setup local repo' '
+ git remote add fake git://example.com/remote &&
+ git config core.gitproxy ./proxy
+'
+
+test_expect_success 'fetch through proxy works' '
+ git fetch fake &&
+ echo one >expect &&
+ git log -1 --format=%s FETCH_HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_done
diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
index b0c2a2c3ae..0492877d51 100755
--- a/t/t5541-http-push.sh
+++ b/t/t5541-http-push.sh
@@ -128,11 +128,14 @@ test_expect_success 'push fails for non-fast-forward refs unmatched by remote he
# push master too; this ensures there is at least one '"'push'"' command to
# the remote helper and triggers interaction with the helper.
- test_must_fail git push -v origin +master master:retsam >output 2>&1 &&
+ test_must_fail git push -v origin +master master:retsam >output 2>&1'
+test_expect_success 'push fails for non-fast-forward refs unmatched by remote helper: remote output' '
grep "^ + [a-f0-9]*\.\.\.[a-f0-9]* *master -> master (forced update)$" output &&
- grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output &&
+ grep "^ ! \[rejected\] *master -> retsam (non-fast-forward)$" output
+'
+test_expect_success C_LOCALE_OUTPUT 'push fails for non-fast-forward refs unmatched by remote helper: our output' '
grep "To prevent you from losing history, non-fast-forward updates were rejected" \
output
'
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 987e0c8463..5a068b21e4 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -31,7 +31,7 @@ test_expect_success 'clone with excess parameters (2)' '
'
-test_expect_success 'output from clone' '
+test_expect_success C_LOCALE_OUTPUT 'output from clone' '
rm -fr dst &&
git clone -n "file://$(pwd)/src" dst >output &&
test $(grep Clon output | wc -l) = 1
@@ -164,7 +164,6 @@ test_expect_success 'clone a void' '
test_expect_success 'clone respects global branch.autosetuprebase' '
(
test_config="$HOME/.gitconfig" &&
- unset GIT_CONFIG_NOGLOBAL &&
git config -f "$test_config" branch.autosetuprebase remote &&
rm -fr dst &&
git clone src dst &&
@@ -192,4 +191,17 @@ test_expect_success 'do not respect url-encoding of non-url path' '
git clone x+y xy-regular
'
+test_expect_success 'clone separate gitdir' '
+ rm -rf dst &&
+ git clone --separate-git-dir realgitdir src dst &&
+ echo "gitdir: `pwd`/realgitdir" >expected &&
+ test_cmp expected dst/.git &&
+ test -d realgitdir/refs
+'
+
+test_expect_success 'clone separate gitdir where target already exists' '
+ rm -rf dst &&
+ test_must_fail git clone --separate-git-dir realgitdir src dst
+'
+
test_done
diff --git a/t/t5701-clone-local.sh b/t/t5701-clone-local.sh
index 0f4d487be3..6972258b27 100755
--- a/t/t5701-clone-local.sh
+++ b/t/t5701-clone-local.sh
@@ -144,4 +144,17 @@ test_expect_success 'clone empty repository, and then push should not segfault.'
test_must_fail git push)
'
+test_expect_success 'cloning non-existent directory fails' '
+ cd "$D" &&
+ rm -rf does-not-exist &&
+ test_must_fail git clone does-not-exist
+'
+
+test_expect_success 'cloning non-git directory fails' '
+ cd "$D" &&
+ rm -rf not-a-git-repo not-a-git-repo-clone &&
+ mkdir not-a-git-repo &&
+ test_must_fail git clone not-a-git-repo not-a-git-repo-clone
+'
+
test_done
diff --git a/t/t6000-rev-list-misc.sh b/t/t6000-rev-list-misc.sh
new file mode 100755
index 0000000000..b10685af4e
--- /dev/null
+++ b/t/t6000-rev-list-misc.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+test_description='miscellaneous rev-list tests'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo content1 >wanted_file &&
+ echo content2 >unwanted_file &&
+ git add wanted_file unwanted_file &&
+ git commit -m one
+'
+
+test_expect_success 'rev-list --objects heeds pathspecs' '
+ git rev-list --objects HEAD -- wanted_file >output &&
+ grep wanted_file output &&
+ ! grep unwanted_file output
+'
+
+test_expect_success 'rev-list --objects with pathspecs and deeper paths' '
+ mkdir foo &&
+ >foo/file &&
+ git add foo/file &&
+ git commit -m two &&
+
+ git rev-list --objects HEAD -- foo >output &&
+ grep foo/file output &&
+
+ git rev-list --objects HEAD -- foo/file >output &&
+ grep foo/file output &&
+ ! grep unwanted_file output
+'
+
+test_expect_success 'rev-list --objects with pathspecs and copied files' '
+ git checkout --orphan junio-testcase &&
+ git rm -rf . &&
+
+ mkdir two &&
+ echo frotz >one &&
+ cp one two/three &&
+ git add one two/three &&
+ test_tick &&
+ git commit -m that &&
+
+ ONE=$(git rev-parse HEAD:one)
+ git rev-list --objects HEAD two >output &&
+ grep "$ONE two/three" output &&
+ ! grep one output
+'
+
+test_done
diff --git a/t/t6004-rev-list-path-optim.sh b/t/t6004-rev-list-path-optim.sh
index 5dabf1c5e3..3e8c42ee0b 100755
--- a/t/t6004-rev-list-path-optim.sh
+++ b/t/t6004-rev-list-path-optim.sh
@@ -1,51 +1,96 @@
#!/bin/sh
-test_description='git rev-list trivial path optimization test'
+test_description='git rev-list trivial path optimization test
+
+ d/z1
+ b0 b1
+ o------------------------*----o master
+ / /
+ o---------o----o----o----o side
+ a0 c0 c1 a1 c2
+ d/f0 d/f1
+ d/z0
+
+'
. ./test-lib.sh
test_expect_success setup '
-echo Hello > a &&
-git add a &&
-git commit -m "Initial commit" a &&
-initial=$(git rev-parse --verify HEAD)
+ echo Hello >a &&
+ mkdir d &&
+ echo World >d/f &&
+ echo World >d/z &&
+ git add a d &&
+ test_tick &&
+ git commit -m "Initial commit" &&
+ git rev-parse --verify HEAD &&
+ git tag initial
'
test_expect_success path-optimization '
- commit=$(echo "Unchanged tree" | git commit-tree "HEAD^{tree}" -p HEAD) &&
- test $(git rev-list $commit | wc -l) = 2 &&
- test $(git rev-list $commit -- . | wc -l) = 1
+ test_tick &&
+ commit=$(echo "Unchanged tree" | git commit-tree "HEAD^{tree}" -p HEAD) &&
+ test $(git rev-list $commit | wc -l) = 2 &&
+ test $(git rev-list $commit -- . | wc -l) = 1
'
test_expect_success 'further setup' '
git checkout -b side &&
echo Irrelevant >c &&
- git add c &&
+ echo Irrelevant >d/f &&
+ git add c d/f &&
+ test_tick &&
git commit -m "Side makes an irrelevant commit" &&
+ git tag side_c0 &&
echo "More Irrelevancy" >c &&
git add c &&
+ test_tick &&
git commit -m "Side makes another irrelevant commit" &&
echo Bye >a &&
git add a &&
+ test_tick &&
git commit -m "Side touches a" &&
- side=$(git rev-parse --verify HEAD) &&
+ git tag side_a1 &&
echo "Yet more Irrelevancy" >c &&
git add c &&
+ test_tick &&
git commit -m "Side makes yet another irrelevant commit" &&
git checkout master &&
echo Another >b &&
- git add b &&
+ echo Munged >d/z &&
+ git add b d/z &&
+ test_tick &&
git commit -m "Master touches b" &&
+ git tag master_b0 &&
git merge side &&
echo Touched >b &&
git add b &&
+ test_tick &&
git commit -m "Master touches b again"
'
test_expect_success 'path optimization 2' '
- ( echo "$side"; echo "$initial" ) >expected &&
+ git rev-parse side_a1 initial >expected &&
git rev-list HEAD -- a >actual &&
test_cmp expected actual
'
+test_expect_success 'pathspec with leading path' '
+ git rev-parse master^ master_b0 side_c0 initial >expected &&
+ git rev-list HEAD -- d >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'pathspec with glob (1)' '
+ git rev-parse master^ master_b0 side_c0 initial >expected &&
+ git rev-list HEAD -- "d/*" >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'pathspec with glob (2)' '
+ git rev-parse side_c0 initial >expected &&
+ git rev-list HEAD -- "d/[a-m]*" >actual &&
+ test_cmp expected actual
+'
+
test_done
diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh
index b565638e92..cacf3de6c9 100755
--- a/t/t6007-rev-list-cherry-pick-file.sh
+++ b/t/t6007-rev-list-cherry-pick-file.sh
@@ -4,13 +4,14 @@ test_description='test git rev-list --cherry-pick -- file'
. ./test-lib.sh
-# A---B
+# A---B---D---F
# \
# \
-# C
+# C---E
#
# B changes a file foo.c, adding a line of text. C changes foo.c as
# well as bar.c, but the change in foo.c was identical to change B.
+# D and C change bar in the same way, E and F differently.
test_expect_success setup '
echo Hallo > foo &&
@@ -25,11 +26,26 @@ test_expect_success setup '
test_tick &&
git commit -m "C" &&
git tag C &&
+ echo Dello > bar &&
+ git add bar &&
+ test_tick &&
+ git commit -m "E" &&
+ git tag E &&
git checkout master &&
git checkout branch foo &&
test_tick &&
git commit -m "B" &&
- git tag B
+ git tag B &&
+ echo Cello > bar &&
+ git add bar &&
+ test_tick &&
+ git commit -m "D" &&
+ git tag D &&
+ echo Nello > bar &&
+ git add bar &&
+ test_tick &&
+ git commit -m "F" &&
+ git tag F
'
cat >expect <<EOF
@@ -53,8 +69,92 @@ test_expect_success '--cherry-pick foo comes up empty' '
test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)"
'
+cat >expect <<EOF
+>tags/C
+EOF
+
test_expect_success '--cherry-pick bar does not come up empty' '
- ! test -z "$(git rev-list --left-right --cherry-pick B...C -- bar)"
+ git rev-list --left-right --cherry-pick B...C -- bar > actual &&
+ git name-rev --stdin --name-only --refs="*tags/*" \
+ < actual > actual.named &&
+ test_cmp actual.named expect
+'
+
+test_expect_success 'bar does not come up empty' '
+ git rev-list --left-right B...C -- bar > actual &&
+ git name-rev --stdin --name-only --refs="*tags/*" \
+ < actual > actual.named &&
+ test_cmp actual.named expect
+'
+
+cat >expect <<EOF
+<tags/F
+>tags/E
+EOF
+
+test_expect_success '--cherry-pick bar does not come up empty (II)' '
+ git rev-list --left-right --cherry-pick F...E -- bar > actual &&
+ git name-rev --stdin --name-only --refs="*tags/*" \
+ < actual > actual.named &&
+ test_cmp actual.named expect
+'
+
+cat >expect <<EOF
++tags/F
+=tags/D
++tags/E
+=tags/C
+EOF
+
+test_expect_success '--cherry-mark' '
+ git rev-list --cherry-mark F...E -- bar > actual &&
+ git name-rev --stdin --name-only --refs="*tags/*" \
+ < actual > actual.named &&
+ test_cmp actual.named expect
+'
+
+cat >expect <<EOF
+<tags/F
+=tags/D
+>tags/E
+=tags/C
+EOF
+
+test_expect_success '--cherry-mark --left-right' '
+ git rev-list --cherry-mark --left-right F...E -- bar > actual &&
+ git name-rev --stdin --name-only --refs="*tags/*" \
+ < actual > actual.named &&
+ test_cmp actual.named expect
+'
+
+cat >expect <<EOF
+tags/E
+EOF
+
+test_expect_success '--cherry-pick --right-only' '
+ git rev-list --cherry-pick --right-only F...E -- bar > actual &&
+ git name-rev --stdin --name-only --refs="*tags/*" \
+ < actual > actual.named &&
+ test_cmp actual.named expect
+'
+
+test_expect_success '--cherry-pick --left-only' '
+ git rev-list --cherry-pick --left-only E...F -- bar > actual &&
+ git name-rev --stdin --name-only --refs="*tags/*" \
+ < actual > actual.named &&
+ test_cmp actual.named expect
+'
+
+cat >expect <<EOF
++tags/E
+=tags/C
+EOF
+
+test_expect_success '--cherry' '
+ git rev-list --cherry F...E -- bar > actual &&
+ git name-rev --stdin --name-only --refs="*tags/*" \
+ < actual > actual.named &&
+ test_cmp actual.named expect
'
test_expect_success '--cherry-pick with independent, but identical branches' '
@@ -75,11 +175,8 @@ cat >expect <<EOF
1 2
EOF
-# Insert an extra commit to break the symmetry
test_expect_success '--count --left-right' '
- git checkout branch &&
- test_commit D &&
- git rev-list --count --left-right B...D > actual &&
+ git rev-list --count --left-right C...D > actual &&
test_cmp expect actual
'
diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
index 52f7b277ce..30507407ff 100755
--- a/t/t6009-rev-list-parent.sh
+++ b/t/t6009-rev-list-parent.sh
@@ -1,14 +1,15 @@
#!/bin/sh
-test_description='properly cull all ancestors'
+test_description='ancestor culling and limiting by parent number'
. ./test-lib.sh
-commit () {
- test_tick &&
- echo $1 >file &&
- git commit -a -m $1 &&
- git tag $1
+check_revlist () {
+ rev_list_args="$1" &&
+ shift &&
+ git rev-parse "$@" >expect &&
+ git rev-list $rev_list_args --all >actual &&
+ test_cmp expect actual
}
test_expect_success setup '
@@ -16,13 +17,13 @@ test_expect_success setup '
touch file &&
git add file &&
- commit one &&
+ test_commit one &&
test_tick=$(($test_tick - 2400)) &&
- commit two &&
- commit three &&
- commit four &&
+ test_commit two &&
+ test_commit three &&
+ test_commit four &&
git log --pretty=oneline --abbrev-commit
'
@@ -35,4 +36,101 @@ test_expect_success 'one is ancestor of others and should not be shown' '
'
+test_expect_success 'setup roots, merges and octopuses' '
+
+ git checkout --orphan newroot &&
+ test_commit five &&
+ git checkout -b sidebranch two &&
+ test_commit six &&
+ git checkout -b anotherbranch three &&
+ test_commit seven &&
+ git checkout -b yetanotherbranch four &&
+ test_commit eight &&
+ git checkout master &&
+ test_merge normalmerge newroot &&
+ test_tick &&
+ git merge -m tripus sidebranch anotherbranch &&
+ git tag tripus &&
+ git checkout -b tetrabranch normalmerge &&
+ test_tick &&
+ git merge -m tetrapus sidebranch anotherbranch yetanotherbranch &&
+ git tag tetrapus &&
+ git checkout master
+'
+
+test_expect_success 'rev-list roots' '
+
+ check_revlist "--max-parents=0" one five
+'
+
+test_expect_success 'rev-list no merges' '
+
+ check_revlist "--max-parents=1" one eight seven six five four three two &&
+ check_revlist "--no-merges" one eight seven six five four three two
+'
+
+test_expect_success 'rev-list no octopuses' '
+
+ check_revlist "--max-parents=2" one normalmerge eight seven six five four three two
+'
+
+test_expect_success 'rev-list no roots' '
+
+ check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two
+'
+
+test_expect_success 'rev-list merges' '
+
+ check_revlist "--min-parents=2" tetrapus tripus normalmerge &&
+ check_revlist "--merges" tetrapus tripus normalmerge
+'
+
+test_expect_success 'rev-list octopus' '
+
+ check_revlist "--min-parents=3" tetrapus tripus
+'
+
+test_expect_success 'rev-list ordinary commits' '
+
+ check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two
+'
+
+test_expect_success 'rev-list --merges --no-merges yields empty set' '
+
+ check_revlist "--min-parents=2 --no-merges" &&
+ check_revlist "--merges --no-merges" &&
+ check_revlist "--no-merges --merges"
+'
+
+test_expect_success 'rev-list override and infinities' '
+
+ check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge &&
+ check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge &&
+ check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge &&
+ check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge &&
+ check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge &&
+ check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five
+'
+
+test_expect_success 'dodecapus' '
+
+ roots= &&
+ for i in 1 2 3 4 5 6 7 8 9 10 11
+ do
+ git checkout -b root$i five &&
+ test_commit $i &&
+ roots="$roots root$i" ||
+ return
+ done &&
+ git checkout master &&
+ test_tick &&
+ git merge -m dodecapus $roots &&
+ git tag dodecapus &&
+
+ check_revlist "--min-parents=4" dodecapus tetrapus &&
+ check_revlist "--min-parents=8" dodecapus &&
+ check_revlist "--min-parents=12" dodecapus &&
+ check_revlist "--min-parents=13" &&
+ check_revlist "--min-parents=4 --max-parents=11" tetrapus
+'
test_done
diff --git a/t/t6017-rev-list-stdin.sh b/t/t6017-rev-list-stdin.sh
index f1c32dba42..667b37564e 100755
--- a/t/t6017-rev-list-stdin.sh
+++ b/t/t6017-rev-list-stdin.sh
@@ -58,4 +58,21 @@ check side-3 ^side-4 -- file-3
check side-3 ^side-2
check side-3 ^side-2 -- file-1
+test_expect_success 'not only --stdin' '
+ cat >expect <<-EOF &&
+ 7
+
+ file-1
+ file-2
+ EOF
+ cat >input <<-EOF &&
+ ^master^
+ --
+ file-2
+ EOF
+ git log --pretty=tformat:%s --name-only --stdin master -- file-1 \
+ <input >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t6035-merge-dir-to-symlink.sh b/t/t6035-merge-dir-to-symlink.sh
index 92e02d5d77..2599ae50eb 100755
--- a/t/t6035-merge-dir-to-symlink.sh
+++ b/t/t6035-merge-dir-to-symlink.sh
@@ -17,13 +17,21 @@ test_expect_success SYMLINKS 'create a commit where dir a/b changed to symlink'
git commit -m "dir to symlink"
'
-test_expect_success SYMLINKS 'keep a/b-2/c/d across checkout' '
+test_expect_success SYMLINKS 'checkout does not clobber untracked symlink' '
git checkout HEAD^0 &&
git reset --hard master &&
git rm --cached a/b &&
git commit -m "untracked symlink remains" &&
- git checkout start^0 &&
- test -f a/b-2/c/d
+ test_must_fail git checkout start^0
+'
+
+test_expect_success SYMLINKS 'a/b-2/c/d is kept when clobbering symlink b' '
+ git checkout HEAD^0 &&
+ git reset --hard master &&
+ git rm --cached a/b &&
+ git commit -m "untracked symlink remains" &&
+ git checkout -f start^0 &&
+ test -f a/b-2/c/d
'
test_expect_success SYMLINKS 'checkout should not have deleted a/b-2/c/d' '
diff --git a/t/t6040-tracking-info.sh b/t/t6040-tracking-info.sh
index 1e0447f615..6c3719141a 100755
--- a/t/t6040-tracking-info.sh
+++ b/t/t6040-tracking-info.sh
@@ -42,7 +42,7 @@ b3 behind 1
b4 ahead 2
EOF
-test_expect_success 'branch -v' '
+test_expect_success C_LOCALE_OUTPUT 'branch -v' '
(
cd test &&
git branch -v
@@ -74,20 +74,20 @@ test_expect_success 'status' '
grep "have 1 and 1 different" actual
'
-test_expect_success 'status when tracking lightweight tags' '
+test_expect_success 'fail to track lightweight tags' '
git checkout master &&
git tag light &&
- git branch --track lighttrack light >actual &&
- grep "set up to track" actual &&
- git checkout lighttrack
+ test_must_fail git branch --track lighttrack light >actual &&
+ test_must_fail grep "set up to track" actual &&
+ test_must_fail git checkout lighttrack
'
-test_expect_success 'status when tracking annotated tags' '
+test_expect_success 'fail to track annotated tags' '
git checkout master &&
git tag -m heavy heavy &&
- git branch --track heavytrack heavy >actual &&
- grep "set up to track" actual &&
- git checkout heavytrack
+ test_must_fail git branch --track heavytrack heavy >actual &&
+ test_must_fail grep "set up to track" actual &&
+ test_must_fail git checkout heavytrack
'
test_expect_success 'setup tracking with branch --set-upstream on existing branch' '
diff --git a/t/t6060-merge-index.sh b/t/t6060-merge-index.sh
new file mode 100755
index 0000000000..debadbd299
--- /dev/null
+++ b/t/t6060-merge-index.sh
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+test_description='basic git merge-index / git-merge-one-file tests'
+. ./test-lib.sh
+
+test_expect_success 'setup diverging branches' '
+ for i in 1 2 3 4 5 6 7 8 9 10; do
+ echo $i
+ done >file &&
+ git add file &&
+ git commit -m base &&
+ git tag base &&
+ sed s/2/two/ <file >tmp &&
+ mv tmp file &&
+ git commit -a -m two &&
+ git tag two &&
+ git checkout -b other HEAD^ &&
+ sed s/10/ten/ <file >tmp &&
+ mv tmp file &&
+ git commit -a -m ten &&
+ git tag ten
+'
+
+cat >expect-merged <<'EOF'
+1
+two
+3
+4
+5
+6
+7
+8
+9
+ten
+EOF
+
+test_expect_success 'read-tree does not resolve content merge' '
+ git read-tree -i -m base ten two &&
+ echo file >expect &&
+ git diff-files --name-only --diff-filter=U >unmerged &&
+ test_cmp expect unmerged
+'
+
+test_expect_success 'git merge-index git-merge-one-file resolves' '
+ git merge-index git-merge-one-file -a &&
+ git diff-files --name-only --diff-filter=U >unmerged &&
+ >expect &&
+ test_cmp expect unmerged &&
+ test_cmp expect-merged file &&
+ git cat-file blob :file >file-index &&
+ test_cmp expect-merged file-index
+'
+
+test_expect_success 'setup bare merge' '
+ git clone --bare . bare.git &&
+ (cd bare.git &&
+ GIT_INDEX_FILE=$PWD/merge.index &&
+ export GIT_INDEX_FILE &&
+ git read-tree -i -m base ten two
+ )
+'
+
+test_expect_success 'merge-one-file fails without a work tree' '
+ (cd bare.git &&
+ GIT_INDEX_FILE=$PWD/merge.index &&
+ export GIT_INDEX_FILE &&
+ test_must_fail git merge-index git-merge-one-file -a
+ )
+'
+
+test_expect_success 'merge-one-file respects GIT_WORK_TREE' '
+ (cd bare.git &&
+ mkdir work &&
+ GIT_WORK_TREE=$PWD/work &&
+ export GIT_WORK_TREE &&
+ GIT_INDEX_FILE=$PWD/merge.index &&
+ export GIT_INDEX_FILE &&
+ git merge-index git-merge-one-file -a &&
+ git cat-file blob :file >work/file-index
+ ) &&
+ test_cmp expect-merged bare.git/work/file &&
+ test_cmp expect-merged bare.git/work/file-index
+'
+
+test_expect_success 'merge-one-file respects core.worktree' '
+ mkdir subdir &&
+ git clone . subdir/child &&
+ (cd subdir &&
+ GIT_DIR=$PWD/child/.git &&
+ export GIT_DIR &&
+ git config core.worktree "$PWD/child" &&
+ git read-tree -i -m base ten two &&
+ git merge-index git-merge-one-file -a &&
+ git cat-file blob :file >file-index
+ ) &&
+ test_cmp expect-merged subdir/child/file &&
+ test_cmp expect-merged subdir/file-index
+'
+
+test_done
diff --git a/t/t6110-rev-list-sparse.sh b/t/t6110-rev-list-sparse.sh
new file mode 100755
index 0000000000..656ac7fe9d
--- /dev/null
+++ b/t/t6110-rev-list-sparse.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+test_description='operations that cull histories in unusual ways'
+. ./test-lib.sh
+
+test_expect_success setup '
+ test_commit A &&
+ test_commit B &&
+ test_commit C &&
+ git checkout -b side HEAD^ &&
+ test_commit D &&
+ test_commit E &&
+ git merge master
+'
+
+test_expect_success 'rev-list --first-parent --boundary' '
+ git rev-list --first-parent --boundary HEAD^..
+'
+
+test_done
diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh
index 876d1ab743..1826996245 100755
--- a/t/t6120-describe.sh
+++ b/t/t6120-describe.sh
@@ -123,7 +123,7 @@ cat - >err.expect <<EOF
warning: tag 'A' is really 'Q' here
EOF
check_describe A-* HEAD
-test_expect_success 'warning was displayed for Q' '
+test_expect_success C_LOCALE_OUTPUT 'warning was displayed for Q' '
test_cmp err.expect err.actual
'
test_expect_success 'rename tag Q back to A' '
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 3e7baaf89f..1dedfd0c83 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1121,6 +1121,7 @@ test_expect_success \
'
test_expect_success \
+ C_LOCALE_OUTPUT \
'message in editor has initial comment: first line' '
# check the first line --- should be empty
echo >first.expect &&
diff --git a/t/t7011-skip-worktree-reading.sh b/t/t7011-skip-worktree-reading.sh
index bb4066f767..8f3b54d826 100755
--- a/t/t7011-skip-worktree-reading.sh
+++ b/t/t7011-skip-worktree-reading.sh
@@ -24,7 +24,7 @@ H sub/2
EOF
NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
-ZERO_SHA0=0000000000000000000000000000000000000000
+
setup_absent() {
test -f 1 && rm 1
git update-index --remove 1 &&
@@ -120,7 +120,7 @@ test_expect_success 'grep with skip-worktree file' '
test "$(git grep --no-ext-grep test)" = "1:test"
'
-echo ":000000 100644 $ZERO_SHA0 $NULL_SHA1 A 1" > expected
+echo ":000000 100644 $_z40 $NULL_SHA1 A 1" > expected
test_expect_success 'diff-index does not examine skip-worktree absent entries' '
setup_absent &&
git diff-index HEAD -- 1 > result &&
diff --git a/t/t7012-skip-worktree-writing.sh b/t/t7012-skip-worktree-writing.sh
index 582d0b54f1..c4104009e1 100755
--- a/t/t7012-skip-worktree-writing.sh
+++ b/t/t7012-skip-worktree-writing.sh
@@ -54,7 +54,7 @@ test_expect_success 'read-tree removes worktree, dirty case' '
'
NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
-ZERO_SHA0=0000000000000000000000000000000000000000
+
setup_absent() {
test -f 1 && rm 1
git update-index --remove 1 &&
@@ -124,13 +124,13 @@ cat >expected <<EOF
Would remove expected
Would remove result
EOF
-test_expect_success 'git-clean, absent case' '
+test_expect_success C_LOCALE_OUTPUT 'git-clean, absent case' '
setup_absent &&
git clean -n > result &&
test_cmp expected result
'
-test_expect_success 'git-clean, dirty case' '
+test_expect_success C_LOCALE_OUTPUT 'git-clean, dirty case' '
setup_dirty &&
git clean -n > result &&
test_cmp expected result
diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh
index fcac472598..3a5d927f83 100755
--- a/t/t7060-wtstatus.sh
+++ b/t/t7060-wtstatus.sh
@@ -38,7 +38,7 @@ cat >expect <<EOF
no changes added to commit (use "git add" and/or "git commit -a")
EOF
-test_expect_success 'M/D conflict does not segfault' '
+test_expect_success C_LOCALE_OUTPUT 'M/D conflict does not segfault' '
mkdir mdconflict &&
(
cd mdconflict &&
@@ -56,4 +56,66 @@ test_expect_success 'M/D conflict does not segfault' '
)
'
+test_expect_success 'rename & unmerged setup' '
+ git rm -f -r . &&
+ cat "$TEST_DIRECTORY/README" >ONE &&
+ git add ONE &&
+ test_tick &&
+ git commit -m "One commit with ONE" &&
+
+ echo Modified >TWO &&
+ cat ONE >>TWO &&
+ cat ONE >>THREE &&
+ git add TWO THREE &&
+ sha1=$(git rev-parse :ONE) &&
+ git rm --cached ONE &&
+ (
+ echo "100644 $sha1 1 ONE" &&
+ echo "100644 $sha1 2 ONE" &&
+ echo "100644 $sha1 3 ONE"
+ ) | git update-index --index-info &&
+ echo Further >>THREE
+'
+
+test_expect_success 'rename & unmerged status' '
+ git status -suno >actual &&
+ cat >expect <<-EOF &&
+ UU ONE
+ AM THREE
+ A TWO
+ EOF
+ test_cmp expect actual
+'
+
+test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' '
+ cat >expected <<-EOF &&
+ U ONE
+ A THREE
+ A TWO
+ EOF
+ git diff-index --cached --name-status HEAD >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' '
+ cat >expected <<-EOF &&
+ U ONE
+ A THREE
+ A TWO
+ EOF
+ git diff-index --cached --name-status HEAD >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' '
+ cat >expected <<-EOF &&
+ U ONE
+ C ONE THREE
+ C ONE TWO
+ EOF
+ git diff-index --cached -C --name-status HEAD |
+ sed "s/^C[0-9]*/C/g" >actual &&
+ test_cmp expected actual
+'
+
test_done
diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh
index b8cf2603a1..7be2ff38fc 100755
--- a/t/t7102-reset.sh
+++ b/t/t7102-reset.sh
@@ -423,7 +423,7 @@ Unstaged changes after reset:
M file2
EOF
-test_expect_success '--mixed refreshes the index' '
+test_expect_success C_LOCALE_OUTPUT '--mixed refreshes the index' '
echo 123 >> file2 &&
git reset --mixed HEAD > output &&
test_cmp expect output
diff --git a/t/t7110-reset-merge.sh b/t/t7110-reset-merge.sh
index 70cdd8e618..b42820ad69 100755
--- a/t/t7110-reset-merge.sh
+++ b/t/t7110-reset-merge.sh
@@ -233,7 +233,7 @@ test_expect_success '"reset --merge HEAD^" is ok with pending merge' '
# working index HEAD target working index HEAD
# ----------------------------------------------------
# file1: X U B C --keep (disallowed)
-test_expect_success '"reset --keep HEAD^" fails with pending merge' '
+test_expect_success C_LOCALE_OUTPUT '"reset --keep HEAD^" fails with pending merge' '
git reset --hard third &&
test_must_fail git merge branch1 &&
test_must_fail git reset --keep HEAD^ 2>err.log &&
@@ -259,7 +259,7 @@ test_expect_success '"reset --merge HEAD" is ok with pending merge' '
# working index HEAD target working index HEAD
# ----------------------------------------------------
# file1: X U B B --keep (disallowed)
-test_expect_success '"reset --keep HEAD" fails with pending merge' '
+test_expect_success C_LOCALE_OUTPUT '"reset --keep HEAD" fails with pending merge' '
git reset --hard third &&
test_must_fail git merge branch1 &&
test_must_fail git reset --keep HEAD 2>err.log &&
@@ -280,7 +280,7 @@ test_expect_success '--merge is ok with added/deleted merge' '
git diff --exit-code --cached
'
-test_expect_success '--keep fails with added/deleted merge' '
+test_expect_success C_LOCALE_OUTPUT '--keep fails with added/deleted merge' '
git reset --hard third &&
rm -f file2 &&
test_must_fail git merge branch3 &&
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 1337fa5a22..37ed0931d9 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -223,7 +223,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' '
test_cmp two expect
'
-test_expect_success 'checkout to detach HEAD (with advice declined)' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD (with advice declined)' '
git config advice.detachedHead false &&
git checkout -f renamer && git clean -f &&
@@ -242,7 +242,7 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' '
fi
'
-test_expect_success 'checkout to detach HEAD' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD' '
git config advice.detachedHead true &&
git checkout -f renamer && git clean -f &&
git checkout renamer^ 2>messages &&
@@ -260,7 +260,7 @@ test_expect_success 'checkout to detach HEAD' '
fi
'
-test_expect_success 'checkout to detach HEAD with branchname^' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with branchname^' '
git checkout -f master && git clean -f &&
git checkout renamer^ &&
@@ -276,7 +276,7 @@ test_expect_success 'checkout to detach HEAD with branchname^' '
fi
'
-test_expect_success 'checkout to detach HEAD with :/message' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with :/message' '
git checkout -f master && git clean -f &&
git checkout ":/Initial" &&
@@ -292,7 +292,7 @@ test_expect_success 'checkout to detach HEAD with :/message' '
fi
'
-test_expect_success 'checkout to detach HEAD with HEAD^0' '
+test_expect_success C_LOCALE_OUTPUT 'checkout to detach HEAD with HEAD^0' '
git checkout -f master && git clean -f &&
git checkout HEAD^0 &&
@@ -408,6 +408,15 @@ test_expect_success 'checkout w/--track from non-branch HEAD fails' '
test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)"
'
+test_expect_success 'checkout w/--track from tag fails' '
+ git checkout master^0 &&
+ test_must_fail git symbolic-ref HEAD &&
+ test_must_fail git checkout --track -b track frotz &&
+ test_must_fail git rev-parse --verify track &&
+ test_must_fail git symbolic-ref HEAD &&
+ test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)"
+'
+
test_expect_success 'detach a symbolic link HEAD' '
git checkout master &&
git config --bool core.prefersymlinkrefs yes &&
@@ -423,7 +432,6 @@ test_expect_success 'detach a symbolic link HEAD' '
test_expect_success \
'checkout with --track fakes a sensible -b <name>' '
git update-ref refs/remotes/origin/koala/bear renamer &&
- git update-ref refs/new/koala/bear renamer &&
git checkout --track origin/koala/bear &&
test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
@@ -439,12 +447,6 @@ test_expect_success \
git checkout --track remotes/origin/koala/bear &&
test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
- test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" &&
-
- git checkout master && git branch -D koala/bear &&
-
- git checkout --track refs/new/koala/bear &&
- test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" &&
test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)"
'
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 02f67b73b7..800b5368a5 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -110,7 +110,7 @@ test_expect_success 'git clean with prefix' '
'
-test_expect_success 'git clean with relative prefix' '
+test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
@@ -125,7 +125,7 @@ test_expect_success 'git clean with relative prefix' '
}
'
-test_expect_success 'git clean with absolute path' '
+test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' '
mkdir -p build docs &&
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
@@ -377,7 +377,7 @@ test_expect_success 'clean.requireForce and -f' '
'
-test_expect_success 'core.excludesfile' '
+test_expect_success C_LOCALE_OUTPUT 'core.excludesfile' '
echo excludes >excludes &&
echo included >included &&
@@ -453,4 +453,11 @@ test_expect_success 'git clean -e' '
)
'
+test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
+ mkdir foo &&
+ chmod a= foo &&
+ git clean -dfx foo &&
+ ! test -d foo
+'
+
test_done
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index e5b19538b0..d600583cef 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -52,7 +52,7 @@ test_expect_success 'change submodule url' '
test_expect_success '"git submodule sync" should update submodule URLs' '
(cd super-clone &&
- git pull &&
+ git pull --no-recurse-submodules &&
git submodule sync
) &&
test -d "$(git config -f super-clone/submodule/.git/config \
diff --git a/t/t7405-submodule-merge.sh b/t/t7405-submodule-merge.sh
index 7e2e258950..a8fb30b792 100755
--- a/t/t7405-submodule-merge.sh
+++ b/t/t7405-submodule-merge.sh
@@ -56,11 +56,11 @@ test_expect_success setup '
# History setup
#
-# b
-# / \
-# a d
-# \ /
-# c
+# b
+# / \
+# init -- a d
+# \ \ /
+# g c
#
# a in the main repository records to sub-a in the submodule and
# analogous b and c. d should be automatically found by merging c into
@@ -76,6 +76,8 @@ test_expect_success 'setup for merge search' '
git add file-a &&
git commit -m "sub-a" &&
git branch sub-a) &&
+ git commit --allow-empty -m init &&
+ git branch init &&
git add sub &&
git commit -m "a" &&
git branch a &&
@@ -101,7 +103,13 @@ test_expect_success 'setup for merge search' '
git checkout -b sub-d sub-b &&
git merge sub-c) &&
git commit -a -m "d" &&
- git branch test b)
+ git branch test b &&
+
+ git checkout -b g init &&
+ (cd sub &&
+ git checkout -b sub-g sub-c) &&
+ git add sub &&
+ git commit -a -m "g")
'
test_expect_success 'merge with one side as a fast-forward of the other' '
@@ -176,6 +184,44 @@ test_expect_success 'merging should fail for changes that are backwards' '
test_must_fail git merge f)
'
+
+# Check that the conflicting submodule is detected when it is
+# in the common ancestor. status should be 'U00...00"
+test_expect_success 'git submodule status should display the merge conflict properly with merge base' '
+ (cd merge-search &&
+ cat >.gitmodules <<EOF &&
+[submodule "sub"]
+ path = sub
+ url = $TRASH_DIRECTORY/sub
+EOF
+ cat >expect <<EOF &&
+U0000000000000000000000000000000000000000 sub
+EOF
+ git submodule status > actual &&
+ test_cmp expect actual &&
+ git reset --hard)
+'
+
+# Check that the conflicting submodule is detected when it is
+# not in the common ancestor. status should be 'U00...00"
+test_expect_success 'git submodule status should display the merge conflict properly without merge-base' '
+ (cd merge-search &&
+ git checkout -b test-no-merge-base g &&
+ test_must_fail git merge b &&
+ cat >.gitmodules <<EOF &&
+[submodule "sub"]
+ path = sub
+ url = $TRASH_DIRECTORY/sub
+EOF
+ cat >expect <<EOF &&
+U0000000000000000000000000000000000000000 sub
+EOF
+ git submodule status > actual &&
+ test_cmp expect actual &&
+ git reset --hard)
+'
+
+
test_expect_success 'merging with a modify/modify conflict between merge bases' '
git reset --hard HEAD &&
git checkout -b test2 c &&
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index bfb4975e94..bf7c788735 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -74,6 +74,26 @@ test_expect_success 'submodule update detaching the HEAD ' '
)
'
+apos="'";
+test_expect_success 'submodule update does not fetch already present commits' '
+ (cd submodule &&
+ echo line3 >> file &&
+ git add file &&
+ test_tick &&
+ git commit -m "upstream line3"
+ ) &&
+ (cd super/submodule &&
+ head=$(git rev-parse --verify HEAD) &&
+ echo "Submodule path ${apos}submodule$apos: checked out $apos$head$apos" > ../../expected &&
+ git reset --hard HEAD~1
+ ) &&
+ (cd super &&
+ git submodule update > ../actual 2> ../actual.err
+ ) &&
+ test_cmp expected actual &&
+ ! test -s actual.err
+'
+
test_expect_success 'submodule update --rebase staying on master' '
(cd super/submodule &&
git checkout master
@@ -203,4 +223,56 @@ test_expect_success 'submodule init picks up merge' '
)
'
+test_expect_success 'submodule update --merge - ignores --merge for new submodules' '
+ (cd super &&
+ rm -rf submodule &&
+ git submodule update submodule &&
+ git status -s submodule >expect &&
+ rm -rf submodule &&
+ git submodule update --merge submodule &&
+ git status -s submodule >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'submodule update --rebase - ignores --rebase for new submodules' '
+ (cd super &&
+ rm -rf submodule &&
+ git submodule update submodule &&
+ git status -s submodule >expect &&
+ rm -rf submodule &&
+ git submodule update --rebase submodule &&
+ git status -s submodule >actual &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'submodule update ignores update=merge config for new submodules' '
+ (cd super &&
+ rm -rf submodule &&
+ git submodule update submodule &&
+ git status -s submodule >expect &&
+ rm -rf submodule &&
+ git config submodule.submodule.update merge &&
+ git submodule update submodule &&
+ git status -s submodule >actual &&
+ git config --unset submodule.submodule.update &&
+ test_cmp expect actual
+ )
+'
+
+test_expect_success 'submodule update ignores update=rebase config for new submodules' '
+ (cd super &&
+ rm -rf submodule &&
+ git submodule update submodule &&
+ git status -s submodule >expect &&
+ rm -rf submodule &&
+ git config submodule.submodule.update rebase &&
+ git submodule update submodule &&
+ git status -s submodule >actual &&
+ git config --unset submodule.submodule.update &&
+ test_cmp expect actual
+ )
+'
+
test_done
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index d8ad25036f..e5be13c271 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -238,6 +238,10 @@ test_expect_success 'ensure "status --cached --recursive" preserves the --cached
) &&
git submodule status --cached --recursive -- nested1 > ../actual
) &&
+ if test_have_prereq MINGW
+ then
+ dos2unix actual
+ fi &&
test_cmp expect actual
'
diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh
index 162527c211..bcdf0847d0 100755
--- a/t/t7500-commit.sh
+++ b/t/t7500-commit.sh
@@ -10,7 +10,12 @@ Tests for selected commit options.'
. ./test-lib.sh
commit_msg_is () {
- test "`git log --pretty=format:%s%b -1`" = "$1"
+ expect=commit_msg_is.expect
+ actual=commit_msg_is.actual
+
+ printf "%s" "$(git log --pretty=format:%s%b -1)" >$expect &&
+ printf "%s" "$1" >$actual &&
+ test_cmp $expect $actual
}
# A sanity check to see if commit is working at all.
@@ -23,13 +28,21 @@ test_expect_success 'a basic commit in an empty tree should succeed' '
test_expect_success 'nonexistent template file should return error' '
echo changes >> foo &&
git add foo &&
- test_must_fail git commit --template "$PWD"/notexist
+ (
+ GIT_EDITOR="echo hello >\"\$1\"" &&
+ export GIT_EDITOR &&
+ test_must_fail git commit --template "$PWD"/notexist
+ )
'
test_expect_success 'nonexistent template file in config should return error' '
git config commit.template "$PWD"/notexist &&
- test_must_fail git commit &&
- git config --unset commit.template
+ test_when_finished "git config --unset commit.template" &&
+ (
+ GIT_EDITOR="echo hello >\"\$1\"" &&
+ export GIT_EDITOR &&
+ test_must_fail git commit
+ )
'
# From now on we'll use a template file that exists.
@@ -59,7 +72,7 @@ test_expect_success 'adding comments to a template should not commit' '
)
'
-test_expect_success 'adding real content to a template should commit' '
+test_expect_success C_LOCALE_OUTPUT 'adding real content to a template should commit' '
(
test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
git commit --template "$TEMPLATE"
@@ -67,7 +80,7 @@ test_expect_success 'adding real content to a template should commit' '
commit_msg_is "template linecommit message"
'
-test_expect_success '-t option should be short for --template' '
+test_expect_success C_LOCALE_OUTPUT '-t option should be short for --template' '
echo "short template" > "$TEMPLATE" &&
echo "new content" >> foo &&
git add foo &&
@@ -78,7 +91,7 @@ test_expect_success '-t option should be short for --template' '
commit_msg_is "short templatecommit message"
'
-test_expect_success 'config-specified template should commit' '
+test_expect_success C_LOCALE_OUTPUT 'config-specified template should commit' '
echo "new template" > "$TEMPLATE" &&
git config commit.template "$TEMPLATE" &&
echo "more content" >> foo &&
@@ -277,7 +290,7 @@ test_expect_success 'commit --squash works with -c for same commit' '
commit_msg_is "squash! edited commit"
'
-test_expect_success 'commit --squash works with editor' '
+test_expect_success C_LOCALE_OUTPUT 'commit --squash works with editor' '
commit_for_rebase_autosquash_setup &&
test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
git commit --squash HEAD~1 &&
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 8980738c75..a76c474195 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -14,8 +14,11 @@ test_tick
test_expect_success \
"initial status" \
"echo 'bongo bongo' >file &&
- git add file && \
- git status | grep 'Initial commit'"
+ git add file"
+
+test_expect_success C_LOCALE_OUTPUT \
+ "Constructing initial commit" \
+ "git status | grep 'Initial commit'"
test_expect_success \
"fail initial amend" \
diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh
index 50da034cd3..cfb569eaba 100755
--- a/t/t7502-commit.sh
+++ b/t/t7502-commit.sh
@@ -22,7 +22,10 @@ check_summary_oneline() {
SUMMARY_POSTFIX="$(git log -1 --pretty='format:%h')"
echo "[$SUMMARY_PREFIX $SUMMARY_POSTFIX] $2" >exp &&
- test_cmp exp act
+ if test_have_prereq C_LOCALE_OUTPUT
+ then
+ test_cmp exp act
+ fi
}
test_expect_success 'output summary format' '
@@ -32,7 +35,10 @@ test_expect_success 'output summary format' '
check_summary_oneline "root-commit" "initial" &&
echo change >>file1 &&
- git add file1 &&
+ git add file1
+'
+
+test_expect_success 'output summary format: root-commit' '
check_summary_oneline "" "a change"
'
@@ -215,30 +221,35 @@ test_expect_success 'cleanup commit messages (strip,-F)' '
'
-echo "sample
-
-# Please enter the commit message for your changes. Lines starting
-# with '#' will be ignored, and an empty message aborts the commit." >expect
-
test_expect_success 'cleanup commit messages (strip,-F,-e)' '
echo >>negative &&
{ echo;echo sample;echo; } >text &&
git commit -e -F text -a &&
- head -n 4 .git/COMMIT_EDITMSG >actual &&
- test_cmp expect actual
+ head -n 4 .git/COMMIT_EDITMSG >actual
+'
+
+echo "sample
+
+# Please enter the commit message for your changes. Lines starting
+# with '#' will be ignored, and an empty message aborts the commit." >expect
+test_expect_success C_LOCALE_OUTPUT 'cleanup commit messages (strip,-F,-e): output' '
+ test_cmp expect actual
'
echo "#
# Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>
#" >> expect
-test_expect_success 'author different from committer' '
+test_expect_success C_LOCALE_OUTPUT 'author different from committer' '
echo >>negative &&
git commit -e -m "sample"
- head -n 7 .git/COMMIT_EDITMSG >actual &&
+ head -n 7 .git/COMMIT_EDITMSG >actual
+'
+
+test_expect_success C_LOCALE_OUTPUT 'author different from committer: output' '
test_cmp expect actual
'
@@ -248,7 +259,7 @@ rm -f expect.tmp
echo "# Committer:
#" >> expect
-test_expect_success 'committer is automatic' '
+test_expect_success C_LOCALE_OUTPUT 'committer is automatic' '
echo >>negative &&
(
@@ -258,7 +269,10 @@ test_expect_success 'committer is automatic' '
test_must_fail git commit -e -m "sample"
) &&
head -n 8 .git/COMMIT_EDITMSG | \
- sed "s/^# Committer: .*/# Committer:/" >actual &&
+ sed "s/^# Committer: .*/# Committer:/" >actual
+'
+
+test_expect_success C_LOCALE_OUTPUT 'committer is automatic: output' '
test_cmp expect actual
'
@@ -370,66 +384,66 @@ try_commit () {
try_commit_status_combo () {
- test_expect_success 'commit' '
+ test_expect_success C_LOCALE_OUTPUT 'commit' '
clear_config commit.status &&
try_commit "" &&
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit' '
+ test_expect_success C_LOCALE_OUTPUT 'commit' '
clear_config commit.status &&
try_commit "" &&
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit --status' '
+ test_expect_success C_LOCALE_OUTPUT 'commit --status' '
clear_config commit.status &&
try_commit --status &&
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit --no-status' '
+ test_expect_success C_LOCALE_OUTPUT 'commit --no-status' '
clear_config commit.status &&
try_commit --no-status &&
! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit with commit.status = yes' '
+ test_expect_success C_LOCALE_OUTPUT 'commit with commit.status = yes' '
clear_config commit.status &&
git config commit.status yes &&
try_commit "" &&
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit with commit.status = no' '
+ test_expect_success C_LOCALE_OUTPUT 'commit with commit.status = no' '
clear_config commit.status &&
git config commit.status no &&
try_commit "" &&
! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit --status with commit.status = yes' '
+ test_expect_success C_LOCALE_OUTPUT 'commit --status with commit.status = yes' '
clear_config commit.status &&
git config commit.status yes &&
try_commit --status &&
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit --no-status with commit.status = yes' '
+ test_expect_success C_LOCALE_OUTPUT 'commit --no-status with commit.status = yes' '
clear_config commit.status &&
git config commit.status yes &&
try_commit --no-status &&
! grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit --status with commit.status = no' '
+ test_expect_success C_LOCALE_OUTPUT 'commit --status with commit.status = no' '
clear_config commit.status &&
git config commit.status no &&
try_commit --status &&
grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
'
- test_expect_success 'commit --no-status with commit.status = no' '
+ test_expect_success C_LOCALE_OUTPUT 'commit --no-status with commit.status = no' '
clear_config commit.status &&
git config commit.status no &&
try_commit --no-status &&
diff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh
index ff189624d4..5b4b694f18 100755
--- a/t/t7505-prepare-commit-msg-hook.sh
+++ b/t/t7505-prepare-commit-msg-hook.sh
@@ -132,6 +132,18 @@ test_expect_success 'with hook (-c)' '
'
+test_expect_success 'with hook (merge)' '
+
+ head=`git rev-parse HEAD` &&
+ git checkout -b other HEAD@{1} &&
+ echo "more" >> file &&
+ git add file &&
+ git commit -m other &&
+ git checkout - &&
+ git merge other &&
+ test "`git log -1 --pretty=format:%s`" = merge
+'
+
cat > "$HOOK" <<'EOF'
#!/bin/sh
exit 1
diff --git a/t/t7506-status-submodule.sh b/t/t7506-status-submodule.sh
index 3d4f85d74f..c56733253f 100755
--- a/t/t7506-status-submodule.sh
+++ b/t/t7506-status-submodule.sh
@@ -20,17 +20,17 @@ test_expect_success 'setup' '
git commit -m "Add submodule sub"
'
-test_expect_success 'status clean' '
+test_expect_success C_LOCALE_OUTPUT 'status clean' '
git status >output &&
grep "nothing to commit" output
'
-test_expect_success 'commit --dry-run -a clean' '
+test_expect_success C_LOCALE_OUTPUT 'commit --dry-run -a clean' '
test_must_fail git commit --dry-run -a >output &&
grep "nothing to commit" output
'
-test_expect_success 'status with modified file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with modified file in submodule' '
(cd sub && git reset --hard) &&
echo "changed" >sub/foo &&
git status >output &&
@@ -46,7 +46,7 @@ test_expect_success 'status with modified file in submodule (porcelain)' '
EOF
'
-test_expect_success 'status with added file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with added file in submodule' '
(cd sub && git reset --hard && echo >foo && git add foo) &&
git status >output &&
grep "modified: sub (modified content)" output
@@ -60,14 +60,14 @@ test_expect_success 'status with added file in submodule (porcelain)' '
EOF
'
-test_expect_success 'status with untracked file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with untracked file in submodule' '
(cd sub && git reset --hard) &&
echo "content" >sub/new-file &&
git status >output &&
grep "modified: sub (untracked content)" output
'
-test_expect_success 'status -uno with untracked file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status -uno with untracked file in submodule' '
git status -uno >output &&
grep "^nothing to commit" output
'
@@ -79,7 +79,7 @@ test_expect_success 'status with untracked file in submodule (porcelain)' '
EOF
'
-test_expect_success 'status with added and untracked file in submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with added and untracked file in submodule' '
(cd sub && git reset --hard && echo >foo && git add foo) &&
echo "content" >sub/new-file &&
git status >output &&
@@ -95,7 +95,7 @@ test_expect_success 'status with added and untracked file in submodule (porcelai
EOF
'
-test_expect_success 'status with modified file in modified submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with modified file in modified submodule' '
(cd sub && git reset --hard) &&
rm sub/new-file &&
(cd sub && echo "next change" >foo && git commit -m "next change" foo) &&
@@ -113,7 +113,7 @@ test_expect_success 'status with modified file in modified submodule (porcelain)
EOF
'
-test_expect_success 'status with added file in modified submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with added file in modified submodule' '
(cd sub && git reset --hard && echo >foo && git add foo) &&
git status >output &&
grep "modified: sub (new commits, modified content)" output
@@ -127,7 +127,7 @@ test_expect_success 'status with added file in modified submodule (porcelain)' '
EOF
'
-test_expect_success 'status with untracked file in modified submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with untracked file in modified submodule' '
(cd sub && git reset --hard) &&
echo "content" >sub/new-file &&
git status >output &&
@@ -141,7 +141,7 @@ test_expect_success 'status with untracked file in modified submodule (porcelain
EOF
'
-test_expect_success 'status with added and untracked file in modified submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status with added and untracked file in modified submodule' '
(cd sub && git reset --hard && echo >foo && git add foo) &&
echo "content" >sub/new-file &&
git status >output &&
@@ -167,7 +167,7 @@ test_expect_success 'setup .git file for sub' '
git commit -m "added .real to .gitignore" .gitignore
'
-test_expect_success 'status with added file in modified submodule with .git file' '
+test_expect_success C_LOCALE_OUTPUT 'status with added file in modified submodule with .git file' '
(cd sub && git reset --hard && echo >foo && git add foo) &&
git status >output &&
grep "modified: sub (new commits, modified content)" output
@@ -177,12 +177,12 @@ test_expect_success 'rm submodule contents' '
rm -rf sub/* sub/.git
'
-test_expect_success 'status clean (empty submodule dir)' '
+test_expect_success C_LOCALE_OUTPUT 'status clean (empty submodule dir)' '
git status >output &&
grep "nothing to commit" output
'
-test_expect_success 'status -a clean (empty submodule dir)' '
+test_expect_success C_LOCALE_OUTPUT 'status -a clean (empty submodule dir)' '
test_must_fail git commit --dry-run -a >output &&
grep "nothing to commit" output
'
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index f1dc5c3b6a..a93e70fac4 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -55,7 +55,7 @@ test_expect_success 'setup' '
git add dir2/added
'
-test_expect_success 'status (1)' '
+test_expect_success C_LOCALE_OUTPUT 'status (1)' '
grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
@@ -85,7 +85,7 @@ cat >expect <<\EOF
# untracked
EOF
-test_expect_success 'status (2)' '
+test_expect_success C_LOCALE_OUTPUT 'status (2)' '
git status >output &&
test_cmp expect output
@@ -111,7 +111,7 @@ EOF
git config advice.statusHints false
-test_expect_success 'status (advice.statusHints false)' '
+test_expect_success C_LOCALE_OUTPUT 'status (advice.statusHints false)' '
git status >output &&
test_cmp expect output
@@ -157,6 +157,12 @@ test_expect_success 'status -s -b' '
'
+test_expect_success 'setup dir3' '
+ mkdir dir3 &&
+ : >dir3/untracked1 &&
+ : >dir3/untracked2
+'
+
cat >expect <<EOF
# On branch master
# Changes to be committed:
@@ -172,16 +178,14 @@ cat >expect <<EOF
#
# Untracked files not listed (use -u option to show untracked files)
EOF
-test_expect_success 'status -uno' '
- mkdir dir3 &&
- : >dir3/untracked1 &&
- : >dir3/untracked2 &&
+test_expect_success C_LOCALE_OUTPUT 'status -uno' '
git status -uno >output &&
test_cmp expect output
'
-test_expect_success 'status (status.showUntrackedFiles no)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles no)' '
git config status.showuntrackedfiles no
+ test_when_finished "git config --unset status.showuntrackedfiles" &&
git status >output &&
test_cmp expect output
'
@@ -197,7 +201,7 @@ cat >expect <<EOF
# Untracked files not listed
EOF
git config advice.statusHints false
-test_expect_success 'status -uno (advice.statusHints false)' '
+test_expect_success C_LOCALE_OUTPUT 'status -uno (advice.statusHints false)' '
git status -uno >output &&
test_cmp expect output
'
@@ -208,7 +212,6 @@ cat >expect << EOF
A dir2/added
EOF
test_expect_success 'status -s -uno' '
- git config --unset status.showuntrackedfiles
git status -s -uno >output &&
test_cmp expect output
'
@@ -243,13 +246,14 @@ cat >expect <<EOF
# output
# untracked
EOF
-test_expect_success 'status -unormal' '
+test_expect_success C_LOCALE_OUTPUT 'status -unormal' '
git status -unormal >output &&
test_cmp expect output
'
-test_expect_success 'status (status.showUntrackedFiles normal)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles normal)' '
git config status.showuntrackedfiles normal
+ test_when_finished "git config --unset status.showuntrackedfiles" &&
git status >output &&
test_cmp expect output
'
@@ -266,7 +270,6 @@ A dir2/added
?? untracked
EOF
test_expect_success 'status -s -unormal' '
- git config --unset status.showuntrackedfiles
git status -s -unormal >output &&
test_cmp expect output
'
@@ -302,18 +305,21 @@ cat >expect <<EOF
# output
# untracked
EOF
-test_expect_success 'status -uall' '
+test_expect_success C_LOCALE_OUTPUT 'status -uall' '
git status -uall >output &&
test_cmp expect output
'
-test_expect_success 'status (status.showUntrackedFiles all)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles all)' '
git config status.showuntrackedfiles all
+ test_when_finished "git config --unset status.showuntrackedfiles" &&
git status >output &&
- rm -rf dir3 &&
- git config --unset status.showuntrackedfiles &&
test_cmp expect output
'
+test_expect_success 'teardown dir3' '
+ rm -rf dir3
+'
+
cat >expect <<EOF
M dir1/modified
A dir2/added
@@ -361,7 +367,7 @@ cat >expect <<\EOF
# ../untracked
EOF
-test_expect_success 'status with relative paths' '
+test_expect_success C_LOCALE_OUTPUT 'status with relative paths' '
(cd dir1 && git status) >output &&
test_cmp expect output
@@ -434,18 +440,19 @@ cat >expect <<\EOF
# <BLUE>untracked<RESET>
EOF
-test_expect_success 'status with color.ui' '
+test_expect_success C_LOCALE_OUTPUT 'status with color.ui' '
git config color.ui always &&
+ test_when_finished "git config --unset color.ui" &&
git status | test_decode_color >output &&
test_cmp expect output
'
-test_expect_success 'status with color.status' '
+test_expect_success C_LOCALE_OUTPUT 'status with color.status' '
- git config --unset color.ui &&
git config color.status always &&
+ test_when_finished "git config --unset color.status" &&
git status | test_decode_color >output &&
test_cmp expect output
@@ -464,7 +471,6 @@ EOF
test_expect_success 'status -s with color.ui' '
- git config --unset color.status &&
git config color.ui always &&
git status -s | test_decode_color >output &&
test_cmp expect output
@@ -564,9 +570,10 @@ cat >expect <<\EOF
EOF
-test_expect_success 'status without relative paths' '
+test_expect_success C_LOCALE_OUTPUT 'status without relative paths' '
- git config status.relativePaths false
+ git config status.relativePaths false &&
+ test_when_finished "git config --unset status.relativePaths" &&
(cd dir1 && git status) >output &&
test_cmp expect output
@@ -585,6 +592,8 @@ EOF
test_expect_success 'status -s without relative paths' '
+ git config status.relativePaths false &&
+ test_when_finished "git config --unset status.relativePaths" &&
(cd dir1 && git status -s) >output &&
test_cmp expect output
@@ -607,7 +616,10 @@ cat <<EOF >expect
# untracked
EOF
test_expect_success 'dry-run of partial commit excluding new file in index' '
- git commit --dry-run dir1/modified >output &&
+ git commit --dry-run dir1/modified >output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'dry-run of partial commit excluding new file in index: output' '
test_cmp expect output
'
@@ -655,13 +667,13 @@ cat >expect <<EOF
# output
# untracked
EOF
-test_expect_success 'status submodule summary is disabled by default' '
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary is disabled by default' '
git status >output &&
test_cmp expect output
'
# we expect the same as the previous test
-test_expect_success 'status --untracked-files=all does not show submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status --untracked-files=all does not show submodule' '
git status --untracked-files=all >output &&
test_cmp expect output
'
@@ -719,7 +731,7 @@ cat >expect <<EOF
# output
# untracked
EOF
-test_expect_success 'status submodule summary' '
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary' '
git config status.submodulesummary 10 &&
git status >output &&
test_cmp expect output
@@ -760,8 +772,11 @@ cat >expect <<EOF
# untracked
no changes added to commit (use "git add" and/or "git commit -a")
EOF
-test_expect_success 'status submodule summary (clean submodule)' '
- git commit -m "commit submodule" &&
+test_expect_success 'status submodule summary (clean submodule): commit' '
+ git commit -m "commit submodule"
+'
+
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary (clean submodule): output' '
git config status.submodulesummary 10 &&
test_must_fail git commit --dry-run >output &&
test_cmp expect output &&
@@ -812,7 +827,7 @@ cat >expect <<EOF
# output
# untracked
EOF
-test_expect_success 'commit --dry-run submodule summary (--amend)' '
+test_expect_success C_LOCALE_OUTPUT 'commit --dry-run submodule summary (--amend)' '
git config status.submodulesummary 10 &&
git commit --dry-run --amend >output &&
test_cmp expect output
@@ -867,13 +882,13 @@ cat > expect << EOF
# untracked
EOF
-test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=untracked suppresses submodules with untracked content' '
echo modified > sm/untracked &&
git status --ignore-submodules=untracked > output &&
test_cmp expect output
'
-test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=untracked suppresses submodules with untracked content' '
git config diff.ignoreSubmodules dirty &&
git status >output &&
test_cmp expect output &&
@@ -885,7 +900,7 @@ test_expect_success '.gitmodules ignore=untracked suppresses submodules with unt
git config --unset diff.ignoreSubmodules
'
-test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=untracked suppresses submodules with untracked content' '
git config --add -f .gitmodules submodule.subname.ignore none &&
git config --add -f .gitmodules submodule.subname.path sm &&
git config --add submodule.subname.ignore untracked &&
@@ -896,12 +911,12 @@ test_expect_success '.git/config ignore=untracked suppresses submodules with unt
git config --remove-section -f .gitmodules submodule.subname
'
-test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=dirty suppresses submodules with untracked content' '
git status --ignore-submodules=dirty > output &&
test_cmp expect output
'
-test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=dirty suppresses submodules with untracked content' '
git config diff.ignoreSubmodules dirty &&
git status >output &&
! test -s actual &&
@@ -913,7 +928,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with untrack
git config --unset diff.ignoreSubmodules
'
-test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=dirty suppresses submodules with untracked content' '
git config --add -f .gitmodules submodule.subname.ignore none &&
git config --add -f .gitmodules submodule.subname.path sm &&
git config --add submodule.subname.ignore dirty &&
@@ -924,13 +939,13 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with untrack
git config -f .gitmodules --remove-section submodule.subname
'
-test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=dirty suppresses submodules with modified content' '
echo modified > sm/foo &&
git status --ignore-submodules=dirty > output &&
test_cmp expect output
'
-test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=dirty suppresses submodules with modified content' '
git config --add -f .gitmodules submodule.subname.ignore dirty &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status > output &&
@@ -938,7 +953,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with modifie
git config -f .gitmodules --remove-section submodule.subname
'
-test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=dirty suppresses submodules with modified content' '
git config --add -f .gitmodules submodule.subname.ignore none &&
git config --add -f .gitmodules submodule.subname.path sm &&
git config --add submodule.subname.ignore dirty &&
@@ -981,12 +996,12 @@ cat > expect << EOF
# untracked
EOF
-test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
git status --ignore-submodules=untracked > output &&
test_cmp expect output
'
-test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
git config --add -f .gitmodules submodule.subname.ignore untracked &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status > output &&
@@ -994,7 +1009,7 @@ test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules wi
git config -f .gitmodules --remove-section submodule.subname
'
-test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=untracked doesn't suppress submodules with modified content" '
git config --add -f .gitmodules submodule.subname.ignore none &&
git config --add -f .gitmodules submodule.subname.path sm &&
git config --add submodule.subname.ignore untracked &&
@@ -1043,12 +1058,12 @@ cat > expect << EOF
# untracked
EOF
-test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=untracked doesn't suppress submodule summary" '
git status --ignore-submodules=untracked > output &&
test_cmp expect output
'
-test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=untracked doesn't suppress submodule summary" '
git config --add -f .gitmodules submodule.subname.ignore untracked &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status > output &&
@@ -1056,7 +1071,7 @@ test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule sum
git config -f .gitmodules --remove-section submodule.subname
'
-test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=untracked doesn't suppress submodule summary" '
git config --add -f .gitmodules submodule.subname.ignore none &&
git config --add -f .gitmodules submodule.subname.path sm &&
git config --add submodule.subname.ignore untracked &&
@@ -1067,11 +1082,11 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodule sum
git config -f .gitmodules --remove-section submodule.subname
'
-test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=dirty doesn't suppress submodule summary" '
git status --ignore-submodules=dirty > output &&
test_cmp expect output
'
-test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=dirty doesn't suppress submodule summary" '
git config --add -f .gitmodules submodule.subname.ignore dirty &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status > output &&
@@ -1079,7 +1094,7 @@ test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary
git config -f .gitmodules --remove-section submodule.subname
'
-test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=dirty doesn't suppress submodule summary" '
git config --add -f .gitmodules submodule.subname.ignore none &&
git config --add -f .gitmodules submodule.subname.path sm &&
git config --add submodule.subname.ignore dirty &&
@@ -1111,7 +1126,7 @@ cat > expect << EOF
no changes added to commit (use "git add" and/or "git commit -a")
EOF
-test_expect_success "--ignore-submodules=all suppresses submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=all suppresses submodule summary" '
git status --ignore-submodules=all > output &&
test_cmp expect output
'
diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh
index 77b6920029..b61fd3c3c4 100755
--- a/t/t7509-commit.sh
+++ b/t/t7509-commit.sh
@@ -157,4 +157,33 @@ test_expect_success '--reset-author should be rejected without -c/-C/--amend' '
test_must_fail git commit -a --reset-author -m done
'
+test_expect_success 'commit respects CHERRY_PICK_HEAD and MERGE_MSG' '
+ echo "cherry-pick 1a" >>foo &&
+ test_tick &&
+ git commit -am "cherry-pick 1" --author="Cherry <cherry@pick.er>" &&
+ git tag cherry-pick-head &&
+ git rev-parse cherry-pick-head >.git/CHERRY_PICK_HEAD &&
+ echo "This is a MERGE_MSG" >.git/MERGE_MSG &&
+ echo "cherry-pick 1b" >>foo &&
+ test_tick &&
+ git commit -a &&
+ author_header cherry-pick-head >expect &&
+ author_header HEAD >actual &&
+ test_cmp expect actual &&
+
+ echo "This is a MERGE_MSG" >expect &&
+ message_body HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success '--reset-author with CHERRY_PICK_HEAD' '
+ git rev-parse cherry-pick-head >.git/CHERRY_PICK_HEAD &&
+ echo "cherry-pick 2" >>foo &&
+ test_tick &&
+ git commit -am "cherry-pick 2" --reset-author &&
+ echo "author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
+ author_header HEAD >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index b147a1bd69..5463f87e68 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -324,6 +324,38 @@ test_expect_success 'merge c1 with c2 (no-commit in config)' '
test_debug 'git log --graph --decorate --oneline --all'
+test_expect_success 'merge c1 with c2 (log in config)' '
+ git config branch.master.mergeoptions "" &&
+ git reset --hard c1 &&
+ git merge --log c2 &&
+ git show -s --pretty=tformat:%s%n%b >expect &&
+
+ git config branch.master.mergeoptions --log &&
+ git reset --hard c1 &&
+ git merge c2 &&
+ git show -s --pretty=tformat:%s%n%b >actual &&
+
+ test_cmp expect actual
+'
+
+test_expect_success 'merge c1 with c2 (log in config gets overridden)' '
+ (
+ git config --remove-section branch.master
+ git config --remove-section merge
+ )
+ git reset --hard c1 &&
+ git merge c2 &&
+ git show -s --pretty=tformat:%s%n%b >expect &&
+
+ git config branch.master.mergeoptions "--no-log" &&
+ git config merge.log true &&
+ git reset --hard c1 &&
+ git merge c2 &&
+ git show -s --pretty=tformat:%s%n%b >actual &&
+
+ test_cmp expect actual
+'
+
test_expect_success 'merge c1 with c2 (squash in config)' '
git reset --hard c1 &&
git config branch.master.mergeoptions "--squash" &&
@@ -495,7 +527,7 @@ test_expect_success 'merge fast-forward in a dirty tree' '
test_debug 'git log --graph --decorate --oneline --all'
-test_expect_success 'in-index merge' '
+test_expect_success C_LOCALE_OUTPUT 'in-index merge' '
git reset --hard c0 &&
git merge --no-ff -s resolve c1 >out &&
grep "Wonderful." out &&
diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh
index 4d5ce4e682..ef84f04102 100755
--- a/t/t7607-merge-overwrite.sh
+++ b/t/t7607-merge-overwrite.sh
@@ -122,7 +122,7 @@ test_expect_success 'will not overwrite untracked file in leading path' '
rm -f sub sub2
'
-test_expect_failure SYMLINKS 'will not overwrite untracked symlink in leading path' '
+test_expect_success SYMLINKS 'will not overwrite untracked symlink in leading path' '
git reset --hard c0 &&
rm -rf sub &&
mkdir sub2 &&
@@ -150,10 +150,37 @@ test_expect_success 'will not overwrite untracked file on unborn branch' '
git rm -fr . &&
git checkout --orphan new &&
cp important c0.c &&
- test_must_fail git merge c0 2>out &&
- test_cmp out expect &&
+ test_must_fail git merge c0 2>out
+'
+
+test_expect_success C_LOCALE_OUTPUT 'will not overwrite untracked file on unborn branch: output' '
+ test_cmp out expect
+'
+
+test_expect_success 'will not overwrite untracked file on unborn branch .git/MERGE_HEAD sanity etc.' '
+ test_when_finished "rm c0.c" &&
test_path_is_missing .git/MERGE_HEAD &&
test_cmp important c0.c
'
+test_expect_success 'failed merge leaves unborn branch in the womb' '
+ test_must_fail git rev-parse --verify HEAD
+'
+
+test_expect_success 'set up unborn branch and content' '
+ git symbolic-ref HEAD refs/heads/unborn &&
+ rm -f .git/index &&
+ echo foo > tracked-file &&
+ git add tracked-file &&
+ echo bar > untracked-file
+'
+
+test_expect_success 'will not clobber WT/index when merging into unborn' '
+ git merge master &&
+ grep foo tracked-file &&
+ git show :tracked-file >expect &&
+ grep foo expect &&
+ grep bar untracked-file
+'
+
test_done
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index d78bdec330..cbc08e3276 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -16,23 +16,57 @@ Testing basic merge tool invocation'
test_expect_success 'setup' '
git config rerere.enabled true &&
echo master >file1 &&
+ echo master file11 >file11 &&
+ echo master file12 >file12 &&
+ echo master file13 >file13 &&
+ echo master file14 >file14 &&
mkdir subdir &&
echo master sub >subdir/file3 &&
- git add file1 subdir/file3 &&
- git commit -m "added file1" &&
+ test_create_repo submod &&
+ (
+ cd submod &&
+ : >foo &&
+ git add foo &&
+ git commit -m "Add foo"
+ ) &&
+ git submodule add git://example.com/submod submod &&
+ git add file1 file1[1-4] subdir/file3 .gitmodules submod &&
+ git commit -m "add initial versions" &&
git checkout -b branch1 master &&
+ git submodule update -N &&
echo branch1 change >file1 &&
echo branch1 newfile >file2 &&
+ echo branch1 change file11 >file11 &&
+ echo branch1 change file13 >file13 &&
echo branch1 sub >subdir/file3 &&
- git add file1 file2 subdir/file3 &&
+ (
+ cd submod &&
+ echo branch1 submodule >bar &&
+ git add bar &&
+ git commit -m "Add bar on branch1" &&
+ git checkout -b submod-branch1
+ ) &&
+ git add file1 file11 file13 file2 subdir/file3 submod &&
+ git rm file12 &&
git commit -m "branch1 changes" &&
git checkout master &&
+ git submodule update -N &&
echo master updated >file1 &&
echo master new >file2 &&
+ echo master updated file12 >file12 &&
+ echo master updated file14 >file14 &&
echo master new sub >subdir/file3 &&
- git add file1 file2 subdir/file3 &&
+ (
+ cd submod &&
+ echo master submodule >bar &&
+ git add bar &&
+ git commit -m "Add bar on master" &&
+ git checkout -b submod-master
+ ) &&
+ git add file1 file12 file14 file2 subdir/file3 submod &&
+ git rm file11 &&
git commit -m "master updates" &&
git config merge.tool mytool &&
@@ -42,13 +76,18 @@ test_expect_success 'setup' '
test_expect_success 'custom mergetool' '
git checkout -b test1 branch1 &&
+ git submodule update -N &&
test_must_fail git merge master >/dev/null 2>&1 &&
( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
+ ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
test "$(cat file1)" = "master updated" &&
test "$(cat file2)" = "master new" &&
test "$(cat subdir/file3)" = "master new sub" &&
+ test "$(cat submod/bar)" = "branch1 submodule" &&
git commit -m "branch1 resolved with mergetool"
'
@@ -59,9 +98,14 @@ test_expect_success 'mergetool crlf' '
( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
+ ( yes "r" | git mergetool submod >/dev/null 2>&1 ) &&
test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" &&
test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" &&
test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" &&
+ git submodule update -N &&
+ test "$(cat submod/bar)" = "master submodule" &&
git commit -m "branch1 resolved with mergetool - autocrlf" &&
git config core.autocrlf false &&
git reset --hard
@@ -69,6 +113,7 @@ test_expect_success 'mergetool crlf' '
test_expect_success 'mergetool in subdir' '
git checkout -b test3 branch1 &&
+ git submodule update -N &&
(
cd subdir &&
test_must_fail git merge master >/dev/null 2>&1 &&
@@ -82,16 +127,24 @@ test_expect_success 'mergetool on file in parent dir' '
cd subdir &&
( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) &&
+ ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) &&
test "$(cat ../file1)" = "master updated" &&
test "$(cat ../file2)" = "master new" &&
+ test "$(cat ../submod/bar)" = "branch1 submodule" &&
git commit -m "branch1 resolved with mergetool - subdir"
)
'
test_expect_success 'mergetool skips autoresolved' '
git checkout -b test4 branch1 &&
+ git submodule update -N &&
test_must_fail git merge master &&
test -n "$(git ls-files -u)" &&
+ ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) &&
+ ( yes "l" | git mergetool submod >/dev/null 2>&1 ) &&
output="$(git mergetool --no-prompt)" &&
test "$output" = "No files need merging" &&
git reset --hard
@@ -102,13 +155,272 @@ test_expect_success 'mergetool merges all from subdir' '
cd subdir &&
git config rerere.enabled false &&
test_must_fail git merge master &&
- git mergetool --no-prompt &&
+ ( yes "r" | git mergetool ../submod ) &&
+ ( yes "d" "d" | git mergetool --no-prompt ) &&
test "$(cat ../file1)" = "master updated" &&
test "$(cat ../file2)" = "master new" &&
test "$(cat file3)" = "master new sub" &&
- git add ../file1 ../file2 file3 &&
+ ( cd .. && git submodule update -N ) &&
+ test "$(cat ../submod/bar)" = "master submodule" &&
git commit -m "branch2 resolved by mergetool from subdir"
)
'
+test_expect_success 'mergetool skips resolved paths when rerere is active' '
+ git config rerere.enabled true &&
+ rm -rf .git/rr-cache &&
+ git checkout -b test5 branch1
+ git submodule update -N &&
+ test_must_fail git merge master >/dev/null 2>&1 &&
+ ( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) &&
+ ( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) &&
+ git submodule update -N &&
+ output="$(yes "n" | git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git reset --hard
+'
+
+test_expect_success 'deleted vs modified submodule' '
+ git checkout -b test6 branch1 &&
+ git submodule update -N &&
+ mv submod submod-movedaside &&
+ git rm submod &&
+ git commit -m "Submodule deleted from branch" &&
+ git checkout -b test6.a test6 &&
+ test_must_fail git merge master &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
+ ( yes "r" | git mergetool submod ) &&
+ rmdir submod && mv submod-movedaside submod &&
+ test "$(cat submod/bar)" = "branch1 submodule" &&
+ git submodule update -N &&
+ test "$(cat submod/bar)" = "master submodule" &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git commit -m "Merge resolved by keeping module" &&
+
+ mv submod submod-movedaside &&
+ git checkout -b test6.b test6 &&
+ git submodule update -N &&
+ test_must_fail git merge master &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
+ ( yes "l" | git mergetool submod ) &&
+ test ! -e submod &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git commit -m "Merge resolved by deleting module" &&
+
+ mv submod-movedaside submod &&
+ git checkout -b test6.c master &&
+ git submodule update -N &&
+ test_must_fail git merge test6 &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
+ ( yes "r" | git mergetool submod ) &&
+ test ! -e submod &&
+ test -d submod.orig &&
+ git submodule update -N &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git commit -m "Merge resolved by deleting module" &&
+ mv submod.orig submod &&
+
+ git checkout -b test6.d master &&
+ git submodule update -N &&
+ test_must_fail git merge test6 &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
+ ( yes "l" | git mergetool submod ) &&
+ test "$(cat submod/bar)" = "master submodule" &&
+ git submodule update -N &&
+ test "$(cat submod/bar)" = "master submodule" &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git commit -m "Merge resolved by keeping module" &&
+ git reset --hard HEAD
+'
+
+test_expect_success 'file vs modified submodule' '
+ git checkout -b test7 branch1 &&
+ git submodule update -N &&
+ mv submod submod-movedaside &&
+ git rm submod &&
+ echo not a submodule >submod &&
+ git add submod &&
+ git commit -m "Submodule path becomes file" &&
+ git checkout -b test7.a branch1 &&
+ test_must_fail git merge master &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
+ ( yes "r" | git mergetool submod ) &&
+ rmdir submod && mv submod-movedaside submod &&
+ test "$(cat submod/bar)" = "branch1 submodule" &&
+ git submodule update -N &&
+ test "$(cat submod/bar)" = "master submodule" &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git commit -m "Merge resolved by keeping module" &&
+
+ mv submod submod-movedaside &&
+ git checkout -b test7.b test7 &&
+ test_must_fail git merge master &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
+ ( yes "l" | git mergetool submod ) &&
+ git submodule update -N &&
+ test "$(cat submod)" = "not a submodule" &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git commit -m "Merge resolved by keeping file" &&
+
+ git checkout -b test7.c master &&
+ rmdir submod && mv submod-movedaside submod &&
+ test ! -e submod.orig &&
+ git submodule update -N &&
+ test_must_fail git merge test7 &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
+ ( yes "r" | git mergetool submod ) &&
+ test -d submod.orig &&
+ git submodule update -N &&
+ test "$(cat submod)" = "not a submodule" &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git commit -m "Merge resolved by keeping file" &&
+
+ git checkout -b test7.d master &&
+ rmdir submod && mv submod.orig submod &&
+ git submodule update -N &&
+ test_must_fail git merge test7 &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) &&
+ ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) &&
+ ( yes "l" | git mergetool submod ) &&
+ test "$(cat submod/bar)" = "master submodule" &&
+ git submodule update -N &&
+ test "$(cat submod/bar)" = "master submodule" &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git commit -m "Merge resolved by keeping module"
+'
+
+test_expect_success 'submodule in subdirectory' '
+ git checkout -b test10 branch1 &&
+ git submodule update -N &&
+ (
+ cd subdir &&
+ test_create_repo subdir_module &&
+ (
+ cd subdir_module &&
+ : >file15 &&
+ git add file15 &&
+ git commit -m "add initial versions"
+ )
+ ) &&
+ git submodule add git://example.com/subsubmodule subdir/subdir_module &&
+ git add subdir/subdir_module &&
+ git commit -m "add submodule in subdirectory" &&
+
+ git checkout -b test10.a test10 &&
+ git submodule update -N &&
+ (
+ cd subdir/subdir_module &&
+ git checkout -b super10.a &&
+ echo test10.a >file15 &&
+ git add file15 &&
+ git commit -m "on branch 10.a"
+ ) &&
+ git add subdir/subdir_module &&
+ git commit -m "change submodule in subdirectory on test10.a" &&
+
+ git checkout -b test10.b test10 &&
+ git submodule update -N &&
+ (
+ cd subdir/subdir_module &&
+ git checkout -b super10.b &&
+ echo test10.b >file15 &&
+ git add file15 &&
+ git commit -m "on branch 10.b"
+ ) &&
+ git add subdir/subdir_module &&
+ git commit -m "change submodule in subdirectory on test10.b" &&
+
+ test_must_fail git merge test10.a >/dev/null 2>&1 &&
+ (
+ cd subdir &&
+ ( yes "l" | git mergetool subdir_module )
+ ) &&
+ test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
+ git submodule update -N &&
+ test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
+ git reset --hard &&
+ git submodule update -N &&
+
+ test_must_fail git merge test10.a >/dev/null 2>&1 &&
+ ( yes "r" | git mergetool subdir/subdir_module ) &&
+ test "$(cat subdir/subdir_module/file15)" = "test10.b" &&
+ git submodule update -N &&
+ test "$(cat subdir/subdir_module/file15)" = "test10.a" &&
+ git commit -m "branch1 resolved with mergetool" &&
+ rm -rf subdir/subdir_module
+'
+
+test_expect_success 'directory vs modified submodule' '
+ git checkout -b test11 branch1 &&
+ mv submod submod-movedaside &&
+ git rm submod &&
+ mkdir submod &&
+ echo not a submodule >submod/file16 &&
+ git add submod/file16 &&
+ git commit -m "Submodule path becomes directory" &&
+
+ test_must_fail git merge master &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "l" | git mergetool submod ) &&
+ test "$(cat submod/file16)" = "not a submodule" &&
+ rm -rf submod.orig &&
+
+ git reset --hard &&
+ test_must_fail git merge master &&
+ test -n "$(git ls-files -u)" &&
+ test ! -e submod.orig &&
+ ( yes "r" | git mergetool submod ) &&
+ test -d submod.orig &&
+ test "$(cat submod.orig/file16)" = "not a submodule" &&
+ rm -r submod.orig &&
+ mv submod-movedaside/.git submod &&
+ ( cd submod && git clean -f && git reset --hard ) &&
+ git submodule update -N &&
+ test "$(cat submod/bar)" = "master submodule" &&
+ git reset --hard && rm -rf submod-movedaside &&
+
+ git checkout -b test11.c master &&
+ git submodule update -N &&
+ test_must_fail git merge test11 &&
+ test -n "$(git ls-files -u)" &&
+ ( yes "l" | git mergetool submod ) &&
+ git submodule update -N &&
+ test "$(cat submod/bar)" = "master submodule" &&
+
+ git reset --hard &&
+ git submodule update -N &&
+ test_must_fail git merge test11 &&
+ test -n "$(git ls-files -u)" &&
+ test ! -e submod.orig &&
+ ( yes "r" | git mergetool submod ) &&
+ test "$(cat submod/file16)" = "not a submodule" &&
+
+ git reset --hard master &&
+ ( cd submod && git clean -f && git reset --hard ) &&
+ git submodule update -N
+'
+
test_done
diff --git a/t/t7611-merge-abort.sh b/t/t7611-merge-abort.sh
index 61890bc892..cdb3f444cd 100755
--- a/t/t7611-merge-abort.sh
+++ b/t/t7611-merge-abort.sh
@@ -46,8 +46,14 @@ test_expect_success 'setup' '
pre_merge_head="$(git rev-parse HEAD)"
test_expect_success 'fails without MERGE_HEAD (unstarted merge)' '
- test_must_fail git merge --abort 2>output &&
- grep -q MERGE_HEAD output &&
+ test_must_fail git merge --abort 2>output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'fails without MERGE_HEAD (unstarted merge): fatal output' '
+ grep -q MERGE_HEAD output
+'
+
+test_expect_success 'fails without MERGE_HEAD (unstarted merge): .git/MERGE_HEAD sanity' '
test ! -f .git/MERGE_HEAD &&
test "$pre_merge_head" = "$(git rev-parse HEAD)"
'
@@ -57,8 +63,14 @@ test_expect_success 'fails without MERGE_HEAD (completed merge)' '
test ! -f .git/MERGE_HEAD &&
# Merge successfully completed
post_merge_head="$(git rev-parse HEAD)" &&
- test_must_fail git merge --abort 2>output &&
- grep -q MERGE_HEAD output &&
+ test_must_fail git merge --abort 2>output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'fails without MERGE_HEAD (completed merge): output' '
+ grep -q MERGE_HEAD output
+'
+
+test_expect_success 'fails without MERGE_HEAD (completed merge): .git/MERGE_HEAD sanity' '
test ! -f .git/MERGE_HEAD &&
test "$post_merge_head" = "$(git rev-parse HEAD)"
'
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index c8777589ca..8184c264cf 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -59,7 +59,29 @@ do
echo ${HC}file:4:foo mmap bar_mmap
echo ${HC}file:5:foo_mmap bar mmap baz
} >expected &&
- git grep -n -w -e mmap $H >actual &&
+ git -c grep.linenumber=false grep -n -w -e mmap $H >actual &&
+ test_cmp expected actual
+ '
+
+ test_expect_success "grep -w $L" '
+ {
+ echo ${HC}file:1:foo mmap bar
+ echo ${HC}file:3:foo_mmap bar mmap
+ echo ${HC}file:4:foo mmap bar_mmap
+ echo ${HC}file:5:foo_mmap bar mmap baz
+ } >expected &&
+ git -c grep.linenumber=true grep -w -e mmap $H >actual &&
+ test_cmp expected actual
+ '
+
+ test_expect_success "grep -w $L" '
+ {
+ echo ${HC}file:foo mmap bar
+ echo ${HC}file:foo_mmap bar mmap
+ echo ${HC}file:foo mmap bar_mmap
+ echo ${HC}file:foo_mmap bar mmap baz
+ } >expected &&
+ git -c grep.linenumber=true grep --no-line-number -w -e mmap $H >actual &&
test_cmp expected actual
'
@@ -182,6 +204,24 @@ do
test_cmp expected actual
'
+ test_expect_success "grep --max-depth 0 -- . t $L" '
+ {
+ echo ${HC}t/v:1:vvv
+ echo ${HC}v:1:vvv
+ } >expected &&
+ git grep --max-depth 0 -n -e vvv $H -- . t >actual &&
+ test_cmp expected actual
+ '
+
+ test_expect_success "grep --max-depth 0 -- t . $L" '
+ {
+ echo ${HC}t/v:1:vvv
+ echo ${HC}v:1:vvv
+ } >expected &&
+ git grep --max-depth 0 -n -e vvv $H -- t . >actual &&
+ test_cmp expected actual
+ '
+
done
cat >expected <<EOF
@@ -285,6 +325,11 @@ test_expect_success 'grep -f, ignore empty lines' '
test_cmp expected actual
'
+test_expect_success 'grep -f, ignore empty lines, read patterns from stdin' '
+ git grep -f - <patterns >actual &&
+ test_cmp expected actual
+'
+
cat >expected <<EOF
y:y yy
--
diff --git a/t/t7811-grep-open.sh b/t/t7811-grep-open.sh
index 568a6f2b69..aedf484fee 100755
--- a/t/t7811-grep-open.sh
+++ b/t/t7811-grep-open.sh
@@ -61,7 +61,7 @@ test_expect_success SIMPLEPAGER 'git grep -O' '
test_cmp empty out
'
-test_expect_success 'git grep -O --cached' '
+test_expect_success C_LOCALE_OUTPUT 'git grep -O --cached' '
test_must_fail git grep --cached -O GREP_PATTERN >out 2>msg &&
grep open-files-in-pager msg
'
diff --git a/t/t8001-annotate.sh b/t/t8001-annotate.sh
index 45cb60ea4b..41962f04a7 100755
--- a/t/t8001-annotate.sh
+++ b/t/t8001-annotate.sh
@@ -6,10 +6,11 @@ test_description='git annotate'
PROG='git annotate'
. "$TEST_DIRECTORY"/annotate-tests.sh
-test_expect_success \
- 'Annotating an old revision works' \
- '[ $(git annotate file master | awk "{print \$3}" | grep -c "^A$") -eq 2 ] && \
- [ $(git annotate file master | awk "{print \$3}" | grep -c "^B$") -eq 2 ]'
-
+test_expect_success 'Annotating an old revision works' '
+ git annotate file master >result &&
+ awk "{ print \$3; }" <result >authors &&
+ test 2 = $(grep A <authors | wc -l) &&
+ test 2 = $(grep B <authors | wc -l)
+'
test_done
diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh
index d3a51e1269..e2896cffc1 100755
--- a/t/t8002-blame.sh
+++ b/t/t8002-blame.sh
@@ -8,7 +8,7 @@ PROG='git blame -c'
PROG='git blame -c -e'
test_expect_success 'Blame --show-email works' '
- check_count "<A@test.git>" 1 "<B@test.git>" 1 "<B1@test.git>" 1 "<B2@test.git>" 1 "<author@example.com>" 1 "<C@test.git>" 1 "<D@test.git>" 1
+ check_count "<A@test.git>" 1 "<B@test.git>" 1 "<B1@test.git>" 1 "<B2@test.git>" 1 "<author@example.com>" 1 "<C@test.git>" 1 "<D@test.git>" 1 "<E at test dot git>" 1
'
test_done
diff --git a/t/t8006-blame-textconv.sh b/t/t8006-blame-textconv.sh
index ea64cd8d0f..32ec82ad67 100755
--- a/t/t8006-blame-textconv.sh
+++ b/t/t8006-blame-textconv.sh
@@ -25,7 +25,8 @@ test_expect_success 'setup ' '
echo "bin: test 1 version 2" >one.bin &&
echo "bin: test number 2 version 2" >>two.bin &&
if test_have_prereq SYMLINKS; then
- ln -sf two.bin symlink.bin
+ rm symlink.bin &&
+ ln -s two.bin symlink.bin
fi &&
GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
'
diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh
index 88a9751dd3..6f6175a8f7 100755
--- a/t/t9010-svn-fe.sh
+++ b/t/t9010-svn-fe.sh
@@ -9,6 +9,30 @@ reinit_git () {
git init
}
+properties () {
+ while test "$#" -ne 0
+ do
+ property="$1" &&
+ value="$2" &&
+ printf "%s\n" "K ${#property}" &&
+ printf "%s\n" "$property" &&
+ printf "%s\n" "V ${#value}" &&
+ printf "%s\n" "$value" &&
+ shift 2 ||
+ return 1
+ done
+}
+
+text_no_props () {
+ text="$1
+" &&
+ printf "%s\n" "Prop-content-length: 10" &&
+ printf "%s\n" "Text-content-length: ${#text}" &&
+ printf "%s\n" "Content-length: $((${#text} + 10))" &&
+ printf "%s\n" "" "PROPS-END" &&
+ printf "%s\n" "$text"
+}
+
>empty
test_expect_success 'empty dump' '
@@ -18,13 +42,794 @@ test_expect_success 'empty dump' '
git fast-import <stream
'
-test_expect_success 'v3 dumps not supported' '
+test_expect_success 'v4 dumps not supported' '
reinit_git &&
- echo "SVN-fs-dump-format-version: 3" >input &&
- test_must_fail test-svn-fe input >stream &&
+ echo "SVN-fs-dump-format-version: 4" >v4.dump &&
+ test_must_fail test-svn-fe v4.dump >stream &&
test_cmp empty stream
'
+test_expect_failure 'empty revision' '
+ reinit_git &&
+ printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
+ cat >emptyrev.dump <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 0
+ Content-length: 0
+
+ Revision-number: 2
+ Prop-content-length: 0
+ Content-length: 0
+
+ EOF
+ test-svn-fe emptyrev.dump >stream &&
+ git fast-import <stream &&
+ git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'empty properties' '
+ reinit_git &&
+ printf "rev <nobody, nobody@local>: %s\n" "" "" >expect &&
+ cat >emptyprop.dump <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Revision-number: 2
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+ EOF
+ test-svn-fe emptyprop.dump >stream &&
+ git fast-import <stream &&
+ git log -p --format="rev <%an, %ae>: %s" HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'author name and commit message' '
+ reinit_git &&
+ echo "<author@example.com, author@example.com@local>" >expect.author &&
+ cat >message <<-\EOF &&
+ A concise summary of the change
+
+ A detailed description of the change, why it is needed, what
+ was broken and why applying this is the best course of action.
+
+ * file.c
+ Details pertaining to an individual file.
+ EOF
+ {
+ properties \
+ svn:author author@example.com \
+ svn:log "$(cat message)" &&
+ echo PROPS-END
+ } >props &&
+ {
+ echo "SVN-fs-dump-format-version: 3" &&
+ echo &&
+ echo "Revision-number: 1" &&
+ echo Prop-content-length: $(wc -c <props) &&
+ echo Content-length: $(wc -c <props) &&
+ echo &&
+ cat props
+ } >log.dump &&
+ test-svn-fe log.dump >stream &&
+ git fast-import <stream &&
+ git log -p --format="%B" HEAD >actual.log &&
+ git log --format="<%an, %ae>" >actual.author &&
+ test_cmp message actual.log &&
+ test_cmp expect.author actual.author
+'
+
+test_expect_success 'unsupported properties are ignored' '
+ reinit_git &&
+ echo author >expect &&
+ cat >extraprop.dump <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 56
+ Content-length: 56
+
+ K 8
+ nonsense
+ V 1
+ y
+ K 10
+ svn:author
+ V 6
+ author
+ PROPS-END
+ EOF
+ test-svn-fe extraprop.dump >stream &&
+ git fast-import <stream &&
+ git log -p --format=%an HEAD >actual &&
+ test_cmp expect actual
+'
+
+test_expect_failure 'timestamp and empty file' '
+ echo author@example.com >expect.author &&
+ echo 1999-01-01 >expect.date &&
+ echo file >expect.files &&
+ reinit_git &&
+ {
+ properties \
+ svn:author author@example.com \
+ svn:date "1999-01-01T00:01:002.000000Z" \
+ svn:log "add empty file" &&
+ echo PROPS-END
+ } >props &&
+ {
+ cat <<-EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ EOF
+ echo Prop-content-length: $(wc -c <props) &&
+ echo Content-length: $(wc -c <props) &&
+ echo &&
+ cat props &&
+ cat <<-\EOF
+
+ Node-path: empty-file
+ Node-kind: file
+ Node-action: add
+ Content-length: 0
+
+ EOF
+ } >emptyfile.dump &&
+ test-svn-fe emptyfile.dump >stream &&
+ git fast-import <stream &&
+ git log --format=%an HEAD >actual.author &&
+ git log --date=short --format=%ad HEAD >actual.date &&
+ git ls-tree -r --name-only HEAD >actual.files &&
+ test_cmp expect.author actual.author &&
+ test_cmp expect.date actual.date &&
+ test_cmp expect.files actual.files &&
+ git checkout HEAD empty-file &&
+ test_cmp empty file
+'
+
+test_expect_success 'directory with files' '
+ reinit_git &&
+ printf "%s\n" directory/file1 directory/file2 >expect.files &&
+ echo hi >hi &&
+ echo hello >hello &&
+ {
+ properties \
+ svn:author author@example.com \
+ svn:date "1999-02-01T00:01:002.000000Z" \
+ svn:log "add directory with some files in it" &&
+ echo PROPS-END
+ } >props &&
+ {
+ cat <<-EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ EOF
+ echo Prop-content-length: $(wc -c <props) &&
+ echo Content-length: $(wc -c <props) &&
+ echo &&
+ cat props &&
+ cat <<-\EOF &&
+
+ Node-path: directory
+ Node-kind: dir
+ Node-action: add
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: directory/file1
+ Node-kind: file
+ Node-action: add
+ EOF
+ text_no_props hello &&
+ cat <<-\EOF &&
+ Node-path: directory/file2
+ Node-kind: file
+ Node-action: add
+ EOF
+ text_no_props hi
+ } >directory.dump &&
+ test-svn-fe directory.dump >stream &&
+ git fast-import <stream &&
+
+ git ls-tree -r --name-only HEAD >actual.files &&
+ git checkout HEAD directory &&
+ test_cmp expect.files actual.files &&
+ test_cmp hello directory/file1 &&
+ test_cmp hi directory/file2
+'
+
+test_expect_success 'node without action' '
+ cat >inaction.dump <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: directory
+ Node-kind: dir
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+ EOF
+ test_must_fail test-svn-fe inaction.dump
+'
+
+test_expect_success 'action: add node without text' '
+ cat >textless.dump <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: textless
+ Node-kind: file
+ Node-action: add
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+ EOF
+ test_must_fail test-svn-fe textless.dump
+'
+
+test_expect_failure 'change file mode but keep old content' '
+ reinit_git &&
+ cat >expect <<-\EOF &&
+ OBJID
+ :120000 100644 OBJID OBJID T greeting
+ OBJID
+ :100644 120000 OBJID OBJID T greeting
+ OBJID
+ :000000 100644 OBJID OBJID A greeting
+ EOF
+ echo "link hello" >expect.blob &&
+ echo hello >hello &&
+ cat >filemode.dump <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: add
+ Prop-content-length: 10
+ Text-content-length: 11
+ Content-length: 21
+
+ PROPS-END
+ link hello
+
+ Revision-number: 2
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: change
+ Prop-content-length: 33
+ Content-length: 33
+
+ K 11
+ svn:special
+ V 1
+ *
+ PROPS-END
+
+ Revision-number: 3
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: change
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+ EOF
+ test-svn-fe filemode.dump >stream &&
+ git fast-import <stream &&
+ {
+ git rev-list HEAD |
+ git diff-tree --root --stdin |
+ sed "s/$_x40/OBJID/g"
+ } >actual &&
+ git show HEAD:greeting >actual.blob &&
+ git show HEAD^:greeting >actual.target &&
+ test_cmp expect actual &&
+ test_cmp expect.blob actual.blob &&
+ test_cmp hello actual.target
+'
+
+test_expect_success 'NUL in property value' '
+ reinit_git &&
+ echo "commit message" >expect.message &&
+ {
+ properties \
+ unimportant "something with a NUL (Q)" \
+ svn:log "commit message"&&
+ echo PROPS-END
+ } |
+ q_to_nul >props &&
+ {
+ cat <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ EOF
+ echo Prop-content-length: $(wc -c <props) &&
+ echo Content-length: $(wc -c <props) &&
+ echo &&
+ cat props
+ } >nulprop.dump &&
+ test-svn-fe nulprop.dump >stream &&
+ git fast-import <stream &&
+ git diff-tree --always -s --format=%s HEAD >actual.message &&
+ test_cmp expect.message actual.message
+'
+
+test_expect_success 'NUL in log message, file content, and property name' '
+ # Caveat: svnadmin 1.6.16 (r1073529) truncates at \0 in the
+ # svn:specialQnotreally example.
+ reinit_git &&
+ cat >expect <<-\EOF &&
+ OBJID
+ :100644 100644 OBJID OBJID M greeting
+ OBJID
+ :000000 100644 OBJID OBJID A greeting
+ EOF
+ printf "\n%s\n" "something with an ASCII NUL (Q)" >expect.message &&
+ printf "%s\n" "helQo" >expect.hello1 &&
+ printf "%s\n" "link hello" >expect.hello2 &&
+ {
+ properties svn:log "something with an ASCII NUL (Q)" &&
+ echo PROPS-END
+ } |
+ q_to_nul >props &&
+ {
+ q_to_nul <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: add
+ Prop-content-length: 10
+ Text-content-length: 6
+ Content-length: 16
+
+ PROPS-END
+ helQo
+
+ Revision-number: 2
+ EOF
+ echo Prop-content-length: $(wc -c <props) &&
+ echo Content-length: $(wc -c <props) &&
+ echo &&
+ cat props &&
+ q_to_nul <<-\EOF
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: change
+ Prop-content-length: 43
+ Text-content-length: 11
+ Content-length: 54
+
+ K 21
+ svn:specialQnotreally
+ V 1
+ *
+ PROPS-END
+ link hello
+ EOF
+ } >8bitclean.dump &&
+ test-svn-fe 8bitclean.dump >stream &&
+ git fast-import <stream &&
+ {
+ git rev-list HEAD |
+ git diff-tree --root --stdin |
+ sed "s/$_x40/OBJID/g"
+ } >actual &&
+ {
+ git cat-file commit HEAD | nul_to_q &&
+ echo
+ } |
+ sed -ne "/^\$/,\$ p" >actual.message &&
+ git cat-file blob HEAD^:greeting | nul_to_q >actual.hello1 &&
+ git cat-file blob HEAD:greeting | nul_to_q >actual.hello2 &&
+ test_cmp expect actual &&
+ test_cmp expect.message actual.message &&
+ test_cmp expect.hello1 actual.hello1 &&
+ test_cmp expect.hello2 actual.hello2
+'
+
+test_expect_success 'change file mode and reiterate content' '
+ reinit_git &&
+ cat >expect <<-\EOF &&
+ OBJID
+ :120000 100644 OBJID OBJID T greeting
+ OBJID
+ :100644 120000 OBJID OBJID T greeting
+ OBJID
+ :000000 100644 OBJID OBJID A greeting
+ EOF
+ echo "link hello" >expect.blob &&
+ echo hello >hello &&
+ cat >filemode.dump <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: add
+ Prop-content-length: 10
+ Text-content-length: 11
+ Content-length: 21
+
+ PROPS-END
+ link hello
+
+ Revision-number: 2
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: change
+ Prop-content-length: 33
+ Text-content-length: 11
+ Content-length: 44
+
+ K 11
+ svn:special
+ V 1
+ *
+ PROPS-END
+ link hello
+
+ Revision-number: 3
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: change
+ Prop-content-length: 10
+ Text-content-length: 11
+ Content-length: 21
+
+ PROPS-END
+ link hello
+ EOF
+ test-svn-fe filemode.dump >stream &&
+ git fast-import <stream &&
+ {
+ git rev-list HEAD |
+ git diff-tree --root --stdin |
+ sed "s/$_x40/OBJID/g"
+ } >actual &&
+ git show HEAD:greeting >actual.blob &&
+ git show HEAD^:greeting >actual.target &&
+ test_cmp expect actual &&
+ test_cmp expect.blob actual.blob &&
+ test_cmp hello actual.target
+'
+
+test_expect_success 'deltas not supported' '
+ {
+ # (old) h + (inline) ello + (old) \n
+ printf "SVNQ%b%b%s" "Q\003\006\005\004" "\001Q\0204\001\002" "ello" |
+ q_to_nul
+ } >delta &&
+ {
+ properties \
+ svn:author author@example.com \
+ svn:date "1999-01-05T00:01:002.000000Z" \
+ svn:log "add greeting" &&
+ echo PROPS-END
+ } >props &&
+ {
+ properties \
+ svn:author author@example.com \
+ svn:date "1999-01-06T00:01:002.000000Z" \
+ svn:log "change it" &&
+ echo PROPS-END
+ } >props2 &&
+ {
+ echo SVN-fs-dump-format-version: 3 &&
+ echo &&
+ echo Revision-number: 1 &&
+ echo Prop-content-length: $(wc -c <props) &&
+ echo Content-length: $(wc -c <props) &&
+ echo &&
+ cat props &&
+ cat <<-\EOF &&
+
+ Node-path: hello
+ Node-kind: file
+ Node-action: add
+ Prop-content-length: 10
+ Text-content-length: 3
+ Content-length: 13
+
+ PROPS-END
+ hi
+
+ EOF
+ echo Revision-number: 2 &&
+ echo Prop-content-length: $(wc -c <props2) &&
+ echo Content-length: $(wc -c <props2) &&
+ echo &&
+ cat props2 &&
+ cat <<-\EOF &&
+
+ Node-path: hello
+ Node-kind: file
+ Node-action: change
+ Text-delta: true
+ Prop-content-length: 10
+ EOF
+ echo Text-content-length: $(wc -c <delta) &&
+ echo Content-length: $((10 + $(wc -c <delta))) &&
+ echo &&
+ echo PROPS-END &&
+ cat delta
+ } >delta.dump &&
+ test_must_fail test-svn-fe delta.dump
+'
+
+test_expect_success 'property deltas supported' '
+ reinit_git &&
+ cat >expect <<-\EOF &&
+ OBJID
+ :100755 100644 OBJID OBJID M script.sh
+ EOF
+ {
+ properties \
+ svn:author author@example.com \
+ svn:date "1999-03-06T00:01:002.000000Z" \
+ svn:log "make an executable, or chmod -x it" &&
+ echo PROPS-END
+ } >revprops &&
+ {
+ echo SVN-fs-dump-format-version: 3 &&
+ echo &&
+ echo Revision-number: 1 &&
+ echo Prop-content-length: $(wc -c <revprops) &&
+ echo Content-length: $(wc -c <revprops) &&
+ echo &&
+ cat revprops &&
+ echo &&
+ cat <<-\EOF &&
+ Node-path: script.sh
+ Node-kind: file
+ Node-action: add
+ Text-content-length: 0
+ Prop-content-length: 39
+ Content-length: 39
+
+ K 14
+ svn:executable
+ V 4
+ true
+ PROPS-END
+
+ EOF
+ echo Revision-number: 2 &&
+ echo Prop-content-length: $(wc -c <revprops) &&
+ echo Content-length: $(wc -c <revprops) &&
+ echo &&
+ cat revprops &&
+ echo &&
+ cat <<-\EOF
+ Node-path: script.sh
+ Node-kind: file
+ Node-action: change
+ Prop-delta: true
+ Prop-content-length: 30
+ Content-length: 30
+
+ D 14
+ svn:executable
+ PROPS-END
+ EOF
+ } >propdelta.dump &&
+ test-svn-fe propdelta.dump >stream &&
+ git fast-import <stream &&
+ {
+ git rev-list HEAD |
+ git diff-tree --stdin |
+ sed "s/$_x40/OBJID/g"
+ } >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'properties on /' '
+ reinit_git &&
+ cat <<-\EOF >expect &&
+ OBJID
+ OBJID
+ :000000 100644 OBJID OBJID A greeting
+ EOF
+ sed -e "s/X$//" <<-\EOF >changeroot.dump &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: greeting
+ Node-kind: file
+ Node-action: add
+ Text-content-length: 0
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Revision-number: 2
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: X
+ Node-kind: dir
+ Node-action: change
+ Prop-delta: true
+ Prop-content-length: 43
+ Content-length: 43
+
+ K 10
+ svn:ignore
+ V 11
+ build-area
+
+ PROPS-END
+ EOF
+ test-svn-fe changeroot.dump >stream &&
+ git fast-import <stream &&
+ {
+ git rev-list HEAD |
+ git diff-tree --root --always --stdin |
+ sed "s/$_x40/OBJID/g"
+ } >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'deltas for typechange' '
+ reinit_git &&
+ cat >expect <<-\EOF &&
+ OBJID
+ :120000 100644 OBJID OBJID T test-file
+ OBJID
+ :100755 120000 OBJID OBJID T test-file
+ OBJID
+ :000000 100755 OBJID OBJID A test-file
+ EOF
+ cat >deleteprop.dump <<-\EOF &&
+ SVN-fs-dump-format-version: 3
+
+ Revision-number: 1
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: test-file
+ Node-kind: file
+ Node-action: add
+ Prop-delta: true
+ Prop-content-length: 35
+ Text-content-length: 17
+ Content-length: 52
+
+ K 14
+ svn:executable
+ V 0
+
+ PROPS-END
+ link testing 123
+
+ Revision-number: 2
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: test-file
+ Node-kind: file
+ Node-action: change
+ Prop-delta: true
+ Prop-content-length: 53
+ Text-content-length: 17
+ Content-length: 70
+
+ K 11
+ svn:special
+ V 1
+ *
+ D 14
+ svn:executable
+ PROPS-END
+ link testing 231
+
+ Revision-number: 3
+ Prop-content-length: 10
+ Content-length: 10
+
+ PROPS-END
+
+ Node-path: test-file
+ Node-kind: file
+ Node-action: change
+ Prop-delta: true
+ Prop-content-length: 27
+ Text-content-length: 17
+ Content-length: 44
+
+ D 11
+ svn:special
+ PROPS-END
+ link testing 321
+ EOF
+ test-svn-fe deleteprop.dump >stream &&
+ git fast-import <stream &&
+ {
+ git rev-list HEAD |
+ git diff-tree --root --stdin |
+ sed "s/$_x40/OBJID/g"
+ } >actual &&
+ test_cmp expect actual
+'
+
+
test_expect_success 'set up svn repo' '
svnconf=$PWD/svnconf &&
mkdir -p "$svnconf" &&
diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh
index 5d477e4bda..cf4c05261b 100755
--- a/t/t9116-git-svn-log.sh
+++ b/t/t9116-git-svn-log.sh
@@ -60,6 +60,21 @@ test_expect_success 'test ascending revision range' "
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 svn log --show-commit -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 (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 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
+ "
+
printf 'r4 \nr2 \nr1 \n' > expected-range-r4-r2-r1
test_expect_success 'test descending revision range' "
diff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh
index ec0a106614..b324c491c5 100755
--- a/t/t9130-git-svn-authors-file.sh
+++ b/t/t9130-git-svn-authors-file.sh
@@ -96,7 +96,6 @@ test_expect_success 'fresh clone with svn.authors-file in config' '
rm -r "$GIT_DIR" &&
test x = x"$(git config svn.authorsfile)" &&
test_config="$HOME"/.gitconfig &&
- unset GIT_CONFIG_NOGLOBAL &&
unset GIT_DIR &&
unset GIT_CONFIG &&
git config --global \
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 222d1059ef..6b1ba6c858 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -42,6 +42,14 @@ echo "$@"'
>empty
+test_expect_success 'setup: have pipes?' '
+ rm -f frob &&
+ if mkfifo frob
+ then
+ test_set_prereq PIPE
+ fi
+'
+
###
### series A
###
@@ -898,6 +906,77 @@ test_expect_success \
git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
compare_diff_raw expect actual'
+test_expect_success PIPE 'N: read and copy directory' '
+ cat >expect <<-\EOF
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
+ :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
+ EOF
+ git update-ref -d refs/heads/N4 &&
+ rm -f backflow &&
+ mkfifo backflow &&
+ (
+ exec <backflow &&
+ cat <<-EOF &&
+ commit refs/heads/N4
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ copy by tree hash, part 2
+ COMMIT
+
+ from refs/heads/branch^0
+ ls "file2"
+ EOF
+ read mode type tree filename &&
+ echo "M 040000 $tree file3"
+ ) |
+ git fast-import --cat-blob-fd=3 3>backflow &&
+ git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
+ compare_diff_raw expect actual
+'
+
+test_expect_success PIPE 'N: empty directory reads as missing' '
+ cat <<-\EOF >expect &&
+ OBJNAME
+ :000000 100644 OBJNAME OBJNAME A unrelated
+ EOF
+ echo "missing src" >expect.response &&
+ git update-ref -d refs/heads/read-empty &&
+ rm -f backflow &&
+ mkfifo backflow &&
+ (
+ exec <backflow &&
+ cat <<-EOF &&
+ commit refs/heads/read-empty
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ read "empty" (missing) directory
+ COMMIT
+
+ M 100644 inline src/greeting
+ data <<BLOB
+ hello
+ BLOB
+ C src/greeting dst1/non-greeting
+ C src/greeting unrelated
+ # leave behind "empty" src directory
+ D src/greeting
+ ls "src"
+ EOF
+ read -r line &&
+ printf "%s\n" "$line" >response &&
+ cat <<-\EOF
+ D dst1
+ D dst2
+ EOF
+ ) |
+ git fast-import --cat-blob-fd=3 3>backflow &&
+ test_cmp expect.response response &&
+ git rev-list read-empty |
+ git diff-tree -r --root --stdin |
+ sed "s/$_x40/OBJNAME/g" >actual &&
+ test_cmp expect actual
+'
+
test_expect_success \
'N: copy root directory by tree hash' \
'cat >expect <<-\EOF &&
@@ -920,6 +999,48 @@ test_expect_success \
compare_diff_raw expect actual'
test_expect_success \
+ 'N: delete directory by copying' \
+ 'cat >expect <<-\EOF &&
+ OBJID
+ :100644 000000 OBJID OBJID D foo/bar/qux
+ OBJID
+ :000000 100644 OBJID OBJID A foo/bar/baz
+ :000000 100644 OBJID OBJID A foo/bar/qux
+ EOF
+ empty_tree=$(git mktree </dev/null) &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/N-delete
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ collect data to be deleted
+ COMMIT
+
+ deleteall
+ M 100644 inline foo/bar/baz
+ data <<DATA_END
+ hello
+ DATA_END
+ C "foo/bar/baz" "foo/bar/qux"
+ C "foo/bar/baz" "foo/bar/quux/1"
+ C "foo/bar/baz" "foo/bar/quuux"
+ M 040000 $empty_tree foo/bar/quux
+ M 040000 $empty_tree foo/bar/quuux
+
+ commit refs/heads/N-delete
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ delete subdirectory
+ COMMIT
+
+ M 040000 $empty_tree foo/bar/qux
+ INPUT_END
+ git fast-import <input &&
+ git rev-list N-delete |
+ git diff-tree -r --stdin --root --always |
+ sed -e "s/$_x40/OBJID/g" >actual &&
+ test_cmp expect actual'
+
+test_expect_success \
'N: modify copied tree' \
'cat >expect <<-\EOF &&
:100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
@@ -1706,6 +1827,61 @@ test_expect_success \
'cat input | git fast-import --export-marks=other.marks &&
grep :1 other.marks'
+test_expect_success 'R: catch typo in marks file name' '
+ test_must_fail git fast-import --import-marks=nonexistent.marks </dev/null &&
+ echo "feature import-marks=nonexistent.marks" |
+ test_must_fail git fast-import
+'
+
+test_expect_success 'R: import and output marks can be the same file' '
+ rm -f io.marks &&
+ blob=$(echo hi | git hash-object --stdin) &&
+ cat >expect <<-EOF &&
+ :1 $blob
+ :2 $blob
+ EOF
+ git fast-import --export-marks=io.marks <<-\EOF &&
+ blob
+ mark :1
+ data 3
+ hi
+
+ EOF
+ git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF &&
+ blob
+ mark :2
+ data 3
+ hi
+
+ EOF
+ test_cmp expect io.marks
+'
+
+test_expect_success 'R: --import-marks=foo --output-marks=foo to create foo fails' '
+ rm -f io.marks &&
+ test_must_fail git fast-import --import-marks=io.marks --export-marks=io.marks <<-\EOF
+ blob
+ mark :1
+ data 3
+ hi
+
+ EOF
+'
+
+test_expect_success 'R: --import-marks-if-exists' '
+ rm -f io.marks &&
+ blob=$(echo hi | git hash-object --stdin) &&
+ echo ":1 $blob" >expect &&
+ git fast-import --import-marks-if-exists=io.marks --export-marks=io.marks <<-\EOF &&
+ blob
+ mark :1
+ data 3
+ hi
+
+ EOF
+ test_cmp expect io.marks
+'
+
cat >input << EOF
feature import-marks=marks.out
feature export-marks=marks.new
@@ -1764,6 +1940,11 @@ test_expect_success 'R: feature no-relative-marks should be honoured' '
test_cmp marks.new non-relative.out
'
+test_expect_success 'R: feature ls supported' '
+ echo "feature ls" |
+ git fast-import
+'
+
test_expect_success 'R: feature cat-blob supported' '
echo "feature cat-blob" |
git fast-import
@@ -1889,14 +2070,6 @@ test_expect_success 'R: print two blobs to stdout' '
test_cmp expect actual
'
-test_expect_success 'setup: have pipes?' '
- rm -f frob &&
- if mkfifo frob
- then
- test_set_prereq PIPE
- fi
-'
-
test_expect_success PIPE 'R: copy using cat-file' '
expect_id=$(git hash-object big) &&
expect_len=$(wc -c <big) &&
diff --git a/t/t9301-fast-import-notes.sh b/t/t9301-fast-import-notes.sh
index 7cf8cd8a2f..463254c727 100755
--- a/t/t9301-fast-import-notes.sh
+++ b/t/t9301-fast-import-notes.sh
@@ -120,6 +120,7 @@ test_expect_success 'add notes with simple M command' '
test_tick
cat >input <<INPUT_END
+feature notes
commit refs/notes/test
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
data <<COMMIT
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 21cd286bb7..afac5b56a8 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -18,42 +18,34 @@ or warnings to log.'
test_expect_success \
'no commits: projects_list (implicit)' \
'gitweb_run'
-test_debug 'cat gitweb.log'
test_expect_success \
'no commits: projects_index' \
'gitweb_run "a=project_index"'
-test_debug 'cat gitweb.log'
test_expect_success \
'no commits: .git summary (implicit)' \
'gitweb_run "p=.git"'
-test_debug 'cat gitweb.log'
test_expect_success \
'no commits: .git commit (implicit HEAD)' \
'gitweb_run "p=.git;a=commit"'
-test_debug 'cat gitweb.log'
test_expect_success \
'no commits: .git commitdiff (implicit HEAD)' \
'gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'no commits: .git tree (implicit HEAD)' \
'gitweb_run "p=.git;a=tree"'
-test_debug 'cat gitweb.log'
test_expect_success \
'no commits: .git heads' \
'gitweb_run "p=.git;a=heads"'
-test_debug 'cat gitweb.log'
test_expect_success \
'no commits: .git tags' \
'gitweb_run "p=.git;a=tags"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
@@ -69,52 +61,42 @@ test_expect_success \
test_expect_success \
'projects_list (implicit)' \
'gitweb_run'
-test_debug 'cat gitweb.log'
test_expect_success \
'projects_index' \
'gitweb_run "a=project_index"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git summary (implicit)' \
'gitweb_run "p=.git"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git commit (implicit HEAD)' \
'gitweb_run "p=.git;a=commit"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git commitdiff (implicit HEAD, root commit)' \
'gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git commitdiff_plain (implicit HEAD, root commit)' \
'gitweb_run "p=.git;a=commitdiff_plain"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git commit (HEAD)' \
'gitweb_run "p=.git;a=commit;h=HEAD"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git tree (implicit HEAD)' \
'gitweb_run "p=.git;a=tree"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git blob (file)' \
'gitweb_run "p=.git;a=blob;f=file"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git blob_plain (file)' \
'gitweb_run "p=.git;a=blob_plain;f=file"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# nonexistent objects
@@ -122,37 +104,30 @@ test_debug 'cat gitweb.log'
test_expect_success \
'.git commit (non-existent)' \
'gitweb_run "p=.git;a=commit;h=non-existent"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git commitdiff (non-existent)' \
'gitweb_run "p=.git;a=commitdiff;h=non-existent"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git commitdiff (non-existent vs HEAD)' \
'gitweb_run "p=.git;a=commitdiff;hp=non-existent;h=HEAD"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git tree (0000000000000000000000000000000000000000)' \
'gitweb_run "p=.git;a=tree;h=0000000000000000000000000000000000000000"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git tag (0000000000000000000000000000000000000000)' \
'gitweb_run "p=.git;a=tag;h=0000000000000000000000000000000000000000"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git blob (non-existent)' \
'gitweb_run "p=.git;a=blob;f=non-existent"'
-test_debug 'cat gitweb.log'
test_expect_success \
'.git blob_plain (non-existent)' \
'gitweb_run "p=.git;a=blob_plain;f=non-existent"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
@@ -161,7 +136,6 @@ test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): root' \
'gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): file added' \
@@ -169,21 +143,18 @@ test_expect_success \
git add new_file &&
git commit -a -m "File added." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): mode change' \
'test_chmod +x new_file &&
git commit -a -m "Mode changed." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): file renamed' \
'git mv new_file renamed_file &&
git commit -a -m "File renamed." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success SYMLINKS \
'commitdiff(0): file to symlink' \
@@ -191,7 +162,6 @@ test_expect_success SYMLINKS \
ln -s file renamed_file &&
git commit -a -m "File to symlink." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): file deleted' \
@@ -199,7 +169,6 @@ test_expect_success \
rm -f renamed_file &&
git commit -a -m "File removed." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): file copied / new file' \
@@ -207,7 +176,6 @@ test_expect_success \
git add file2 &&
git commit -a -m "File copied." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): mode change and modified' \
@@ -215,7 +183,6 @@ test_expect_success \
test_chmod +x file2 &&
git commit -a -m "Mode change and modification." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): renamed and modified' \
@@ -233,7 +200,6 @@ EOF
echo "Propter nomen suum." >> file3 &&
git commit -a -m "File rename and modification." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): renamed, mode change and modified' \
@@ -242,7 +208,6 @@ test_expect_success \
test_chmod +x file2 &&
git commit -a -m "File rename, mode change and modification." &&
gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# commitdiff testing (taken from t4114-apply-typechange.sh)
@@ -279,42 +244,34 @@ test_expect_success SYMLINKS 'setup typechange commits' '
test_expect_success \
'commitdiff(2): file renamed from foo to foo/baz' \
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-baz-renamed-from-foo"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(2): file renamed from foo/baz to foo' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-baz-renamed-from-foo;h=initial"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(2): directory becomes file' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=initial"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(2): file becomes directory' \
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-becomes-a-directory"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(2): file becomes symlink' \
'gitweb_run "p=.git;a=commitdiff;hp=initial;h=foo-symlinked-to-bar"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(2): symlink becomes file' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-back-to-file"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(2): symlink becomes directory' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-symlinked-to-bar;h=foo-becomes-a-directory"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(2): directory becomes symlink' \
'gitweb_run "p=.git;a=commitdiff;hp=foo-becomes-a-directory;h=foo-symlinked-to-bar"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# commit, commitdiff: merge, large
@@ -330,12 +287,10 @@ test_expect_success \
test_expect_success \
'commit(0): merge commit' \
'gitweb_run "p=.git;a=commit"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(0): merge commit' \
'gitweb_run "p=.git;a=commitdiff"'
-test_debug 'cat gitweb.log'
test_expect_success \
'Prepare large commit' \
@@ -371,12 +326,10 @@ test_expect_success \
test_expect_success \
'commit(1): large commit' \
'gitweb_run "p=.git;a=commit;h=b"'
-test_debug 'cat gitweb.log'
test_expect_success \
'commitdiff(1): large commit' \
'gitweb_run "p=.git;a=commitdiff;h=b"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# tags testing
@@ -394,17 +347,14 @@ test_expect_success \
git tag lightweight/tag-tree HEAD^{tree} &&
git tag lightweight/tag-blob HEAD:file &&
gitweb_run "p=.git;a=tags"'
-test_debug 'cat gitweb.log'
test_expect_success \
'tag: Tag to commit object' \
'gitweb_run "p=.git;a=tag;h=tag-commit"'
-test_debug 'cat gitweb.log'
test_expect_success \
'tag: on lightweight tag (invalid)' \
'gitweb_run "p=.git;a=tag;h=lightweight/tag-commit"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# logs
@@ -412,22 +362,18 @@ test_debug 'cat gitweb.log'
test_expect_success \
'logs: log (implicit HEAD)' \
'gitweb_run "p=.git;a=log"'
-test_debug 'cat gitweb.log'
test_expect_success \
'logs: shortlog (implicit HEAD)' \
'gitweb_run "p=.git;a=shortlog"'
-test_debug 'cat gitweb.log'
test_expect_success \
'logs: history (implicit HEAD, file)' \
'gitweb_run "p=.git;a=history;f=file"'
-test_debug 'cat gitweb.log'
test_expect_success \
'logs: history (implicit HEAD, non-existent file)' \
'gitweb_run "p=.git;a=history;f=non-existent"'
-test_debug 'cat gitweb.log'
test_expect_success \
'logs: history (implicit HEAD, deleted file)' \
@@ -438,55 +384,45 @@ test_expect_success \
git rm deleted_file &&
git commit -m "Delete file" &&
gitweb_run "p=.git;a=history;f=deleted_file"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# path_info links
test_expect_success \
'path_info: project' \
'gitweb_run "" "/.git"'
-test_debug 'cat gitweb.log'
test_expect_success \
'path_info: project/branch' \
'gitweb_run "" "/.git/b"'
-test_debug 'cat gitweb.log'
test_expect_success \
'path_info: project/branch:file' \
'gitweb_run "" "/.git/master:file"'
-test_debug 'cat gitweb.log'
test_expect_success \
'path_info: project/branch:dir/' \
'gitweb_run "" "/.git/master:foo/"'
-test_debug 'cat gitweb.log'
test_expect_success \
'path_info: project/branch:file (non-existent)' \
'gitweb_run "" "/.git/master:non-existent"'
-test_debug 'cat gitweb.log'
test_expect_success \
'path_info: project/branch:dir/ (non-existent)' \
'gitweb_run "" "/.git/master:non-existent/"'
-test_debug 'cat gitweb.log'
test_expect_success \
'path_info: project/branch:/file' \
'gitweb_run "" "/.git/master:/file"'
-test_debug 'cat gitweb.log'
test_expect_success \
'path_info: project/:/file (implicit HEAD)' \
'gitweb_run "" "/.git/:/file"'
-test_debug 'cat gitweb.log'
test_expect_success \
'path_info: project/:/ (implicit HEAD, top tree)' \
'gitweb_run "" "/.git/:/"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
@@ -495,17 +431,14 @@ test_debug 'cat gitweb.log'
test_expect_success \
'feeds: OPML' \
'gitweb_run "a=opml"'
-test_debug 'cat gitweb.log'
test_expect_success \
'feed: RSS' \
'gitweb_run "p=.git;a=rss"'
-test_debug 'cat gitweb.log'
test_expect_success \
'feed: Atom' \
'gitweb_run "p=.git;a=atom"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# encoding/decoding
@@ -513,27 +446,28 @@ test_debug 'cat gitweb.log'
test_expect_success \
'encode(commit): utf8' \
'. "$TEST_DIRECTORY"/t3901-utf8.txt &&
+ test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
+ test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
echo "UTF-8" >> file &&
git add file &&
git commit -F "$TEST_DIRECTORY"/t3900/1-UTF-8.txt &&
gitweb_run "p=.git;a=commit"'
-test_debug 'cat gitweb.log'
test_expect_success \
'encode(commit): iso-8859-1' \
'. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
+ test_when_finished "GIT_AUTHOR_NAME=\"A U Thor\"" &&
+ test_when_finished "GIT_COMMITTER_NAME=\"C O Mitter\"" &&
echo "ISO-8859-1" >> file &&
git add file &&
git config i18n.commitencoding ISO-8859-1 &&
+ test_when_finished "git config --unset i18n.commitencoding" &&
git commit -F "$TEST_DIRECTORY"/t3900/ISO8859-1.txt &&
- git config --unset i18n.commitencoding &&
gitweb_run "p=.git;a=commit"'
-test_debug 'cat gitweb.log'
test_expect_success \
'encode(log): utf-8 and iso-8859-1' \
'gitweb_run "p=.git;a=log"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# extra options
@@ -541,27 +475,22 @@ test_debug 'cat gitweb.log'
test_expect_success \
'opt: log --no-merges' \
'gitweb_run "p=.git;a=log;opt=--no-merges"'
-test_debug 'cat gitweb.log'
test_expect_success \
'opt: atom --no-merges' \
'gitweb_run "p=.git;a=log;opt=--no-merges"'
-test_debug 'cat gitweb.log'
test_expect_success \
'opt: "file" history --no-merges' \
'gitweb_run "p=.git;a=history;f=file;opt=--no-merges"'
-test_debug 'cat gitweb.log'
test_expect_success \
'opt: log --no-such-option (invalid option)' \
'gitweb_run "p=.git;a=log;opt=--no-such-option"'
-test_debug 'cat gitweb.log'
test_expect_success \
'opt: tree --no-merges (invalid option for action)' \
'gitweb_run "p=.git;a=tree;opt=--no-merges"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# testing config_to_multi / cloneurl
@@ -569,14 +498,12 @@ test_debug 'cat gitweb.log'
test_expect_success \
'URL: no project URLs, no base URL' \
'gitweb_run "p=.git;a=summary"'
-test_debug 'cat gitweb.log'
test_expect_success \
'URL: project URLs via gitweb.url' \
'git config --add gitweb.url git://example.com/git/trash.git &&
git config --add gitweb.url http://example.com/git/trash.git &&
gitweb_run "p=.git;a=summary"'
-test_debug 'cat gitweb.log'
cat >.git/cloneurl <<\EOF
git://example.com/git/trash.git
@@ -586,7 +513,6 @@ EOF
test_expect_success \
'URL: project URLs via cloneurl file' \
'gitweb_run "p=.git;a=summary"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# gitweb config and repo config
@@ -604,12 +530,10 @@ EOF
test_expect_success \
'config override: projects list (implicit)' \
'gitweb_run'
-test_debug 'cat gitweb.log'
test_expect_success \
'config override: tree view, features not overridden in repo config' \
'gitweb_run "p=.git;a=tree"'
-test_debug 'cat gitweb.log'
test_expect_success \
'config override: tree view, features disabled in repo config' \
@@ -617,14 +541,12 @@ test_expect_success \
git config gitweb.snapshot none &&
git config gitweb.avatar gravatar &&
gitweb_run "p=.git;a=tree"'
-test_debug 'cat gitweb.log'
test_expect_success \
'config override: tree view, features enabled in repo config (1)' \
'git config gitweb.blame yes &&
git config gitweb.snapshot "zip,tgz, tbz2" &&
gitweb_run "p=.git;a=tree"'
-test_debug 'cat gitweb.log'
cat >.git/config <<\EOF
# testing noval and alternate separator
@@ -635,7 +557,6 @@ EOF
test_expect_success \
'config override: tree view, features enabled in repo config (2)' \
'gitweb_run "p=.git;a=tree"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# non-ASCII in README.html
@@ -645,7 +566,6 @@ test_expect_success \
'echo "<b>UTF-8 example:</b><br />" > .git/README.html &&
cat "$TEST_DIRECTORY"/t3900/1-UTF-8.txt >> .git/README.html &&
gitweb_run "p=.git;a=summary"'
-test_debug 'cat gitweb.log'
# ----------------------------------------------------------------------
# syntax highlighting
@@ -666,7 +586,6 @@ test_expect_success HIGHLIGHT \
'syntax highlighting (no highlight, unknown syntax)' \
'git config gitweb.highlight yes &&
gitweb_run "p=.git;a=blob;f=file"'
-test_debug 'cat gitweb.log'
test_expect_success HIGHLIGHT \
'syntax highlighting (highlighted, shell script)' \
@@ -675,6 +594,5 @@ test_expect_success HIGHLIGHT \
git add test.sh &&
git commit -m "Add test.sh" &&
gitweb_run "p=.git;a=blob;f=test.sh"'
-test_debug 'cat gitweb.log'
test_done
diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh
index 18825aff89..26102ee9b0 100755
--- a/t/t9501-gitweb-standalone-http-status.sh
+++ b/t/t9501-gitweb-standalone-http-status.sh
@@ -126,7 +126,6 @@ test_expect_success 'load checking: load too high (default action)' '
grep "Status: 503 Service Unavailable" gitweb.headers &&
grep "503 - The load average on the server is too high" gitweb.body
'
-test_debug 'cat gitweb.log' # just in case
test_debug 'cat gitweb.headers'
# turn off load checking
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index c15ca2d647..13ba96e21a 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -113,6 +113,16 @@ like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash');
my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.');
isnt($last_commit, $dir_commit, 'log . does not show last commit');
+# commands outside working tree
+chdir($abs_repo_dir . '/..');
+my $r3 = Git->repository(Directory => $abs_repo_dir);
+my $tmpfile3 = "$abs_repo_dir/file3.tmp";
+open TEMPFILE3, "+>$tmpfile3" or die "Can't open $tmpfile3: $!";
+is($r3->cat_blob($file1hash, \*TEMPFILE3), 15, "cat_blob(outside): size");
+close TEMPFILE3;
+unlink $tmpfile3;
+chdir($abs_repo_dir);
+
printf "1..%d\n", Test::More->builder->current_test;
my $is_passing = eval { Test::More->is_passing };
diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh
new file mode 100755
index 0000000000..a523473954
--- /dev/null
+++ b/t/t9800-git-p4.sh
@@ -0,0 +1,139 @@
+#!/bin/sh
+
+test_description='git-p4 tests'
+
+. ./test-lib.sh
+
+( p4 -h && p4d -h ) >/dev/null 2>&1 || {
+ skip_all='skipping git-p4 tests; no p4 or p4d'
+ test_done
+}
+
+GITP4=$GIT_BUILD_DIR/contrib/fast-import/git-p4
+P4DPORT=10669
+
+db="$TRASH_DIRECTORY/db"
+cli="$TRASH_DIRECTORY/cli"
+git="$TRASH_DIRECTORY/git"
+
+test_debug 'echo p4d -q -d -r "$db" -p $P4DPORT'
+test_expect_success setup '
+ mkdir -p "$db" &&
+ p4d -q -d -r "$db" -p $P4DPORT &&
+ mkdir -p "$cli" &&
+ mkdir -p "$git" &&
+ export P4PORT=localhost:$P4DPORT
+'
+
+test_expect_success 'add p4 files' '
+ cd "$cli" &&
+ p4 client -i <<-EOF &&
+ Client: client
+ Description: client
+ Root: $cli
+ View: //depot/... //client/...
+ EOF
+ export P4CLIENT=client &&
+ echo file1 >file1 &&
+ p4 add file1 &&
+ p4 submit -d "file1" &&
+ echo file2 >file2 &&
+ p4 add file2 &&
+ p4 submit -d "file2" &&
+ cd "$TRASH_DIRECTORY"
+'
+
+test_expect_success 'basic git-p4 clone' '
+ "$GITP4" clone --dest="$git" //depot &&
+ cd "$git" &&
+ git log --oneline >lines &&
+ test_line_count = 1 lines &&
+ cd .. &&
+ rm -rf "$git" && mkdir "$git"
+'
+
+test_expect_success 'git-p4 clone @all' '
+ "$GITP4" clone --dest="$git" //depot@all &&
+ cd "$git" &&
+ git log --oneline >lines &&
+ test_line_count = 2 lines &&
+ cd .. &&
+ rm -rf "$git" && mkdir "$git"
+'
+
+test_expect_success 'git-p4 sync uninitialized repo' '
+ test_create_repo "$git" &&
+ cd "$git" &&
+ test_must_fail "$GITP4" sync &&
+ rm -rf "$git" && mkdir "$git"
+'
+
+#
+# Create a git repo by hand. Add a commit so that HEAD is valid.
+# Test imports a new p4 repository into a new git branch.
+#
+test_expect_success 'git-p4 sync new branch' '
+ test_create_repo "$git" &&
+ cd "$git" &&
+ test_commit head &&
+ "$GITP4" sync --branch=refs/remotes/p4/depot //depot@all &&
+ git log --oneline p4/depot >lines &&
+ cat lines &&
+ test_line_count = 2 lines &&
+ cd .. &&
+ rm -rf "$git" && mkdir "$git"
+'
+
+test_expect_success 'exit when p4 fails to produce marshaled output' '
+ badp4dir="$TRASH_DIRECTORY/badp4dir" &&
+ mkdir -p "$badp4dir" &&
+ cat >"$badp4dir"/p4 <<-EOF &&
+ #!$SHELL_PATH
+ exit 1
+ EOF
+ chmod 755 "$badp4dir"/p4 &&
+ PATH="$badp4dir:$PATH" "$GITP4" clone --dest="$git" //depot >errs 2>&1 ; retval=$? &&
+ test $retval -eq 1 &&
+ test_must_fail grep -q Traceback errs
+'
+
+test_expect_success 'add p4 files with wildcards in the names' '
+ cd "$cli" &&
+ echo file-wild-hash >file-wild#hash &&
+ echo file-wild-star >file-wild\*star &&
+ echo file-wild-at >file-wild@at &&
+ echo file-wild-percent >file-wild%percent &&
+ p4 add -f file-wild* &&
+ p4 submit -d "file wildcards" &&
+ cd "$TRASH_DIRECTORY"
+'
+
+test_expect_success 'wildcard files git-p4 clone' '
+ "$GITP4" clone --dest="$git" //depot &&
+ cd "$git" &&
+ test -f file-wild#hash &&
+ test -f file-wild\*star &&
+ test -f file-wild@at &&
+ test -f file-wild%percent &&
+ cd "$TRASH_DIRECTORY" &&
+ rm -rf "$git" && mkdir "$git"
+'
+
+test_expect_success 'clone bare' '
+ "$GITP4" clone --dest="$git" --bare //depot &&
+ cd "$git" &&
+ test ! -d .git &&
+ bare=`git config --get core.bare` &&
+ test "$bare" = true &&
+ cd "$TRASH_DIRECTORY" &&
+ rm -rf "$git" && mkdir "$git"
+'
+
+test_expect_success 'shutdown' '
+ pid=`pgrep -f p4d` &&
+ test -n "$pid" &&
+ test_debug "ps wl `echo $pid`" &&
+ kill $pid
+'
+
+test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 42f2f14496..8a274fbe79 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -43,33 +43,25 @@ TERM=dumb
export LANG LC_ALL PAGER TERM TZ
EDITOR=:
unset VISUAL
-unset GIT_EDITOR
-unset AUTHOR_DATE
-unset AUTHOR_EMAIL
-unset AUTHOR_NAME
-unset COMMIT_AUTHOR_EMAIL
-unset COMMIT_AUTHOR_NAME
unset EMAIL
-unset GIT_ALTERNATE_OBJECT_DIRECTORIES
-unset GIT_AUTHOR_DATE
+unset $(perl -e '
+ my @env = keys %ENV;
+ my $ok = join("|", qw(
+ TRACE
+ DEBUG
+ USE_LOOKUP
+ TEST
+ .*_TEST
+ PROVE
+ VALGRIND
+ ));
+ my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
+ print join("\n", @vars);
+')
GIT_AUTHOR_EMAIL=author@example.com
GIT_AUTHOR_NAME='A U Thor'
-unset GIT_COMMITTER_DATE
GIT_COMMITTER_EMAIL=committer@example.com
GIT_COMMITTER_NAME='C O Mitter'
-unset GIT_DIFF_OPTS
-unset GIT_DIR
-unset GIT_WORK_TREE
-unset GIT_EXTERNAL_DIFF
-unset GIT_INDEX_FILE
-unset GIT_OBJECT_DIRECTORY
-unset GIT_CEILING_DIRECTORIES
-unset SHA1_FILE_DIRECTORIES
-unset SHA1_FILE_DIRECTORY
-unset GIT_NOTES_REF
-unset GIT_NOTES_DISPLAY_REF
-unset GIT_NOTES_REWRITE_REF
-unset GIT_NOTES_REWRITE_MODE
GIT_MERGE_VERBOSITY=5
export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
@@ -97,6 +89,9 @@ esac
_x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
_x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05"
+# Zero SHA-1
+_z40=0000000000000000000000000000000000000000
+
# Each test should start with something like this, after copyright notices:
#
# test_description='Description of this test...
@@ -951,8 +946,8 @@ fi
GIT_TEMPLATE_DIR="$GIT_BUILD_DIR"/templates/blt
unset GIT_CONFIG
GIT_CONFIG_NOSYSTEM=1
-GIT_CONFIG_NOGLOBAL=1
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_CONFIG_NOGLOBAL
+GIT_ATTR_NOSYSTEM=1
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG_NOSYSTEM GIT_ATTR_NOSYSTEM
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
@@ -1001,14 +996,14 @@ rm -fr "$test" || {
exit 1
}
+HOME="$TRASH_DIRECTORY"
+export HOME
+
test_create_repo "$test"
# Use -P to resolve symlinks in our working directory so that the cwd
# in subprocesses like git equals our $PWD (for pathname comparisons).
cd -P "$test" || exit 1
-HOME=$(pwd)
-export HOME
-
this_test=${0##*/}
this_test=${this_test%%-*}
for skp in $GIT_SKIP_TESTS
@@ -1076,6 +1071,15 @@ esac
test -z "$NO_PERL" && test_set_prereq PERL
test -z "$NO_PYTHON" && test_set_prereq PYTHON
+# Can we rely on git's output in the C locale?
+if test -n "$GETTEXT_POISON"
+then
+ GIT_GETTEXT_POISON=YesPlease
+ export GIT_GETTEXT_POISON
+else
+ test_set_prereq C_LOCALE_OUTPUT
+fi
+
# test whether the filesystem supports symbolic links
ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
rm -f y
diff --git a/t/valgrind/default.supp b/t/valgrind/default.supp
index 9e013fa3b2..0a6724fcc4 100644
--- a/t/valgrind/default.supp
+++ b/t/valgrind/default.supp
@@ -43,3 +43,9 @@
fun:write_buffer
fun:write_loose_object
}
+
+{
+ ignore-sse-strlen-invalid-read-size
+ Memcheck:Addr4
+ fun:copy_ref
+}