summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/README7
-rw-r--r--t/lib-rebase.sh2
-rwxr-xr-xt/t0003-attributes.sh10
-rwxr-xr-xt/t0080-vcs-svn.sh171
-rwxr-xr-xt/t1001-read-tree-m-2way.sh2
-rwxr-xr-xt/t1011-read-tree-sparse-checkout.sh123
-rwxr-xr-xt/t1501-worktree.sh483
-rwxr-xr-xt/t1503-rev-parse-verify.sh11
-rwxr-xr-xt/t1506-rev-parse-diagnosis.sh9
-rwxr-xr-xt/t2018-checkout-branch.sh172
-rwxr-xr-xt/t3030-merge-recursive.sh2
-rwxr-xr-xt/t3301-notes.sh6
-rwxr-xr-xt/t3302-notes-index-expensive.sh2
-rwxr-xr-xt/t3306-notes-prune.sh8
-rwxr-xr-xt/t3400-rebase.sh205
-rwxr-xr-xt/t3402-rebase-merge.sh9
-rwxr-xr-xt/t3404-rebase-interactive.sh68
-rwxr-xr-xt/t3407-rebase-abort.sh6
-rwxr-xr-xt/t3410-rebase-preserve-dropped-merges.sh8
-rwxr-xr-xt/t3415-rebase-autosquash.sh40
-rwxr-xr-xt/t3505-cherry-pick-empty.sh20
-rwxr-xr-xt/t3507-cherry-pick-conflict.sh20
-rwxr-xr-xt/t3508-cherry-pick-many-commits.sh64
-rwxr-xr-xt/t3509-cherry-pick-merge-df.sh35
-rwxr-xr-xt/t3903-stash.sh112
-rwxr-xr-xt/t4013-diff-various.sh5
-rw-r--r--t/t4013/diff.log_-S_F_master7
-rwxr-xr-xt/t4018-diff-funcname.sh2
-rwxr-xr-xt/t4027-diff-submodule.sh160
-rwxr-xr-xt/t4111-apply-subdir.sh142
-rwxr-xr-xt/t4120-apply-popt.sh35
-rwxr-xr-xt/t4135-apply-weird-filenames.sh75
-rw-r--r--t/t4135/.gitignore3
-rw-r--r--t/t4135/add-plain.diff5
-rw-r--r--t/t4135/add-with backslash.diff5
-rw-r--r--t/t4135/add-with quote.diff5
-rw-r--r--t/t4135/add-with spaces.diff5
-rw-r--r--t/t4135/add-with tab.diff5
-rw-r--r--t/t4135/damaged.diff5
-rw-r--r--t/t4135/diff-plain.diff5
-rw-r--r--t/t4135/diff-with backslash.diff5
-rw-r--r--t/t4135/diff-with quote.diff5
-rw-r--r--t/t4135/diff-with spaces.diff5
-rw-r--r--t/t4135/diff-with tab.diff5
-rw-r--r--t/t4135/git-plain.diff7
-rw-r--r--t/t4135/git-with backslash.diff7
-rw-r--r--t/t4135/git-with quote.diff7
-rw-r--r--t/t4135/git-with spaces.diff7
-rw-r--r--t/t4135/git-with tab.diff7
-rwxr-xr-xt/t4135/make-patches45
-rwxr-xr-xt/t4150-am.sh334
-rwxr-xr-xt/t4200-rerere.sh400
-rwxr-xr-xt/t4202-log.sh33
-rwxr-xr-xt/t5001-archive-attr.sh2
-rwxr-xr-xt/t5520-pull.sh62
-rwxr-xr-xt/t5525-fetch-tagopt.sh41
-rwxr-xr-xt/t5601-clone.sh10
-rwxr-xr-xt/t6010-merge-base.sh340
-rwxr-xr-xt/t6018-rev-list-glob.sh6
-rwxr-xr-xt/t6020-merge-df.sh2
-rwxr-xr-xt/t6031-merge-recursive.sh31
-rwxr-xr-xt/t6035-merge-dir-to-symlink.sh64
-rwxr-xr-xt/t6037-merge-ours-theirs.sh2
-rwxr-xr-xt/t6038-merge-text-auto.sh189
-rwxr-xr-xt/t6050-replace.sh2
-rwxr-xr-xt/t6200-fmt-merge-msg.sh310
-rwxr-xr-xt/t7006-pager.sh66
-rwxr-xr-xt/t7008-grep-binary.sh2
-rwxr-xr-xt/t7300-clean.sh16
-rwxr-xr-xt/t7403-submodule-sync.sh7
-rwxr-xr-xt/t7405-submodule-merge.sh127
-rwxr-xr-xt/t7406-submodule-update.sh2
-rwxr-xr-xt/t7407-submodule-foreach.sh4
-rwxr-xr-xt/t7508-status.sh183
-rwxr-xr-xt/t7509-commit.sh4
-rwxr-xr-xt/t7600-merge.sh391
-rwxr-xr-xt/t7606-merge-custom.sh96
-rwxr-xr-xt/t7607-merge-overwrite.sh12
-rwxr-xr-xt/t7609-merge-co-error-msgs.sh133
-rwxr-xr-xt/t7610-mergetool.sh57
-rwxr-xr-xt/t7810-grep.sh2
-rwxr-xr-xt/t9010-svn-fe.sh32
-rwxr-xr-xt/t9130-git-svn-authors-file.sh4
-rwxr-xr-xt/t9139-git-svn-non-utf8-commitencoding.sh2
-rwxr-xr-xt/t9140-git-svn-reset.sh2
-rwxr-xr-xt/t9155-git-svn-fetch-deleted-tag.sh42
-rwxr-xr-xt/t9156-git-svn-fetch-deleted-tag-2.sh44
-rwxr-xr-xt/t9300-fast-import.sh54
-rwxr-xr-xt/t9350-fast-export.sh38
-rw-r--r--t/test-lib.sh36
90 files changed, 4145 insertions, 1198 deletions
diff --git a/t/README b/t/README
index 118e50d..a1eb7c8 100644
--- a/t/README
+++ b/t/README
@@ -501,6 +501,13 @@ library for your script to use.
<expected> file. This behaves like "cmp" but produces more
helpful output when the test is run with "-v" option.
+ - test_path_is_file <file> [<diagnosis>]
+ test_path_is_dir <dir> [<diagnosis>]
+ test_path_is_missing <path> [<diagnosis>]
+
+ Check whether a file/directory exists or doesn't. <diagnosis> will
+ be displayed if the test fails.
+
- test_when_finished <script>
Prepend <script> to a list of commands to run to clean up
diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
index 6aefe27..6ccf797 100644
--- a/t/lib-rebase.sh
+++ b/t/lib-rebase.sh
@@ -47,6 +47,8 @@ for line in $FAKE_LINES; do
case $line in
squash|fixup|edit|reword)
action="$line";;
+ exec*)
+ echo "$line" | sed 's/_/ /g' >> "$1";;
"#")
echo '# comment' >> "$1";;
">")
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index 53bd7fc..de38c7f 100755
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
@@ -48,11 +48,11 @@ test_expect_success 'attribute test' '
attr_check a/b/g a/b/g &&
attr_check b/g unspecified &&
attr_check a/b/h a/b/h &&
- attr_check a/b/d/g "a/b/d/*"
- attr_check onoff unset
- attr_check offon set
- attr_check no unspecified
- attr_check a/b/d/no "a/b/d/*"
+ attr_check a/b/d/g "a/b/d/*" &&
+ attr_check onoff unset &&
+ attr_check offon set &&
+ attr_check no unspecified &&
+ attr_check a/b/d/no "a/b/d/*" &&
attr_check a/b/d/yes unspecified
'
diff --git a/t/t0080-vcs-svn.sh b/t/t0080-vcs-svn.sh
new file mode 100755
index 0000000..d3225ad
--- /dev/null
+++ b/t/t0080-vcs-svn.sh
@@ -0,0 +1,171 @@
+#!/bin/sh
+
+test_description='check infrastructure for svn importer'
+
+. ./test-lib.sh
+uint32_max=4294967295
+
+test_expect_success 'obj pool: store data' '
+ cat <<-\EOF >expected &&
+ 0
+ 1
+ EOF
+
+ test-obj-pool <<-\EOF >actual &&
+ alloc one 16
+ set one 13
+ test one 13
+ reset one
+ EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'obj pool: NULL is offset ~0' '
+ echo "$uint32_max" >expected &&
+ echo null one | test-obj-pool >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'obj pool: out-of-bounds access' '
+ cat <<-EOF >expected &&
+ 0
+ 0
+ $uint32_max
+ $uint32_max
+ 16
+ 20
+ $uint32_max
+ EOF
+
+ test-obj-pool <<-\EOF >actual &&
+ alloc one 16
+ alloc two 16
+ offset one 20
+ offset two 20
+ alloc one 5
+ offset one 20
+ free one 1
+ offset one 20
+ reset one
+ reset two
+ EOF
+ test_cmp expected actual
+'
+
+test_expect_success 'obj pool: high-water mark' '
+ cat <<-\EOF >expected &&
+ 0
+ 0
+ 10
+ 20
+ 20
+ 20
+ EOF
+
+ test-obj-pool <<-\EOF >actual &&
+ alloc one 10
+ committed one
+ alloc one 10
+ commit one
+ committed one
+ alloc one 10
+ free one 20
+ committed one
+ reset one
+ EOF
+ 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 &&
+ echo equals equals equals >expected.matchmore &&
+
+ test-string-pool "a,--b" >actual.differ &&
+ test-string-pool "a,a" >actual.match &&
+ test-string-pool "equals-equals" >actual.matchmore &&
+ test_must_fail test-string-pool a,a,a &&
+ test_must_fail test-string-pool a &&
+
+ test_cmp expected.differ actual.differ &&
+ test_cmp expected.match actual.match &&
+ test_cmp expected.matchmore actual.matchmore
+'
+
+test_expect_success 'treap sort' '
+ cat <<-\EOF >unsorted &&
+ 68
+ 12
+ 13
+ 13
+ 68
+ 13
+ 13
+ 21
+ 10
+ 11
+ 12
+ 13
+ 13
+ EOF
+ sort unsorted >expected &&
+
+ test-treap <unsorted >actual &&
+ test_cmp expected actual
+'
+
+test_done
diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh
index 0c562bb..93ca84f 100755
--- a/t/t1001-read-tree-m-2way.sh
+++ b/t/t1001-read-tree-m-2way.sh
@@ -359,7 +359,7 @@ test_expect_success \
test_expect_success \
'a/b (untracked) vs a, plus c/d case test.' \
- '! git read-tree -u -m "$treeH" "$treeM" &&
+ 'test_must_fail git read-tree -u -m "$treeH" "$treeM" &&
git ls-files --stage &&
test -f a/b'
diff --git a/t/t1011-read-tree-sparse-checkout.sh b/t/t1011-read-tree-sparse-checkout.sh
index 62246db..9a07de1 100755
--- a/t/t1011-read-tree-sparse-checkout.sh
+++ b/t/t1011-read-tree-sparse-checkout.sh
@@ -1,16 +1,30 @@
#!/bin/sh
-test_description='sparse checkout tests'
+test_description='sparse checkout tests
+
+* (tag: removed, master) removed
+| D sub/added
+* (HEAD, tag: top) modified and added
+| M init.t
+| A sub/added
+* (tag: init) init
+ A init.t
+'
. ./test-lib.sh
-cat >expected <<EOF
-100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
-100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
-EOF
test_expect_success 'setup' '
+ cat >expected <<-\EOF &&
+ 100644 77f0ba1734ed79d12881f81b36ee134de6a3327b 0 init.t
+ 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 sub/added
+ EOF
+ cat >expected.swt <<-\EOF &&
+ H init.t
+ H sub/added
+ EOF
+
test_commit init &&
- echo modified >> init.t &&
+ echo modified >>init.t &&
mkdir sub &&
touch sub/added &&
git add init.t sub/added &&
@@ -20,26 +34,22 @@ test_expect_success 'setup' '
git commit -m removed &&
git tag removed &&
git checkout top &&
- git ls-files --stage > result &&
+ git ls-files --stage >result &&
test_cmp expected result
'
-cat >expected.swt <<EOF
-H init.t
-H sub/added
-EOF
test_expect_success 'read-tree without .git/info/sparse-checkout' '
git read-tree -m -u HEAD &&
- git ls-files --stage > result &&
+ git ls-files --stage >result &&
test_cmp expected result &&
- git ls-files -t > result &&
+ git ls-files -t >result &&
test_cmp expected.swt result
'
test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
- echo > .git/info/sparse-checkout
+ echo >.git/info/sparse-checkout
git read-tree -m -u HEAD &&
- git ls-files -t > result &&
+ git ls-files -t >result &&
test_cmp expected.swt result &&
test -f init.t &&
test -f sub/added
@@ -47,9 +57,9 @@ test_expect_success 'read-tree with .git/info/sparse-checkout but disabled' '
test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-checkout and enabled' '
git config core.sparsecheckout true &&
- echo > .git/info/sparse-checkout &&
+ echo >.git/info/sparse-checkout &&
git read-tree --no-sparse-checkout -m -u HEAD &&
- git ls-files -t > result &&
+ git ls-files -t >result &&
test_cmp expected.swt result &&
test -f init.t &&
test -f sub/added
@@ -57,94 +67,113 @@ test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-
test_expect_success 'read-tree with empty .git/info/sparse-checkout' '
git config core.sparsecheckout true &&
- echo > .git/info/sparse-checkout &&
+ echo >.git/info/sparse-checkout &&
test_must_fail git read-tree -m -u HEAD &&
- git ls-files --stage > result &&
+ git ls-files --stage >result &&
test_cmp expected result &&
- git ls-files -t > result &&
+ git ls-files -t >result &&
test_cmp expected.swt result &&
test -f init.t &&
test -f sub/added
'
-cat >expected.swt <<EOF
-S init.t
-H sub/added
-EOF
test_expect_success 'match directories with trailing slash' '
+ cat >expected.swt-noinit <<-\EOF &&
+ S init.t
+ H sub/added
+ EOF
+
echo sub/ > .git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
git ls-files -t > result &&
- test_cmp expected.swt result &&
+ test_cmp expected.swt-noinit result &&
test ! -f init.t &&
test -f sub/added
'
-cat >expected.swt <<EOF
-H init.t
-H sub/added
-EOF
test_expect_failure 'match directories without trailing slash' '
- echo init.t > .git/info/sparse-checkout &&
- echo sub >> .git/info/sparse-checkout &&
+ echo init.t >.git/info/sparse-checkout &&
+ echo sub >>.git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
- git ls-files -t > result &&
+ git ls-files -t >result &&
test_cmp expected.swt result &&
test ! -f init.t &&
test -f sub/added
'
-cat >expected.swt <<EOF
-H init.t
-S sub/added
-EOF
test_expect_success 'checkout area changes' '
- echo init.t > .git/info/sparse-checkout &&
+ cat >expected.swt-nosub <<-\EOF &&
+ H init.t
+ S sub/added
+ EOF
+
+ echo init.t >.git/info/sparse-checkout &&
git read-tree -m -u HEAD &&
- git ls-files -t > result &&
- test_cmp expected.swt result &&
+ git ls-files -t >result &&
+ test_cmp expected.swt-nosub result &&
test -f init.t &&
test ! -f sub/added
'
test_expect_success 'read-tree updates worktree, absent case' '
- echo sub/added > .git/info/sparse-checkout &&
+ echo sub/added >.git/info/sparse-checkout &&
git checkout -f top &&
git read-tree -m -u HEAD^ &&
test ! -f init.t
'
test_expect_success 'read-tree updates worktree, dirty case' '
- echo sub/added > .git/info/sparse-checkout &&
+ echo sub/added >.git/info/sparse-checkout &&
git checkout -f top &&
- echo dirty > init.t &&
+ echo dirty >init.t &&
git read-tree -m -u HEAD^ &&
grep -q dirty init.t &&
rm init.t
'
test_expect_success 'read-tree removes worktree, dirty case' '
- echo init.t > .git/info/sparse-checkout &&
+ echo init.t >.git/info/sparse-checkout &&
git checkout -f top &&
- echo dirty > added &&
+ echo dirty >added &&
git read-tree -m -u HEAD^ &&
grep -q dirty added
'
test_expect_success 'read-tree adds to worktree, absent case' '
- echo init.t > .git/info/sparse-checkout &&
+ echo init.t >.git/info/sparse-checkout &&
git checkout -f removed &&
git read-tree -u -m HEAD^ &&
test ! -f sub/added
'
test_expect_success 'read-tree adds to worktree, dirty case' '
- echo init.t > .git/info/sparse-checkout &&
+ echo init.t >.git/info/sparse-checkout &&
git checkout -f removed &&
mkdir sub &&
- echo dirty > sub/added &&
+ echo dirty >sub/added &&
git read-tree -u -m HEAD^ &&
grep -q dirty sub/added
'
+test_expect_success 'index removal and worktree narrowing at the same time' '
+ >empty &&
+ echo init.t >.git/info/sparse-checkout &&
+ echo sub/added >>.git/info/sparse-checkout &&
+ git checkout -f top &&
+ echo init.t >.git/info/sparse-checkout &&
+ git checkout removed &&
+ git ls-files sub/added >result &&
+ test ! -f sub/added &&
+ test_cmp empty result
+'
+
+test_expect_success 'read-tree --reset removes outside worktree' '
+ >empty &&
+ echo init.t >.git/info/sparse-checkout &&
+ git checkout -f top &&
+ git reset --hard removed &&
+ git ls-files sub/added >result &&
+ test_cmp empty result
+'
+
test_done
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index bd8b607..2c8f01f 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -3,183 +3,320 @@
test_description='test separate work tree'
. ./test-lib.sh
-test_rev_parse() {
- name=$1
- shift
-
- test_expect_success "$name: is-bare-repository" \
- "test '$1' = \"\$(git rev-parse --is-bare-repository)\""
- shift
- [ $# -eq 0 ] && return
-
- test_expect_success "$name: is-inside-git-dir" \
- "test '$1' = \"\$(git rev-parse --is-inside-git-dir)\""
- shift
- [ $# -eq 0 ] && return
-
- test_expect_success "$name: is-inside-work-tree" \
- "test '$1' = \"\$(git rev-parse --is-inside-work-tree)\""
- shift
- [ $# -eq 0 ] && return
-
- test_expect_success "$name: prefix" \
- "test '$1' = \"\$(git rev-parse --show-prefix)\""
- shift
- [ $# -eq 0 ] && return
-}
-
-EMPTY_TREE=$(git write-tree)
-mkdir -p work/sub/dir || exit 1
-mkdir -p work2 || exit 1
-mv .git repo.git || exit 1
-
-say "core.worktree = relative path"
-GIT_DIR=repo.git
-GIT_CONFIG="$(pwd)"/$GIT_DIR/config
-export GIT_DIR GIT_CONFIG
-unset GIT_WORK_TREE
-git config core.worktree ../work
-test_rev_parse 'outside' false false false
-cd work || exit 1
-GIT_DIR=../repo.git
-GIT_CONFIG="$(pwd)"/$GIT_DIR/config
-test_rev_parse 'inside' false false true ''
-cd sub/dir || exit 1
-GIT_DIR=../../../repo.git
-GIT_CONFIG="$(pwd)"/$GIT_DIR/config
-test_rev_parse 'subdirectory' false false true sub/dir/
-cd ../../.. || exit 1
-
-say "core.worktree = absolute path"
-GIT_DIR=$(pwd)/repo.git
-GIT_CONFIG=$GIT_DIR/config
-git config core.worktree "$(pwd)/work"
-test_rev_parse 'outside' false false false
-cd work2
-test_rev_parse 'outside2' false false false
-cd ../work || exit 1
-test_rev_parse 'inside' false false true ''
-cd sub/dir || exit 1
-test_rev_parse 'subdirectory' false false true sub/dir/
-cd ../../.. || exit 1
-
-say "GIT_WORK_TREE=relative path (override core.worktree)"
-GIT_DIR=$(pwd)/repo.git
-GIT_CONFIG=$GIT_DIR/config
-git config core.worktree non-existent
-GIT_WORK_TREE=work
-export GIT_WORK_TREE
-test_rev_parse 'outside' false false false
-cd work2
-test_rev_parse 'outside' false false false
-cd ../work || exit 1
-GIT_WORK_TREE=.
-test_rev_parse 'inside' false false true ''
-cd sub/dir || exit 1
-GIT_WORK_TREE=../..
-test_rev_parse 'subdirectory' false false true sub/dir/
-cd ../../.. || exit 1
-
-mv work repo.git/work
-mv work2 repo.git/work2
-
-say "GIT_WORK_TREE=absolute path, work tree below git dir"
-GIT_DIR=$(pwd)/repo.git
-GIT_CONFIG=$GIT_DIR/config
-GIT_WORK_TREE=$(pwd)/repo.git/work
-test_rev_parse 'outside' false false false
-cd repo.git || exit 1
-test_rev_parse 'in repo.git' false true false
-cd objects || exit 1
-test_rev_parse 'in repo.git/objects' false true false
-cd ../work2 || exit 1
-test_rev_parse 'in repo.git/work2' false true false
-cd ../work || exit 1
-test_rev_parse 'in repo.git/work' false true true ''
-cd sub/dir || exit 1
-test_rev_parse 'in repo.git/sub/dir' false true true sub/dir/
-cd ../../../.. || exit 1
-
-test_expect_success 'repo finds its work tree' '
- (cd repo.git &&
- : > work/sub/dir/untracked &&
- test sub/dir/untracked = "$(git ls-files --others)")
-'
-
-test_expect_success 'repo finds its work tree from work tree, too' '
- (cd repo.git/work/sub/dir &&
- : > tracked &&
- git --git-dir=../../.. add tracked &&
- cd ../../.. &&
- test sub/dir/tracked = "$(git ls-files)")
+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/") &&
+
+ mkdir -p work/sub/dir &&
+ mkdir -p work2 &&
+ mv .git repo.git
+'
+
+test_expect_success 'setup: helper for testing rev-parse' '
+ test_rev_parse() {
+ echo $1 >expected.bare &&
+ echo $2 >expected.inside-git &&
+ echo $3 >expected.inside-worktree &&
+ if test $# -ge 4
+ then
+ echo $4 >expected.prefix
+ fi &&
+
+ git rev-parse --is-bare-repository >actual.bare &&
+ git rev-parse --is-inside-git-dir >actual.inside-git &&
+ git rev-parse --is-inside-work-tree >actual.inside-worktree &&
+ if test $# -ge 4
+ then
+ git rev-parse --show-prefix >actual.prefix
+ fi &&
+
+ test_cmp expected.bare actual.bare &&
+ test_cmp expected.inside-git actual.inside-git &&
+ test_cmp expected.inside-worktree actual.inside-worktree &&
+ if test $# -ge 4
+ then
+ # rev-parse --show-prefix should output
+ # a single newline when at the top of the work tree,
+ # but we test for that separately.
+ test -z "$4" && ! test -s actual.prefix ||
+ test_cmp expected.prefix actual.prefix
+ fi
+ }
+'
+
+test_expect_success 'setup: core.worktree = relative path' '
+ unset GIT_WORK_TREE;
+ GIT_DIR=repo.git &&
+ GIT_CONFIG="$(pwd)"/$GIT_DIR/config &&
+ export GIT_DIR GIT_CONFIG &&
+ git config core.worktree ../work
+'
+
+test_expect_success 'outside' '
+ test_rev_parse false false false
+'
+
+test_expect_success 'inside work tree' '
+ (
+ cd work &&
+ GIT_DIR=../repo.git &&
+ GIT_CONFIG="$(pwd)"/$GIT_DIR/config &&
+ test_rev_parse false false true ""
+ )
+'
+
+test_expect_failure 'empty prefix is actually written out' '
+ echo >expected &&
+ (
+ cd work &&
+ GIT_DIR=../repo.git &&
+ GIT_CONFIG="$(pwd)"/$GIT_DIR/config &&
+ git rev-parse --show-prefix >../actual
+ ) &&
+ test_cmp expected actual
+'
+
+test_expect_success 'subdir of work tree' '
+ (
+ cd work/sub/dir &&
+ GIT_DIR=../../../repo.git &&
+ GIT_CONFIG="$(pwd)"/$GIT_DIR/config &&
+ test_rev_parse false false true sub/dir/
+ )
+'
+
+test_expect_success 'setup: core.worktree = absolute path' '
+ unset GIT_WORK_TREE;
+ GIT_DIR=$(pwd)/repo.git &&
+ GIT_CONFIG=$GIT_DIR/config &&
+ export GIT_DIR GIT_CONFIG &&
+ git config core.worktree "$(pwd)/work"
+'
+
+test_expect_success 'outside' '
+ test_rev_parse false false false &&
+ (
+ cd work2 &&
+ test_rev_parse false false false
+ )
+'
+
+test_expect_success 'inside work tree' '
+ (
+ cd work &&
+ test_rev_parse false false true ""
+ )
+'
+
+test_expect_success 'subdir of work tree' '
+ (
+ cd work/sub/dir &&
+ test_rev_parse false false true sub/dir/
+ )
+'
+
+test_expect_success 'setup: GIT_WORK_TREE=relative (override core.worktree)' '
+ GIT_DIR=$(pwd)/repo.git &&
+ GIT_CONFIG=$GIT_DIR/config &&
+ git config core.worktree non-existent &&
+ GIT_WORK_TREE=work &&
+ export GIT_DIR GIT_CONFIG GIT_WORK_TREE
+'
+
+test_expect_success 'outside' '
+ test_rev_parse false false false &&
+ (
+ cd work2 &&
+ test_rev_parse false false false
+ )
+'
+
+test_expect_success 'inside work tree' '
+ (
+ cd work &&
+ GIT_WORK_TREE=. &&
+ test_rev_parse false false true ""
+ )
+'
+
+test_expect_success 'subdir of work tree' '
+ (
+ cd work/sub/dir &&
+ GIT_WORK_TREE=../.. &&
+ test_rev_parse false false true sub/dir/
+ )
+'
+
+test_expect_success 'setup: GIT_WORK_TREE=absolute, below git dir' '
+ mv work repo.git/work &&
+ mv work2 repo.git/work2 &&
+ GIT_DIR=$(pwd)/repo.git &&
+ GIT_CONFIG=$GIT_DIR/config &&
+ GIT_WORK_TREE=$(pwd)/repo.git/work &&
+ export GIT_DIR GIT_CONFIG GIT_WORK_TREE
+'
+
+test_expect_success 'outside' '
+ echo outside &&
+ test_rev_parse false false false
+'
+
+test_expect_success 'in repo.git' '
+ (
+ cd repo.git &&
+ test_rev_parse false true false
+ ) &&
+ (
+ cd repo.git/objects &&
+ test_rev_parse false true false
+ ) &&
+ (
+ cd repo.git/work2 &&
+ test_rev_parse false true false
+ )
+'
+
+test_expect_success 'inside work tree' '
+ (
+ cd repo.git/work &&
+ test_rev_parse false true true ""
+ )
+'
+
+test_expect_success 'subdir of work tree' '
+ (
+ cd repo.git/work/sub/dir &&
+ test_rev_parse false true true sub/dir/
+ )
+'
+
+test_expect_success 'find work tree from repo' '
+ echo sub/dir/untracked >expected &&
+ cat <<-\EOF >repo.git/work/.gitignore &&
+ expected.*
+ actual.*
+ .gitignore
+ EOF
+ >repo.git/work/sub/dir/untracked &&
+ (
+ cd repo.git &&
+ git ls-files --others --exclude-standard >../actual
+ ) &&
+ test_cmp expected actual
+'
+
+test_expect_success 'find work tree from work tree' '
+ echo sub/dir/tracked >expected &&
+ >repo.git/work/sub/dir/tracked &&
+ (
+ cd repo.git/work/sub/dir &&
+ git --git-dir=../../.. add tracked
+ ) &&
+ (
+ cd repo.git &&
+ git ls-files >../actual
+ ) &&
+ test_cmp expected actual
'
test_expect_success '_gently() groks relative GIT_DIR & GIT_WORK_TREE' '
- (cd repo.git/work/sub/dir &&
- GIT_DIR=../../.. GIT_WORK_TREE=../.. GIT_PAGER= \
+ (
+ cd repo.git/work/sub/dir &&
+ GIT_DIR=../../.. &&
+ GIT_WORK_TREE=../.. &&
+ GIT_PAGER= &&
+ export GIT_DIR GIT_WORK_TREE GIT_PAGER &&
+
git diff --exit-code tracked &&
- echo changed > tracked &&
- ! GIT_DIR=../../.. GIT_WORK_TREE=../.. GIT_PAGER= \
- git diff --exit-code tracked)
-'
-cat > diff-index-cached.expected <<\EOF
-:000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A sub/dir/tracked
-EOF
-cat > diff-index.expected <<\EOF
-:000000 100644 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 A sub/dir/tracked
-EOF
-
-
-test_expect_success 'git diff-index' '
- GIT_DIR=repo.git GIT_WORK_TREE=repo.git/work git diff-index $EMPTY_TREE > result &&
- test_cmp diff-index.expected result &&
- GIT_DIR=repo.git git diff-index --cached $EMPTY_TREE > result &&
- test_cmp diff-index-cached.expected result
-'
-cat >diff-files.expected <<\EOF
-:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M sub/dir/tracked
-EOF
-
-test_expect_success 'git diff-files' '
- GIT_DIR=repo.git GIT_WORK_TREE=repo.git/work git diff-files > result &&
- test_cmp diff-files.expected result
-'
-
-cat >diff-TREE.expected <<\EOF
-diff --git a/sub/dir/tracked b/sub/dir/tracked
-new file mode 100644
-index 0000000..5ea2ed4
---- /dev/null
-+++ b/sub/dir/tracked
-@@ -0,0 +1 @@
-+changed
-EOF
-cat >diff-TREE-cached.expected <<\EOF
-diff --git a/sub/dir/tracked b/sub/dir/tracked
-new file mode 100644
-index 0000000..e69de29
-EOF
-cat >diff-FILES.expected <<\EOF
-diff --git a/sub/dir/tracked b/sub/dir/tracked
-index e69de29..5ea2ed4 100644
---- a/sub/dir/tracked
-+++ b/sub/dir/tracked
-@@ -0,0 +1 @@
-+changed
-EOF
-
-test_expect_success 'git diff' '
- GIT_DIR=repo.git GIT_WORK_TREE=repo.git/work git diff $EMPTY_TREE > result &&
- test_cmp diff-TREE.expected result &&
- GIT_DIR=repo.git git diff --cached $EMPTY_TREE > result &&
- test_cmp diff-TREE-cached.expected result &&
- GIT_DIR=repo.git GIT_WORK_TREE=repo.git/work git diff > result &&
- test_cmp diff-FILES.expected result
+ echo changed >tracked &&
+ test_must_fail git diff --exit-code tracked
+ )
+'
+
+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
+ EOF
+ cat >diff-index.expected <<-EOF &&
+ :000000 100644 $ZEROES $ZEROES A sub/dir/tracked
+ EOF
+
+ (
+ GIT_DIR=repo.git &&
+ GIT_WORK_TREE=repo.git/work &&
+ export GIT_DIR GIT_WORK_TREE &&
+ git diff-index $EMPTY_TREE >diff-index.actual &&
+ git diff-index --cached $EMPTY_TREE >diff-index-cached.actual
+ ) &&
+ test_cmp diff-index.expected diff-index.actual &&
+ test_cmp diff-index-cached.expected diff-index-cached.actual
+'
+
+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
+ EOF
+
+ (
+ GIT_DIR=repo.git &&
+ GIT_WORK_TREE=repo.git/work &&
+ export GIT_DIR GIT_WORK_TREE &&
+ git diff-files >diff-files.actual
+ ) &&
+ test_cmp diff-files.expected diff-files.actual
+'
+
+test_expect_success 'git diff respects work tree under .git dir' '
+ cat >diff-TREE.expected <<-EOF &&
+ diff --git a/sub/dir/tracked b/sub/dir/tracked
+ new file mode 100644
+ index 0000000..$CHANGED_BLOB7
+ --- /dev/null
+ +++ b/sub/dir/tracked
+ @@ -0,0 +1 @@
+ +changed
+ EOF
+ cat >diff-TREE-cached.expected <<-EOF &&
+ diff --git a/sub/dir/tracked b/sub/dir/tracked
+ new file mode 100644
+ index 0000000..$EMPTY_BLOB7
+ EOF
+ cat >diff-FILES.expected <<-EOF &&
+ diff --git a/sub/dir/tracked b/sub/dir/tracked
+ index $EMPTY_BLOB7..$CHANGED_BLOB7 100644
+ --- a/sub/dir/tracked
+ +++ b/sub/dir/tracked
+ @@ -0,0 +1 @@
+ +changed
+ EOF
+
+ (
+ GIT_DIR=repo.git &&
+ GIT_WORK_TREE=repo.git/work &&
+ export GIT_DIR GIT_WORK_TREE &&
+ git diff $EMPTY_TREE >diff-TREE.actual &&
+ git diff --cached $EMPTY_TREE >diff-TREE-cached.actual &&
+ git diff >diff-FILES.actual
+ ) &&
+ test_cmp diff-TREE.expected diff-TREE.actual &&
+ test_cmp diff-TREE-cached.expected diff-TREE-cached.actual &&
+ test_cmp diff-FILES.expected diff-FILES.actual
'
test_expect_success 'git grep' '
- (cd repo.git/work/sub &&
- GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep dir/tracked)
+ echo dir/tracked >expected.grep &&
+ (
+ cd repo.git/work/sub &&
+ GIT_DIR=../.. &&
+ GIT_WORK_TREE=.. &&
+ export GIT_DIR GIT_WORK_TREE &&
+ git grep -l changed >../../../actual.grep
+ ) &&
+ test_cmp expected.grep actual.grep
'
test_expect_success 'git commit' '
@@ -191,14 +328,14 @@ test_expect_success 'git commit' '
test_expect_success 'absolute pathspec should fail gracefully' '
(
- cd repo.git || exit 1
- git config --unset core.worktree
+ cd repo.git &&
+ test_might_fail git config --unset core.worktree &&
test_must_fail git log HEAD -- /home
)
'
test_expect_success 'make_relative_path handles double slashes in GIT_DIR' '
- : > dummy_file
+ >dummy_file
echo git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file &&
git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file
'
diff --git a/t/t1503-rev-parse-verify.sh b/t/t1503-rev-parse-verify.sh
index cc65394..100f857 100755
--- a/t/t1503-rev-parse-verify.sh
+++ b/t/t1503-rev-parse-verify.sh
@@ -104,4 +104,15 @@ test_expect_success 'use --default' '
test_must_fail git rev-parse --verify --default bar
'
+test_expect_success 'master@{n} for various n' '
+ N=$(git reflog | wc -l) &&
+ Nm1=$((N-1)) &&
+ Np1=$((N+1)) &&
+ git rev-parse --verify master@{0} &&
+ git rev-parse --verify master@{1} &&
+ git rev-parse --verify master@{$Nm1} &&
+ test_must_fail git rev-parse --verify master@{$N} &&
+ test_must_fail git rev-parse --verify master@{$Np1}
+'
+
test_done
diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh
index af721f9..0eeeb0e 100755
--- a/t/t1506-rev-parse-diagnosis.sh
+++ b/t/t1506-rev-parse-diagnosis.sh
@@ -66,4 +66,13 @@ test_expect_success 'incorrect file in :path and :N:path' '
grep "fatal: Path '"'"'disk-only.txt'"'"' exists on disk, but not in the index." error
'
+test_expect_success 'invalid @{n} reference' '
+ test_must_fail git rev-parse master@{99999} >output 2>error &&
+ test -z "$(cat output)" &&
+ grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error &&
+ test_must_fail git rev-parse --verify master@{99999} >output 2>error &&
+ test -z "$(cat output)" &&
+ grep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error
+'
+
test_done
diff --git a/t/t2018-checkout-branch.sh b/t/t2018-checkout-branch.sh
new file mode 100755
index 0000000..fa69016
--- /dev/null
+++ b/t/t2018-checkout-branch.sh
@@ -0,0 +1,172 @@
+#!/bin/sh
+
+test_description='checkout '
+
+. ./test-lib.sh
+
+# Arguments: <branch> <sha> [<checkout options>]
+#
+# Runs "git checkout" to switch to <branch>, testing that
+#
+# 1) we are on the specified branch, <branch>;
+# 2) HEAD is <sha>; if <sha> is not specified, the old HEAD is used.
+#
+# If <checkout options> is not specified, "git checkout" is run with -b.
+do_checkout() {
+ exp_branch=$1 &&
+ exp_ref="refs/heads/$exp_branch" &&
+
+ # if <sha> is not specified, use HEAD.
+ exp_sha=${2:-$(git rev-parse --verify HEAD)} &&
+
+ # default options for git checkout: -b
+ if [ -z "$3" ]; then
+ opts="-b"
+ else
+ opts="$3"
+ fi
+
+ git checkout $opts $exp_branch $exp_sha &&
+
+ test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) &&
+ test $exp_sha = $(git rev-parse --verify HEAD)
+}
+
+test_dirty_unmergeable() {
+ ! git diff --exit-code >/dev/null
+}
+
+setup_dirty_unmergeable() {
+ echo >>file1 change2
+}
+
+test_dirty_mergeable() {
+ ! git diff --cached --exit-code >/dev/null
+}
+
+setup_dirty_mergeable() {
+ echo >file2 file2 &&
+ git add file2
+}
+
+test_expect_success 'setup' '
+ test_commit initial file1 &&
+ HEAD1=$(git rev-parse --verify HEAD) &&
+
+ test_commit change1 file1 &&
+ HEAD2=$(git rev-parse --verify HEAD) &&
+
+ git branch -m branch1
+'
+
+test_expect_success 'checkout -b to a new branch, set to HEAD' '
+ do_checkout branch2
+'
+
+test_expect_success 'checkout -b to a new branch, set to an explicit ref' '
+ git checkout branch1 &&
+ git branch -D branch2 &&
+
+ do_checkout branch2 $HEAD1
+'
+
+test_expect_success 'checkout -b to a new branch with unmergeable changes fails' '
+ git checkout branch1 &&
+
+ # clean up from previous test
+ git branch -D branch2 &&
+
+ setup_dirty_unmergeable &&
+ test_must_fail do_checkout branch2 $HEAD1 &&
+ test_dirty_unmergeable
+'
+
+test_expect_success 'checkout -f -b to a new branch with unmergeable changes discards changes' '
+ # still dirty and on branch1
+ do_checkout branch2 $HEAD1 "-f -b" &&
+ test_must_fail test_dirty_unmergeable
+'
+
+test_expect_success 'checkout -b to a new branch preserves mergeable changes' '
+ git checkout branch1 &&
+
+ # clean up from previous test
+ git branch -D branch2 &&
+
+ setup_dirty_mergeable &&
+ do_checkout branch2 $HEAD1 &&
+ test_dirty_mergeable
+'
+
+test_expect_success 'checkout -f -b to a new branch with mergeable changes discards changes' '
+ # clean up from previous test
+ git reset --hard &&
+
+ git checkout branch1 &&
+
+ # clean up from previous test
+ git branch -D branch2 &&
+
+ setup_dirty_mergeable &&
+ do_checkout branch2 $HEAD1 "-f -b" &&
+ test_must_fail test_dirty_mergeable
+'
+
+test_expect_success 'checkout -b to an existing branch fails' '
+ git reset --hard HEAD &&
+
+ test_must_fail do_checkout branch2 $HEAD2
+'
+
+test_expect_success 'checkout -B to an existing branch resets branch to HEAD' '
+ git checkout branch1 &&
+
+ do_checkout branch2 "" -B
+'
+
+test_expect_success 'checkout -B to an existing branch from detached HEAD resets branch to HEAD' '
+ git checkout $(git rev-parse --verify HEAD) &&
+
+ do_checkout branch2 "" -B
+'
+
+test_expect_success 'checkout -B to an existing branch with an explicit ref resets branch to that ref' '
+ git checkout branch1 &&
+
+ do_checkout branch2 $HEAD1 -B
+'
+
+test_expect_success 'checkout -B to an existing branch with unmergeable changes fails' '
+ git checkout branch1 &&
+
+ setup_dirty_unmergeable &&
+ test_must_fail do_checkout branch2 $HEAD1 -B &&
+ test_dirty_unmergeable
+'
+
+test_expect_success 'checkout -f -B to an existing branch with unmergeable changes discards changes' '
+ # still dirty and on branch1
+ do_checkout branch2 $HEAD1 "-f -B" &&
+ test_must_fail test_dirty_unmergeable
+'
+
+test_expect_success 'checkout -B to an existing branch preserves mergeable changes' '
+ git checkout branch1 &&
+
+ setup_dirty_mergeable &&
+ do_checkout branch2 $HEAD1 -B &&
+ test_dirty_mergeable
+'
+
+test_expect_success 'checkout -f -B to an existing branch with mergeable changes discards changes' '
+ # clean up from previous test
+ git reset --hard &&
+
+ git checkout branch1 &&
+
+ setup_dirty_mergeable &&
+ do_checkout branch2 $HEAD1 "-f -B" &&
+ test_must_fail test_dirty_mergeable
+'
+
+test_done
diff --git a/t/t3030-merge-recursive.sh b/t/t3030-merge-recursive.sh
index d541544..efe2900 100755
--- a/t/t3030-merge-recursive.sh
+++ b/t/t3030-merge-recursive.sh
@@ -294,7 +294,7 @@ test_expect_success 'fail if the index has unresolved entries' '
grep "You have not concluded your merge" out &&
rm -f .git/MERGE_HEAD &&
test_must_fail git merge "$c5" 2> out &&
- grep "Your local changes to .* would be overwritten by merge." out
+ grep "Your local changes to the following files would be overwritten by merge:" out
'
test_expect_success 'merge-recursive remove conflict' '
diff --git a/t/t3301-notes.sh b/t/t3301-notes.sh
index 1d82f79..96b7581 100755
--- a/t/t3301-notes.sh
+++ b/t/t3301-notes.sh
@@ -299,7 +299,7 @@ cat expect-F >> expect-rm-F
test_expect_success 'verify note removal with -F /dev/null' '
git log -4 > output &&
test_cmp expect-rm-F output &&
- ! git notes show
+ test_must_fail git notes show
'
test_expect_success 'do not create empty note with -m "" (setup)' '
@@ -309,7 +309,7 @@ test_expect_success 'do not create empty note with -m "" (setup)' '
test_expect_success 'verify non-creation of note with -m ""' '
git log -4 > output &&
test_cmp expect-rm-F output &&
- ! git notes show
+ test_must_fail git notes show
'
cat > expect-combine_m_and_F << EOF
@@ -357,7 +357,7 @@ cat expect-multiline >> expect-rm-remove
test_expect_success 'verify note removal with "git notes remove"' '
git log -4 > output &&
test_cmp expect-rm-remove output &&
- ! git notes show HEAD^
+ test_must_fail git notes show HEAD^
'
cat > expect << EOF
diff --git a/t/t3302-notes-index-expensive.sh b/t/t3302-notes-index-expensive.sh
index 7c08e99..e35d781 100755
--- a/t/t3302-notes-index-expensive.sh
+++ b/t/t3302-notes-index-expensive.sh
@@ -96,7 +96,7 @@ time_notes () {
for mode in no-notes notes
do
echo $mode
- /usr/bin/time sh ../time_notes $mode $1
+ /usr/bin/time "$SHELL_PATH" ../time_notes $mode $1
done
}
diff --git a/t/t3306-notes-prune.sh b/t/t3306-notes-prune.sh
index b455404..c428217 100755
--- a/t/t3306-notes-prune.sh
+++ b/t/t3306-notes-prune.sh
@@ -67,7 +67,7 @@ test_expect_success 'remove some commits' '
test_expect_success 'verify that commits are gone' '
- ! git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+ test_must_fail git cat-file -p 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
git cat-file -p 08341ad9e94faa089d60fd3f523affb25c6da189 &&
git cat-file -p ab5f302035f2e7aaf04265f08b42034c23256e1f
'
@@ -106,7 +106,7 @@ test_expect_success 'prune notes' '
test_expect_success 'verify that notes are gone' '
- ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+ test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
'
@@ -130,8 +130,8 @@ test_expect_success 'prune -v notes' '
test_expect_success 'verify that notes are gone' '
- ! git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
- ! git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
+ test_must_fail git notes show 5ee1c35e83ea47cd3cc4f8cbee0568915fbbbd29 &&
+ test_must_fail git notes show 08341ad9e94faa089d60fd3f523affb25c6da189 &&
git notes show ab5f302035f2e7aaf04265f08b42034c23256e1f
'
diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh
index d98c7b5..349eebd 100755
--- a/t/t3400-rebase.sh
+++ b/t/t3400-rebase.sh
@@ -14,140 +14,165 @@ GIT_AUTHOR_NAME=author@name
GIT_AUTHOR_EMAIL=bogus@email@address
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
-test_expect_success \
- 'prepare repository with topic branches' \
- 'git config core.logAllRefUpdates true &&
- echo First > A &&
- git update-index --add A &&
- git commit -m "Add A." &&
- git checkout -b my-topic-branch &&
- echo Second > B &&
- git update-index --add B &&
- git commit -m "Add B." &&
- git checkout -f master &&
- echo Third >> A &&
- git update-index A &&
- git commit -m "Modify A." &&
- git checkout -b side my-topic-branch &&
- echo Side >> C &&
- git add C &&
- git commit -m "Add C" &&
- git checkout -b nonlinear my-topic-branch &&
- echo Edit >> B &&
- git add B &&
- git commit -m "Modify B" &&
- git merge side &&
- git checkout -b upstream-merged-nonlinear &&
- git merge master &&
- git checkout -f my-topic-branch &&
- git tag topic
+test_expect_success 'prepare repository with topic branches' '
+ git config core.logAllRefUpdates true &&
+ echo First >A &&
+ git update-index --add A &&
+ git commit -m "Add A." &&
+ git checkout -b force-3way &&
+ echo Dummy >Y &&
+ git update-index --add Y &&
+ git commit -m "Add Y." &&
+ git checkout -b filemove &&
+ git reset --soft master &&
+ mkdir D &&
+ git mv A D/A &&
+ git commit -m "Move A." &&
+ git checkout -b my-topic-branch master &&
+ echo Second >B &&
+ git update-index --add B &&
+ git commit -m "Add B." &&
+ git checkout -f master &&
+ echo Third >>A &&
+ git update-index A &&
+ git commit -m "Modify A." &&
+ git checkout -b side my-topic-branch &&
+ echo Side >>C &&
+ git add C &&
+ git commit -m "Add C" &&
+ git checkout -b nonlinear my-topic-branch &&
+ echo Edit >>B &&
+ git add B &&
+ git commit -m "Modify B" &&
+ git merge side &&
+ git checkout -b upstream-merged-nonlinear &&
+ git merge master &&
+ git checkout -f my-topic-branch &&
+ git tag topic
'
test_expect_success 'rebase on dirty worktree' '
- echo dirty >> A &&
- test_must_fail git rebase master'
+ echo dirty >>A &&
+ test_must_fail git rebase master
+'
test_expect_success 'rebase on dirty cache' '
- git add A &&
- test_must_fail git rebase master'
+ git add A &&
+ test_must_fail git rebase master
+'
test_expect_success 'rebase against master' '
- git reset --hard HEAD &&
- git rebase master'
+ git reset --hard HEAD &&
+ git rebase master
+'
test_expect_success 'rebase against master twice' '
- git rebase master >out &&
- grep "Current branch my-topic-branch is up to date" out
+ git rebase master >out &&
+ grep "Current branch my-topic-branch is up to date" out
'
test_expect_success 'rebase against master twice with --force' '
- git rebase --force-rebase master >out &&
- grep "Current branch my-topic-branch is up to date, rebase forced" out
+ git rebase --force-rebase master >out &&
+ grep "Current branch my-topic-branch is up to date, rebase forced" out
'
test_expect_success 'rebase against master twice from another branch' '
- git checkout my-topic-branch^ &&
- git rebase master my-topic-branch >out &&
- grep "Current branch my-topic-branch is up to date" out
+ git checkout my-topic-branch^ &&
+ git rebase master my-topic-branch >out &&
+ grep "Current branch my-topic-branch is up to date" out
'
test_expect_success 'rebase fast-forward to master' '
- git checkout my-topic-branch^ &&
- git rebase my-topic-branch >out &&
- grep "Fast-forwarded HEAD to my-topic-branch" out
+ git checkout my-topic-branch^ &&
+ git rebase my-topic-branch >out &&
+ grep "Fast-forwarded HEAD to my-topic-branch" out
'
-test_expect_success \
- 'the rebase operation should not have destroyed author information' \
- '! (git log | grep "Author:" | grep "<>")'
+test_expect_success 'the rebase operation should not have destroyed author information' '
+ ! (git log | grep "Author:" | grep "<>")
+'
-test_expect_success \
- 'the rebase operation should not have destroyed author information (2)' \
- "git log -1 | grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'"
+test_expect_success 'the rebase operation should not have destroyed author information (2)' "
+ git log -1 |
+ grep 'Author: $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'
+"
test_expect_success 'HEAD was detached during rebase' '
- test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})
+ test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})
'
test_expect_success 'rebase after merge master' '
- git reset --hard topic &&
- git merge master &&
- git rebase master &&
- ! (git show | grep "^Merge:")
+ git reset --hard topic &&
+ git merge master &&
+ git rebase master &&
+ ! (git show | grep "^Merge:")
'
test_expect_success 'rebase of history with merges is linearized' '
- git checkout nonlinear &&
- test 4 = $(git rev-list master.. | wc -l) &&
- git rebase master &&
- test 3 = $(git rev-list master.. | wc -l)
+ git checkout nonlinear &&
+ test 4 = $(git rev-list master.. | wc -l) &&
+ git rebase master &&
+ test 3 = $(git rev-list master.. | wc -l)
'
-test_expect_success \
- 'rebase of history with merges after upstream merge is linearized' '
- git checkout upstream-merged-nonlinear &&
- test 5 = $(git rev-list master.. | wc -l) &&
- git rebase master &&
- test 3 = $(git rev-list master.. | wc -l)
+test_expect_success 'rebase of history with merges after upstream merge is linearized' '
+ git checkout upstream-merged-nonlinear &&
+ test 5 = $(git rev-list master.. | wc -l) &&
+ git rebase master &&
+ test 3 = $(git rev-list master.. | wc -l)
'
test_expect_success 'rebase a single mode change' '
- git checkout master &&
- echo 1 > X &&
- git add X &&
- test_tick &&
- git commit -m prepare &&
- git checkout -b modechange HEAD^ &&
- echo 1 > X &&
- git add X &&
- test_chmod +x A &&
- test_tick &&
- git commit -m modechange &&
- GIT_TRACE=1 git rebase master
+ git checkout master &&
+ echo 1 >X &&
+ git add X &&
+ test_tick &&
+ git commit -m prepare &&
+ git checkout -b modechange HEAD^ &&
+ echo 1 >X &&
+ git add X &&
+ test_chmod +x A &&
+ test_tick &&
+ git commit -m modechange &&
+ GIT_TRACE=1 git rebase master
+'
+
+test_expect_success 'rebase is not broken by diff.renames' '
+ git config diff.renames copies &&
+ test_when_finished "git config --unset diff.renames" &&
+ git checkout filemove &&
+ GIT_TRACE=1 git rebase force-3way
+'
+
+test_expect_success 'setup: recover' '
+ test_might_fail git rebase --abort &&
+ git reset --hard &&
+ git checkout modechange
'
test_expect_success 'Show verbose error when HEAD could not be detached' '
- : > B &&
- test_must_fail git rebase topic 2> output.err > output.out &&
- grep "Untracked working tree file .B. would be overwritten" output.err
+ >B &&
+ test_must_fail git rebase topic 2>output.err >output.out &&
+ grep "The following untracked working tree files would be overwritten by checkout:" output.err &&
+ grep B output.err
'
rm -f B
test_expect_success 'dump usage when upstream arg is missing' '
- git checkout -b usage topic &&
- test_must_fail git rebase 2>error1 &&
- grep "[Uu]sage" error1 &&
- test_must_fail git rebase --abort 2>error2 &&
- grep "No rebase in progress" error2 &&
- test_must_fail git rebase --onto master 2>error3 &&
- grep "[Uu]sage" error3 &&
- ! grep "can.t shift" error3
+ git checkout -b usage topic &&
+ test_must_fail git rebase 2>error1 &&
+ grep "[Uu]sage" error1 &&
+ test_must_fail git rebase --abort 2>error2 &&
+ grep "No rebase in progress" error2 &&
+ test_must_fail git rebase --onto master 2>error3 &&
+ grep "[Uu]sage" error3 &&
+ ! grep "can.t shift" error3
'
test_expect_success 'rebase -q is quiet' '
- git checkout -b quiet topic &&
- git rebase -q master > output.out 2>&1 &&
- test ! -s output.out
+ git checkout -b quiet topic &&
+ git rebase -q master >output.out 2>&1 &&
+ test ! -s output.out
'
test_expect_success 'Rebase a commit that sprinkles CRs in' '
diff --git a/t/t3402-rebase-merge.sh b/t/t3402-rebase-merge.sh
index 7b7d072..2bea656 100755
--- a/t/t3402-rebase-merge.sh
+++ b/t/t3402-rebase-merge.sh
@@ -74,6 +74,15 @@ test_expect_success 'rebase the other way' '
git rebase --merge side
'
+test_expect_success 'rebase -Xtheirs' '
+ git checkout -b conflicting master~2 &&
+ echo "AB $T" >> original &&
+ git commit -mconflicting original &&
+ git rebase -Xtheirs master &&
+ grep AB original &&
+ ! grep 11 original
+'
+
test_expect_success 'merge and rebase should match' '
git diff-tree -r test-rebase test-merge >difference &&
if test -s difference
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 9f03ce6..af3b663 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -64,6 +64,67 @@ test_expect_success 'setup' '
done
'
+# "exec" commands are ran with the user shell by default, but this may
+# be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
+# to create a file. Unseting SHELL avoids such non-portable behavior
+# in tests.
+SHELL=
+
+test_expect_success 'rebase -i with the exec command' '
+ git checkout master &&
+ (
+ FAKE_LINES="1 exec_>touch-one
+ 2 exec_>touch-two exec_false exec_>touch-three
+ 3 4 exec_>\"touch-file__name_with_spaces\";_>touch-after-semicolon 5" &&
+ export FAKE_LINES &&
+ test_must_fail git rebase -i A
+ ) &&
+ test_path_is_file touch-one &&
+ test_path_is_file touch-two &&
+ test_path_is_missing touch-three " (should have stopped before)" &&
+ test $(git rev-parse C) = $(git rev-parse HEAD) || {
+ echo "Stopped at wrong revision:"
+ echo "($(git describe --tags HEAD) instead of C)"
+ false
+ } &&
+ git rebase --continue &&
+ test_path_is_file touch-three &&
+ test_path_is_file "touch-file name with spaces" &&
+ test_path_is_file touch-after-semicolon &&
+ test $(git rev-parse master) = $(git rev-parse HEAD) || {
+ echo "Stopped at wrong revision:"
+ echo "($(git describe --tags HEAD) instead of master)"
+ false
+ } &&
+ rm -f touch-*
+'
+
+test_expect_success 'rebase -i with the exec command runs from tree root' '
+ git checkout master &&
+ mkdir subdir && cd subdir &&
+ FAKE_LINES="1 exec_>touch-subdir" \
+ git rebase -i HEAD^ &&
+ cd .. &&
+ test_path_is_file touch-subdir &&
+ rm -fr subdir
+'
+
+test_expect_success 'rebase -i with the exec command checks tree cleanness' '
+ git checkout master &&
+ (
+ FAKE_LINES="exec_echo_foo_>file1 1" &&
+ export FAKE_LINES &&
+ test_must_fail git rebase -i HEAD^
+ ) &&
+ test $(git rev-parse master^) = $(git rev-parse HEAD) || {
+ echo "Stopped at wrong revision:"
+ echo "($(git describe --tags HEAD) instead of master^)"
+ false
+ } &&
+ git reset --hard &&
+ git rebase --continue
+'
+
test_expect_success 'no changes are a nop' '
git checkout branch2 &&
git rebase -i F &&
@@ -143,16 +204,17 @@ test_expect_success 'abort' '
git rebase --abort &&
test $(git rev-parse new-branch1) = $(git rev-parse HEAD) &&
test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
- ! test -d .git/rebase-merge
+ test_path_is_missing .git/rebase-merge
'
test_expect_success 'abort with error when new base cannot be checked out' '
git rm --cached file1 &&
git commit -m "remove file in base" &&
test_must_fail git rebase -i master > output 2>&1 &&
- grep "Untracked working tree file .file1. would be overwritten" \
+ grep "The following untracked working tree files would be overwritten by checkout:" \
output &&
- ! test -d .git/rebase-merge &&
+ grep "file1" output &&
+ test_path_is_missing .git/rebase-merge &&
git reset --hard HEAD^
'
diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh
index 2999e78..fbb3f2e 100755
--- a/t/t3407-rebase-abort.sh
+++ b/t/t3407-rebase-abort.sh
@@ -38,7 +38,7 @@ testrebase() {
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
- test -d "$dotest" &&
+ test_path_is_dir "$dotest" &&
git rebase --abort &&
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&
test ! -d "$dotest"
@@ -49,7 +49,7 @@ testrebase() {
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
- test -d "$dotest" &&
+ test_path_is_dir "$dotest" &&
test_must_fail git rebase --skip &&
test $(git rev-parse HEAD) = $(git rev-parse master) &&
git rebase --abort &&
@@ -62,7 +62,7 @@ testrebase() {
# Clean up the state from the previous one
git reset --hard pre-rebase &&
test_must_fail git rebase$type master &&
- test -d "$dotest" &&
+ test_path_is_dir "$dotest" &&
echo c > a &&
echo d >> a &&
git add a &&
diff --git a/t/t3410-rebase-preserve-dropped-merges.sh b/t/t3410-rebase-preserve-dropped-merges.sh
index c49143a..6f73b95 100755
--- a/t/t3410-rebase-preserve-dropped-merges.sh
+++ b/t/t3410-rebase-preserve-dropped-merges.sh
@@ -43,11 +43,11 @@ test_expect_success 'setup' '
# G2 = same changes as G
test_expect_success 'skip same-resolution merges with -p' '
git checkout H &&
- ! git merge E &&
+ test_must_fail git merge E &&
test_commit L file1 23 &&
git checkout I &&
test_commit G2 file1 3 &&
- ! git merge E &&
+ test_must_fail git merge E &&
test_commit J file1 23 &&
test_commit K file7 file7 &&
git rebase -i -p L &&
@@ -65,11 +65,11 @@ test_expect_success 'skip same-resolution merges with -p' '
# G2 = different changes as G
test_expect_success 'keep different-resolution merges with -p' '
git checkout H &&
- ! git merge E &&
+ test_must_fail git merge E &&
test_commit L2 file1 23 &&
git checkout I &&
test_commit G3 file1 4 &&
- ! git merge E &&
+ test_must_fail git merge E &&
test_commit J2 file1 24 &&
test_commit K2 file7 file7 &&
test_must_fail git rebase -i -p L2 &&
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index b63f4e2..37cb89a 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -21,38 +21,62 @@ test_expect_success setup '
git tag base
'
-test_expect_success 'auto fixup' '
+test_auto_fixup() {
git reset --hard base &&
echo 1 >file1 &&
git add -u &&
test_tick &&
git commit -m "fixup! first"
- git tag final-fixup &&
+ git tag $1 &&
test_tick &&
- git rebase --autosquash -i HEAD^^^ &&
+ git rebase $2 -i HEAD^^^ &&
git log --oneline >actual &&
test 3 = $(wc -l <actual) &&
- git diff --exit-code final-fixup &&
+ git diff --exit-code $1 &&
test 1 = "$(git cat-file blob HEAD^:file1)" &&
test 1 = $(git cat-file commit HEAD^ | grep first | wc -l)
+}
+
+test_expect_success 'auto fixup (option)' '
+ test_auto_fixup final-fixup-option --autosquash
+'
+
+test_expect_success 'auto fixup (config)' '
+ git config rebase.autosquash true &&
+ test_auto_fixup final-fixup-config-true &&
+ test_must_fail test_auto_fixup fixup-config-true-no --no-autosquash &&
+ git config rebase.autosquash false &&
+ test_must_fail test_auto_fixup final-fixup-config-false
'
-test_expect_success 'auto squash' '
+test_auto_squash() {
git reset --hard base &&
echo 1 >file1 &&
git add -u &&
test_tick &&
git commit -m "squash! first"
- git tag final-squash &&
+ git tag $1 &&
test_tick &&
- git rebase --autosquash -i HEAD^^^ &&
+ git rebase $2 -i HEAD^^^ &&
git log --oneline >actual &&
test 3 = $(wc -l <actual) &&
- git diff --exit-code final-squash &&
+ git diff --exit-code $1 &&
test 1 = "$(git cat-file blob HEAD^:file1)" &&
test 2 = $(git cat-file commit HEAD^ | grep first | wc -l)
+}
+
+test_expect_success 'auto squash (option)' '
+ test_auto_squash final-squash --autosquash
+'
+
+test_expect_success 'auto squash (config)' '
+ git config rebase.autosquash true &&
+ test_auto_squash final-squash-config-true &&
+ test_must_fail test_auto_squash squash-config-true-no --no-autosquash &&
+ git config rebase.autosquash false &&
+ test_must_fail test_auto_squash final-squash-config-false
'
test_expect_success 'misspelled auto squash' '
diff --git a/t/t3505-cherry-pick-empty.sh b/t/t3505-cherry-pick-empty.sh
index e51e505..c10b28c 100755
--- a/t/t3505-cherry-pick-empty.sh
+++ b/t/t3505-cherry-pick-empty.sh
@@ -13,12 +13,30 @@ test_expect_success setup '
git checkout -b empty-branch &&
test_tick &&
- git commit --allow-empty -m "empty"
+ git commit --allow-empty -m "empty" &&
+
+ echo third >> file1 &&
+ git add file1 &&
+ test_tick &&
+ git commit --allow-empty-message -m ""
'
test_expect_success 'cherry-pick an empty commit' '
git checkout master && {
+ git cherry-pick empty-branch^
+ test "$?" = 1
+ }
+'
+
+test_expect_success 'index lockfile was removed' '
+
+ test ! -f .git/index.lock
+
+'
+
+test_expect_success 'cherry-pick a commit with an empty message' '
+ git checkout master && {
git cherry-pick empty-branch
test "$?" = 1
}
diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh
index e25cf80..607bf25 100755
--- a/t/t3507-cherry-pick-conflict.sh
+++ b/t/t3507-cherry-pick-conflict.sh
@@ -38,6 +38,26 @@ 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 &&
+
+ 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'
+ EOF
+ test_must_fail git cherry-pick picked 2>actual &&
+
+ test_cmp expected actual
+"
+
test_expect_success 'failed cherry-pick produces dirty index' '
git checkout -f initial^0 &&
diff --git a/t/t3508-cherry-pick-many-commits.sh b/t/t3508-cherry-pick-many-commits.sh
index f90ed3d..8e09fd0 100755
--- a/t/t3508-cherry-pick-many-commits.sh
+++ b/t/t3508-cherry-pick-many-commits.sh
@@ -4,6 +4,18 @@ test_description='test cherry-picking many commits'
. ./test-lib.sh
+check_head_differs_from() {
+ head=$(git rev-parse --verify HEAD) &&
+ arg=$(git rev-parse --verify "$1") &&
+ test "$head" != "$arg"
+}
+
+check_head_equals() {
+ head=$(git rev-parse --verify HEAD) &&
+ arg=$(git rev-parse --verify "$1") &&
+ test "$head" = "$arg"
+}
+
test_expect_success setup '
echo first > file1 &&
git add file1 &&
@@ -23,13 +35,55 @@ test_expect_success setup '
'
test_expect_success 'cherry-pick first..fourth works' '
+ cat <<-\EOF >expected &&
+ [master OBJID] second
+ Author: A U Thor <author@example.com>
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ [master OBJID] third
+ Author: A U Thor <author@example.com>
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ [master OBJID] fourth
+ Author: A U Thor <author@example.com>
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ EOF
+
+ git checkout -f master &&
+ git reset --hard first &&
+ test_tick &&
+ git cherry-pick first..fourth >actual &&
+ git diff --quiet other &&
+ git diff --quiet HEAD other &&
+
+ sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
+ test_cmp expected actual.fuzzy &&
+ check_head_differs_from fourth
+'
+
+test_expect_success 'cherry-pick --strategy resolve first..fourth works' '
+ cat <<-\EOF >expected &&
+ Trying simple merge.
+ [master OBJID] second
+ Author: A U Thor <author@example.com>
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ Trying simple merge.
+ [master OBJID] third
+ Author: A U Thor <author@example.com>
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ Trying simple merge.
+ [master OBJID] fourth
+ Author: A U Thor <author@example.com>
+ 1 files changed, 1 insertions(+), 0 deletions(-)
+ EOF
+
git checkout -f master &&
git reset --hard first &&
test_tick &&
- git cherry-pick first..fourth &&
+ git cherry-pick --strategy resolve first..fourth >actual &&
git diff --quiet other &&
git diff --quiet HEAD other &&
- test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+ sed -e "s/$_x05[0-9a-f][0-9a-f]/OBJID/" <actual >actual.fuzzy &&
+ test_cmp expected actual.fuzzy &&
+ check_head_differs_from fourth
'
test_expect_success 'cherry-pick --ff first..fourth works' '
@@ -39,7 +93,7 @@ test_expect_success 'cherry-pick --ff first..fourth works' '
git cherry-pick --ff first..fourth &&
git diff --quiet other &&
git diff --quiet HEAD other &&
- test "$(git rev-parse --verify HEAD)" = "$(git rev-parse --verify fourth)"
+ check_head_equals fourth
'
test_expect_success 'cherry-pick -n first..fourth works' '
@@ -89,7 +143,7 @@ test_expect_success 'cherry-pick -3 fourth works' '
git cherry-pick -3 fourth &&
git diff --quiet other &&
git diff --quiet HEAD other &&
- test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+ check_head_differs_from fourth
'
test_expect_success 'cherry-pick --stdin works' '
@@ -99,7 +153,7 @@ test_expect_success 'cherry-pick --stdin works' '
git rev-list --reverse first..fourth | git cherry-pick --stdin &&
git diff --quiet other &&
git diff --quiet HEAD other &&
- test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
+ check_head_differs_from fourth
'
test_done
diff --git a/t/t3509-cherry-pick-merge-df.sh b/t/t3509-cherry-pick-merge-df.sh
new file mode 100755
index 0000000..a5ccdbf
--- /dev/null
+++ b/t/t3509-cherry-pick-merge-df.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+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' '
+ mkdir a &&
+ >a/f &&
+ git add a &&
+ git commit -m a &&
+
+ mkdir b &&
+ ln -s ../a b/a &&
+ git add b &&
+ git commit -m b &&
+
+ git checkout -b branch &&
+ rm b/a &&
+ mv a b/a &&
+ ln -s b/a a &&
+ git add . &&
+ git commit -m swap &&
+
+ >f1 &&
+ git add f1 &&
+ git commit -m f1
+'
+
+test_expect_success SYMLINKS 'Cherry-pick succeeds with rename across D/F conflicts' '
+ git reset --hard &&
+ git checkout master^0 &&
+ git cherry-pick branch
+'
+
+test_done
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 62e208a..d99f27a 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -378,4 +378,116 @@ test_expect_failure 'stash file to directory' '
test foo = "$(cat file/file)"
'
+test_expect_success 'stash branch - no stashes on stack, stash-like argument' '
+ git stash clear &&
+ test_when_finished "git reset --hard HEAD" &&
+ git reset --hard &&
+ echo foo >> file &&
+ STASH_ID=$(git stash create) &&
+ git reset --hard &&
+ git stash branch stash-branch ${STASH_ID} &&
+ test_when_finished "git reset --hard HEAD && git checkout master && git branch -D stash-branch" &&
+ test $(git ls-files --modified | wc -l) -eq 1
+'
+
+test_expect_success 'stash branch - stashes on stack, stash-like argument' '
+ git stash clear &&
+ test_when_finished "git reset --hard HEAD" &&
+ git reset --hard &&
+ echo foo >> file &&
+ git stash &&
+ test_when_finished "git stash drop" &&
+ echo bar >> file &&
+ STASH_ID=$(git stash create) &&
+ git reset --hard &&
+ git stash branch stash-branch ${STASH_ID} &&
+ test_when_finished "git reset --hard HEAD && git checkout master && git branch -D stash-branch" &&
+ test $(git ls-files --modified | wc -l) -eq 1
+'
+
+test_expect_success 'stash show - stashes on stack, stash-like argument' '
+ git stash clear &&
+ test_when_finished "git reset --hard HEAD" &&
+ git reset --hard &&
+ echo foo >> file &&
+ git stash &&
+ test_when_finished "git stash drop" &&
+ echo bar >> file &&
+ STASH_ID=$(git stash create) &&
+ git reset --hard &&
+ git stash show ${STASH_ID}
+'
+test_expect_success 'stash show - no stashes on stack, stash-like argument' '
+ git stash clear &&
+ test_when_finished "git reset --hard HEAD" &&
+ git reset --hard &&
+ echo foo >> file &&
+ STASH_ID=$(git stash create) &&
+ git reset --hard &&
+ git stash show ${STASH_ID}
+'
+
+test_expect_success 'stash drop - fail early if specified stash is not a stash reference' '
+ git stash clear &&
+ test_when_finished "git reset --hard HEAD && git stash clear" &&
+ git reset --hard &&
+ echo foo > file &&
+ git stash &&
+ echo bar > file &&
+ git stash &&
+ test_must_fail git stash drop $(git rev-parse stash@{0}) &&
+ git stash pop &&
+ test bar = "$(cat file)" &&
+ git reset --hard HEAD
+'
+
+test_expect_success 'stash pop - fail early if specified stash is not a stash reference' '
+ git stash clear &&
+ test_when_finished "git reset --hard HEAD && git stash clear" &&
+ git reset --hard &&
+ echo foo > file &&
+ git stash &&
+ echo bar > file &&
+ git stash &&
+ test_must_fail git stash pop $(git rev-parse stash@{0}) &&
+ git stash pop &&
+ test bar = "$(cat file)" &&
+ git reset --hard HEAD
+'
+
+test_expect_success 'ref with non-existant reflog' '
+ git stash clear &&
+ echo bar5 > file &&
+ echo bar6 > file2 &&
+ git add file2 &&
+ git stash &&
+ ! "git rev-parse --quiet --verify does-not-exist" &&
+ test_must_fail git stash drop does-not-exist &&
+ test_must_fail git stash drop does-not-exist@{0} &&
+ test_must_fail git stash pop does-not-exist &&
+ test_must_fail git stash pop does-not-exist@{0} &&
+ test_must_fail git stash apply does-not-exist &&
+ test_must_fail git stash apply does-not-exist@{0} &&
+ test_must_fail git stash show does-not-exist &&
+ test_must_fail git stash show does-not-exist@{0} &&
+ test_must_fail git stash branch tmp does-not-exist &&
+ test_must_fail git stash branch tmp does-not-exist@{0} &&
+ git stash drop
+'
+
+test_expect_success 'invalid ref of the form stash@{n}, n >= N' '
+ git stash clear &&
+ test_must_fail git stash drop stash@{0} &&
+ echo bar5 > file &&
+ 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} &&
+ git stash drop
+'
+
test_done
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index dae6358..19857f4 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -208,6 +208,7 @@ log -p --first-parent master
log -m -p --first-parent master
log -m -p master
log -SF master
+log -S F master
log -SF -p master
log --decorate --all
log --decorate=full --all
@@ -282,4 +283,8 @@ diff master master^ side
diff --dirstat master~1 master~2
EOF
+test_expect_success 'log -S requires an argument' '
+ test_must_fail git log -S
+'
+
test_done
diff --git a/t/t4013/diff.log_-S_F_master b/t/t4013/diff.log_-S_F_master
new file mode 100644
index 0000000..978d2b4
--- /dev/null
+++ b/t/t4013/diff.log_-S_F_master
@@ -0,0 +1,7 @@
+$ git log -S F master
+commit 9a6d4949b6b76956d9d5e26f2791ec2ceff5fdc0
+Author: A U Thor <author@example.com>
+Date: Mon Jun 26 00:02:00 2006 +0000
+
+ Third
+$
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 5b10e97..61de8a2 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -32,7 +32,7 @@ EOF
sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
-builtin_patterns="bibtex cpp html java objc pascal php python ruby tex"
+builtin_patterns="bibtex cpp csharp html java objc pascal php python ruby tex"
for p in $builtin_patterns
do
test_expect_success "builtin $p pattern compiles" '
diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh
index 1bd8e5e..d99814a 100755
--- a/t/t4027-diff-submodule.sh
+++ b/t/t4027-diff-submodule.sh
@@ -114,6 +114,69 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)'
! test -s actual4
'
+test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) [.git/config]' '
+ git config diff.ignoreSubmodules all &&
+ git diff HEAD >actual &&
+ ! test -s actual &&
+ git config submodule.subname.ignore none &&
+ git config submodule.subname.path sub &&
+ git diff HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subprev $subprev-dirty &&
+ test_cmp expect.body actual.body &&
+ git config submodule.subname.ignore all &&
+ git diff HEAD >actual2 &&
+ ! test -s actual2 &&
+ git config submodule.subname.ignore untracked &&
+ git diff HEAD >actual3 &&
+ sed -e "1,/^@@/d" actual3 >actual3.body &&
+ expect_from_to >expect.body $subprev $subprev-dirty &&
+ test_cmp expect.body actual3.body &&
+ git config submodule.subname.ignore dirty &&
+ git diff HEAD >actual4 &&
+ ! test -s actual4 &&
+ git diff HEAD --ignore-submodules=none >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subprev $subprev-dirty &&
+ test_cmp expect.body actual.body &&
+ git config --remove-section submodule.subname &&
+ git config --unset diff.ignoreSubmodules
+'
+
+test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) [.gitmodules]' '
+ git config diff.ignoreSubmodules dirty &&
+ git diff HEAD >actual &&
+ ! test -s actual &&
+ git config --add -f .gitmodules submodule.subname.ignore none &&
+ git config --add -f .gitmodules submodule.subname.path sub &&
+ git diff HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subprev $subprev-dirty &&
+ test_cmp expect.body actual.body &&
+ git config -f .gitmodules submodule.subname.ignore all &&
+ git config -f .gitmodules submodule.subname.path sub &&
+ git diff HEAD >actual2 &&
+ ! test -s actual2 &&
+ git config -f .gitmodules submodule.subname.ignore untracked &&
+ git diff HEAD >actual3 &&
+ sed -e "1,/^@@/d" actual3 >actual3.body &&
+ expect_from_to >expect.body $subprev $subprev-dirty &&
+ test_cmp expect.body actual3.body &&
+ git config -f .gitmodules submodule.subname.ignore dirty &&
+ git diff HEAD >actual4 &&
+ ! test -s actual4 &&
+ git config submodule.subname.ignore none &&
+ git config submodule.subname.path sub &&
+ git diff HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subprev $subprev-dirty &&
+ test_cmp expect.body actual.body &&
+ git config --remove-section submodule.subname &&
+ git config --remove-section -f .gitmodules submodule.subname &&
+ git config --unset diff.ignoreSubmodules &&
+ rm .gitmodules
+'
+
test_expect_success 'git diff HEAD with dirty submodule (index, refs match)' '
(
cd sub &&
@@ -146,6 +209,103 @@ test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match)'
! test -s actual4
'
+test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match) [.git/config]' '
+ git config submodule.subname.ignore all &&
+ git config submodule.subname.path sub &&
+ git diff HEAD >actual2 &&
+ ! test -s actual2 &&
+ git config submodule.subname.ignore untracked &&
+ git diff HEAD >actual3 &&
+ ! test -s actual3 &&
+ git config submodule.subname.ignore dirty &&
+ git diff HEAD >actual4 &&
+ ! test -s actual4 &&
+ git diff --ignore-submodules=none HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subprev $subprev-dirty &&
+ test_cmp expect.body actual.body &&
+ git config --remove-section submodule.subname
+'
+
+test_expect_success 'git diff HEAD with dirty submodule (untracked, refs match) [.gitmodules]' '
+ git config --add -f .gitmodules submodule.subname.ignore all &&
+ git config --add -f .gitmodules submodule.subname.path sub &&
+ git diff HEAD >actual2 &&
+ ! test -s actual2 &&
+ git config -f .gitmodules submodule.subname.ignore untracked &&
+ git diff HEAD >actual3 &&
+ ! test -s actual3 &&
+ git config -f .gitmodules submodule.subname.ignore dirty &&
+ git diff HEAD >actual4 &&
+ ! test -s actual4 &&
+ git config submodule.subname.ignore none &&
+ git config submodule.subname.path sub &&
+ git diff HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subprev $subprev-dirty &&
+ test_cmp expect.body actual.body &&
+ git config --remove-section submodule.subname &&
+ git config --remove-section -f .gitmodules submodule.subname &&
+ rm .gitmodules
+'
+
+test_expect_success 'git diff between submodule commits' '
+ git diff HEAD^..HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body &&
+ git diff --ignore-submodules=dirty HEAD^..HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body &&
+ git diff --ignore-submodules HEAD^..HEAD >actual &&
+ ! test -s actual
+'
+
+test_expect_success 'git diff between submodule commits [.git/config]' '
+ git diff HEAD^..HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body &&
+ git config submodule.subname.ignore dirty &&
+ git config submodule.subname.path sub &&
+ git diff HEAD^..HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body &&
+ git config submodule.subname.ignore all &&
+ git diff HEAD^..HEAD >actual &&
+ ! test -s actual &&
+ git diff --ignore-submodules=dirty HEAD^..HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ git config --remove-section submodule.subname
+'
+
+test_expect_success 'git diff between submodule commits [.gitmodules]' '
+ git diff HEAD^..HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body &&
+ git config --add -f .gitmodules submodule.subname.ignore dirty &&
+ git config --add -f .gitmodules submodule.subname.path sub &&
+ git diff HEAD^..HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ test_cmp expect.body actual.body &&
+ git config -f .gitmodules submodule.subname.ignore all &&
+ git diff HEAD^..HEAD >actual &&
+ ! test -s actual &&
+ git config submodule.subname.ignore dirty &&
+ git config submodule.subname.path sub &&
+ git diff HEAD^..HEAD >actual &&
+ sed -e "1,/^@@/d" actual >actual.body &&
+ expect_from_to >expect.body $subtip $subprev &&
+ git config --remove-section submodule.subname &&
+ git config --remove-section -f .gitmodules submodule.subname &&
+ rm .gitmodules
+'
+
test_expect_success 'git diff (empty submodule dir)' '
: >empty &&
rm -rf sub/* sub/.git &&
diff --git a/t/t4111-apply-subdir.sh b/t/t4111-apply-subdir.sh
new file mode 100755
index 0000000..a52d94a
--- /dev/null
+++ b/t/t4111-apply-subdir.sh
@@ -0,0 +1,142 @@
+#!/bin/sh
+
+test_description='patching from inconvenient places'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ cat >patch <<-\EOF &&
+ diff file.orig file
+ --- a/file.orig
+ +++ b/file
+ @@ -1 +1,2 @@
+ 1
+ +2
+ EOF
+ patch="$(pwd)/patch" &&
+
+ echo 1 >preimage &&
+ printf "%s\n" 1 2 >postimage &&
+ echo 3 >other &&
+
+ test_tick &&
+ git commit --allow-empty -m basis
+'
+
+test_expect_success 'setup: subdir' '
+ reset_subdir() {
+ git reset &&
+ mkdir -p sub/dir/b &&
+ mkdir -p objects &&
+ cp "$1" file &&
+ cp "$1" objects/file &&
+ cp "$1" sub/dir/file &&
+ cp "$1" sub/dir/b/file &&
+ git add file sub/dir/file sub/dir/b/file objects/file &&
+ cp "$2" file &&
+ cp "$2" sub/dir/file &&
+ cp "$2" sub/dir/b/file &&
+ cp "$2" objects/file &&
+ test_might_fail git update-index --refresh -q
+ }
+'
+
+test_expect_success 'apply from subdir of toplevel' '
+ cp postimage expected &&
+ reset_subdir other preimage &&
+ (
+ cd sub/dir &&
+ git apply "$patch"
+ ) &&
+ test_cmp expected sub/dir/file
+'
+
+test_expect_success 'apply --cached from subdir of toplevel' '
+ cp postimage expected &&
+ cp other expected.working &&
+ reset_subdir preimage other &&
+ (
+ cd sub/dir &&
+ git apply --cached "$patch"
+ ) &&
+ git show :sub/dir/file >actual &&
+ test_cmp expected actual &&
+ test_cmp expected.working sub/dir/file
+'
+
+test_expect_success 'apply --index from subdir of toplevel' '
+ cp postimage expected &&
+ reset_subdir preimage other &&
+ (
+ cd sub/dir &&
+ test_must_fail git apply --index "$patch"
+ ) &&
+ reset_subdir other preimage &&
+ (
+ cd sub/dir &&
+ test_must_fail git apply --index "$patch"
+ ) &&
+ reset_subdir preimage preimage &&
+ (
+ cd sub/dir &&
+ git apply --index "$patch"
+ ) &&
+ git show :sub/dir/file >actual &&
+ test_cmp expected actual &&
+ test_cmp expected sub/dir/file
+'
+
+test_expect_success 'apply from .git dir' '
+ cp postimage expected &&
+ cp preimage .git/file &&
+ cp preimage .git/objects/file
+ (
+ cd .git &&
+ git apply "$patch"
+ ) &&
+ test_cmp expected .git/file
+'
+
+test_expect_success 'apply from subdir of .git dir' '
+ cp postimage expected &&
+ cp preimage .git/file &&
+ cp preimage .git/objects/file
+ (
+ cd .git/objects &&
+ git apply "$patch"
+ ) &&
+ test_cmp expected .git/objects/file
+'
+
+test_expect_success 'apply --cached from .git dir' '
+ cp postimage expected &&
+ cp other expected.working &&
+ cp other .git/file &&
+ reset_subdir preimage other &&
+ (
+ cd .git &&
+ git apply --cached "$patch"
+ ) &&
+ git show :file >actual &&
+ test_cmp expected actual &&
+ test_cmp expected.working file &&
+ test_cmp expected.working .git/file
+'
+
+test_expect_success 'apply --cached from subdir of .git dir' '
+ cp postimage expected &&
+ cp preimage expected.subdir &&
+ cp other .git/file &&
+ cp other .git/objects/file &&
+ reset_subdir preimage other &&
+ (
+ cd .git/objects &&
+ git apply --cached "$patch"
+ ) &&
+ git show :file >actual &&
+ git show :objects/file >actual.subdir &&
+ test_cmp expected actual &&
+ test_cmp expected.subdir actual.subdir
+'
+
+test_done
diff --git a/t/t4120-apply-popt.sh b/t/t4120-apply-popt.sh
index b463b4f..2b2d00b 100755
--- a/t/t4120-apply-popt.sh
+++ b/t/t4120-apply-popt.sh
@@ -10,21 +10,50 @@ test_description='git apply -p handling.'
test_expect_success setup '
mkdir sub &&
echo A >sub/file1 &&
- cp sub/file1 file1 &&
+ cp sub/file1 file1.saved &&
git add sub/file1 &&
echo B >sub/file1 &&
git diff >patch.file &&
- rm sub/file1 &&
- rmdir sub
+ git checkout -- sub/file1 &&
+ git mv sub süb &&
+ echo B >süb/file1 &&
+ git diff >patch.escaped &&
+ grep "[\]" patch.escaped &&
+ rm süb/file1 &&
+ rmdir süb
'
test_expect_success 'apply git diff with -p2' '
+ cp file1.saved file1 &&
git apply -p2 patch.file
'
test_expect_success 'apply with too large -p' '
+ cp file1.saved file1 &&
test_must_fail git apply --stat -p3 patch.file 2>err &&
grep "removing 3 leading" err
'
+test_expect_success 'apply (-p2) traditional diff with funny filenames' '
+ cat >patch.quotes <<-\EOF &&
+ diff -u "a/"sub/file1 "b/"sub/file1
+ --- "a/"sub/file1
+ +++ "b/"sub/file1
+ @@ -1 +1 @@
+ -A
+ +B
+ EOF
+ echo B >expected &&
+
+ cp file1.saved file1 &&
+ git apply -p2 patch.quotes &&
+ test_cmp expected file1
+'
+
+test_expect_success 'apply with too large -p and fancy filename' '
+ cp file1.saved file1 &&
+ test_must_fail git apply --stat -p3 patch.escaped 2>err &&
+ grep "removing 3 leading" err
+'
+
test_done
diff --git a/t/t4135-apply-weird-filenames.sh b/t/t4135-apply-weird-filenames.sh
new file mode 100755
index 0000000..1e5aad5
--- /dev/null
+++ b/t/t4135-apply-weird-filenames.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+test_description='git apply with weird postimage filenames'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+ vector=$TEST_DIRECTORY/t4135 &&
+
+ test_tick &&
+ git commit --allow-empty -m preimage &&
+ git tag preimage &&
+
+ reset_preimage() {
+ git checkout -f preimage^0 &&
+ git read-tree -u --reset HEAD &&
+ git update-index --refresh
+ } &&
+
+ test_when_finished "rm -f \"tab embedded.txt\"" &&
+ test_when_finished "rm -f '\''\"quoteembedded\".txt'\''" &&
+ if touch -- "tab embedded.txt" '\''"quoteembedded".txt'\''
+ then
+ test_set_prereq FUNNYNAMES
+ fi
+'
+
+try_filename() {
+ desc=$1
+ postimage=$2
+ prereq=${3:-}
+ exp1=${4:-success}
+ exp2=${5:-success}
+ exp3=${6:-success}
+
+ test_expect_$exp1 $prereq "$desc, git-style file creation patch" "
+ echo postimage >expected &&
+ reset_preimage &&
+ rm -f '$postimage' &&
+ git apply -v \"\$vector\"/'git-$desc.diff' &&
+ test_cmp expected '$postimage'
+ "
+
+ test_expect_$exp2 $prereq "$desc, traditional patch" "
+ echo postimage >expected &&
+ reset_preimage &&
+ echo preimage >'$postimage' &&
+ git apply -v \"\$vector\"/'diff-$desc.diff' &&
+ test_cmp expected '$postimage'
+ "
+
+ test_expect_$exp3 $prereq "$desc, traditional file creation patch" "
+ echo postimage >expected &&
+ reset_preimage &&
+ rm -f '$postimage' &&
+ git apply -v \"\$vector\"/'add-$desc.diff' &&
+ test_cmp expected '$postimage'
+ "
+}
+
+try_filename 'plain' 'postimage.txt'
+try_filename 'with spaces' 'post image.txt'
+try_filename 'with tab' 'post image.txt' FUNNYNAMES
+try_filename 'with backslash' 'post\image.txt' BSLASHPSPEC
+try_filename 'with quote' '"postimage".txt' FUNNYNAMES success failure success
+
+test_expect_success 'whitespace-damaged traditional patch' '
+ echo postimage >expected &&
+ reset_preimage &&
+ rm -f postimage.txt &&
+ git apply -v "$vector/damaged.diff" &&
+ test_cmp expected postimage.txt
+'
+
+test_done
diff --git a/t/t4135/.gitignore b/t/t4135/.gitignore
new file mode 100644
index 0000000..3e58e65
--- /dev/null
+++ b/t/t4135/.gitignore
@@ -0,0 +1,3 @@
+/file-creation/
+/trad-creation/
+/trad-modification/
diff --git a/t/t4135/add-plain.diff b/t/t4135/add-plain.diff
new file mode 100644
index 0000000..cf5970a
--- /dev/null
+++ b/t/t4135/add-plain.diff
@@ -0,0 +1,5 @@
+diff -pruN a/postimage.txt b/postimage.txt
+--- a/postimage.txt 1969-12-31 18:00:00.000000000 -0600
++++ b/postimage.txt 2010-08-18 20:13:31.484002255 -0500
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/add-with backslash.diff b/t/t4135/add-with backslash.diff
new file mode 100644
index 0000000..c6861e1
--- /dev/null
+++ b/t/t4135/add-with backslash.diff
@@ -0,0 +1,5 @@
+diff -pruN a/post\image.txt b/post\image.txt
+--- a/post\image.txt 1969-12-31 18:00:00.000000000 -0600
++++ b/post\image.txt 2010-08-18 20:13:31.692002255 -0500
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/add-with quote.diff b/t/t4135/add-with quote.diff
new file mode 100644
index 0000000..866de78
--- /dev/null
+++ b/t/t4135/add-with quote.diff
@@ -0,0 +1,5 @@
+diff -pruN a/"postimage".txt b/"postimage".txt
+--- a/"postimage".txt 1969-12-31 18:00:00.000000000 -0600
++++ b/"postimage".txt 2010-08-18 20:13:31.756002255 -0500
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/add-with spaces.diff b/t/t4135/add-with spaces.diff
new file mode 100644
index 0000000..a9a1212
--- /dev/null
+++ b/t/t4135/add-with spaces.diff
@@ -0,0 +1,5 @@
+diff -pruN a/post image.txt b/post image.txt
+--- a/post image.txt 1969-12-31 18:00:00.000000000 -0600
++++ b/post image.txt 2010-08-18 20:13:31.556002255 -0500
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/add-with tab.diff b/t/t4135/add-with tab.diff
new file mode 100644
index 0000000..bb67cb7
--- /dev/null
+++ b/t/t4135/add-with tab.diff
@@ -0,0 +1,5 @@
+diff -pruN a/post image.txt b/post image.txt
+--- a/post image.txt 1969-12-31 18:00:00.000000000 -0600
++++ b/post image.txt 2010-08-18 20:13:31.628002255 -0500
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/damaged.diff b/t/t4135/damaged.diff
new file mode 100644
index 0000000..68f7ede
--- /dev/null
+++ b/t/t4135/damaged.diff
@@ -0,0 +1,5 @@
+diff -pruN a/postimage.txt b/postimage.txt
+--- a/postimage.txt 1969-12-31 18:00:00.000000000 -0600
++++ b/postimage.txt 2010-08-18 20:13:31.484002255 -0500
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/diff-plain.diff b/t/t4135/diff-plain.diff
new file mode 100644
index 0000000..acedcfa
--- /dev/null
+++ b/t/t4135/diff-plain.diff
@@ -0,0 +1,5 @@
+--- postimage.txt.orig 2010-08-18 20:13:31.432002255 -0500
++++ postimage.txt 2010-08-18 20:13:31.432002255 -0500
+@@ -1 +1 @@
+-preimage
++postimage
diff --git a/t/t4135/diff-with backslash.diff b/t/t4135/diff-with backslash.diff
new file mode 100644
index 0000000..9068a61
--- /dev/null
+++ b/t/t4135/diff-with backslash.diff
@@ -0,0 +1,5 @@
+--- post\image.txt.orig 2010-08-18 20:13:31.680002255 -0500
++++ post\image.txt 2010-08-18 20:13:31.680002255 -0500
+@@ -1 +1 @@
+-preimage
++postimage
diff --git a/t/t4135/diff-with quote.diff b/t/t4135/diff-with quote.diff
new file mode 100644
index 0000000..c8e8cc1
--- /dev/null
+++ b/t/t4135/diff-with quote.diff
@@ -0,0 +1,5 @@
+--- "postimage".txt.orig 2010-08-18 20:13:31.744002255 -0500
++++ "postimage".txt 2010-08-18 20:13:31.744002255 -0500
+@@ -1 +1 @@
+-preimage
++postimage
diff --git a/t/t4135/diff-with spaces.diff b/t/t4135/diff-with spaces.diff
new file mode 100644
index 0000000..3512056
--- /dev/null
+++ b/t/t4135/diff-with spaces.diff
@@ -0,0 +1,5 @@
+--- post image.txt.orig 2010-08-18 20:13:31.544002255 -0500
++++ post image.txt 2010-08-18 20:13:31.544002255 -0500
+@@ -1 +1 @@
+-preimage
++postimage
diff --git a/t/t4135/diff-with tab.diff b/t/t4135/diff-with tab.diff
new file mode 100644
index 0000000..4e6d9b2
--- /dev/null
+++ b/t/t4135/diff-with tab.diff
@@ -0,0 +1,5 @@
+--- post image.txt.orig 2010-08-18 20:13:31.616002255 -0500
++++ post image.txt 2010-08-18 20:13:31.616002255 -0500
+@@ -1 +1 @@
+-preimage
++postimage
diff --git a/t/t4135/git-plain.diff b/t/t4135/git-plain.diff
new file mode 100644
index 0000000..db47d1a
--- /dev/null
+++ b/t/t4135/git-plain.diff
@@ -0,0 +1,7 @@
+diff --git a/postimage.txt b/postimage.txt
+new file mode 100644
+index 0000000..eff0c54
+--- /dev/null
++++ b/postimage.txt
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/git-with backslash.diff b/t/t4135/git-with backslash.diff
new file mode 100644
index 0000000..0e84a10
--- /dev/null
+++ b/t/t4135/git-with backslash.diff
@@ -0,0 +1,7 @@
+diff --git "a/post\\image.txt" "b/post\\image.txt"
+new file mode 100644
+index 0000000..eff0c54
+--- /dev/null
++++ "b/post\\image.txt"
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/git-with quote.diff b/t/t4135/git-with quote.diff
new file mode 100644
index 0000000..bdbea8a
--- /dev/null
+++ b/t/t4135/git-with quote.diff
@@ -0,0 +1,7 @@
+diff --git "a/\"postimage\".txt" "b/\"postimage\".txt"
+new file mode 100644
+index 0000000..eff0c54
+--- /dev/null
++++ "b/\"postimage\".txt"
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/git-with spaces.diff b/t/t4135/git-with spaces.diff
new file mode 100644
index 0000000..baaa810
--- /dev/null
+++ b/t/t4135/git-with spaces.diff
@@ -0,0 +1,7 @@
+diff --git a/post image.txt b/post image.txt
+new file mode 100644
+index 0000000..eff0c54
+--- /dev/null
++++ b/post image.txt
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/git-with tab.diff b/t/t4135/git-with tab.diff
new file mode 100644
index 0000000..cca3c92
--- /dev/null
+++ b/t/t4135/git-with tab.diff
@@ -0,0 +1,7 @@
+diff --git "a/post\timage.txt" "b/post\timage.txt"
+new file mode 100644
+index 0000000..eff0c54
+--- /dev/null
++++ "b/post\timage.txt"
+@@ -0,0 +1 @@
++postimage
diff --git a/t/t4135/make-patches b/t/t4135/make-patches
new file mode 100755
index 0000000..f5f45dd
--- /dev/null
+++ b/t/t4135/make-patches
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+do_filename() {
+ desc=$1
+ postimage=$2
+
+ rm -fr file-creation &&
+ git init file-creation &&
+ (
+ cd file-creation &&
+ git commit --allow-empty -m init &&
+ echo postimage >"$postimage" &&
+ git add -N "$postimage" &&
+ git diff HEAD >"../git-$desc.diff"
+ ) &&
+
+ rm -fr trad-modification &&
+ mkdir trad-modification &&
+ (
+ cd trad-modification &&
+ echo preimage >"$postimage.orig" &&
+ echo postimage >"$postimage" &&
+ ! diff -u "$postimage.orig" "$postimage" >"../diff-$desc.diff"
+ ) &&
+
+ rm -fr trad-creation &&
+ mkdir trad-creation &&
+ (
+ cd trad-creation &&
+ mkdir a b &&
+ echo postimage >"b/$postimage" &&
+ ! diff -pruN a b >"../add-$desc.diff"
+ )
+}
+
+do_filename plain postimage.txt &&
+do_filename 'with spaces' 'post image.txt' &&
+do_filename 'with tab' 'post image.txt' &&
+do_filename 'with backslash' 'post\image.txt' &&
+do_filename 'with quote' '"postimage".txt' &&
+expand add-plain.diff >damaged.diff ||
+{
+ echo >&2 Failed. &&
+ exit 1
+}
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 810b04b..1c3d8ed 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -4,66 +4,71 @@ test_description='git am running'
. ./test-lib.sh
-cat >msg <<EOF
-second
-
-Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy
-eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
-voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
-kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
-ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
-tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
-vero eos et accusam et justo duo dolores et ea rebum.
-
- Duis autem vel eum iriure dolor in hendrerit in vulputate velit
- esse molestie consequat, vel illum dolore eu feugiat nulla facilisis
- at vero eros et accumsan et iusto odio dignissim qui blandit
- praesent luptatum zzril delenit augue duis dolore te feugait nulla
- facilisi.
-
-
-Lorem ipsum dolor sit amet,
-consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
-laoreet dolore magna aliquam erat volutpat.
-
- git
- ---
- +++
-
-Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
-lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
-dolor in hendrerit in vulputate velit esse molestie consequat, vel illum
-dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
-dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te
-feugait nulla facilisi.
-EOF
-
-cat >failmail <<EOF
-From foo@example.com Fri May 23 10:43:49 2008
-From: foo@example.com
-To: bar@example.com
-Subject: Re: [RFC/PATCH] git-foo.sh
-Date: Fri, 23 May 2008 05:23:42 +0200
-
-Sometimes we have to find out that there's nothing left.
-
-EOF
-
-cat >pine <<EOF
-From MAILER-DAEMON Fri May 23 10:43:49 2008
-Date: 23 May 2008 05:23:42 +0200
-From: Mail System Internal Data <MAILER-DAEMON@example.com>
-Subject: DON'T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA
-Message-ID: <foo-0001@example.com>
-
-This text is part of the internal format of your mail folder, and is not
-a real message. It is created automatically by the mail system software.
-If deleted, important folder data will be lost, and it will be re-created
-with the data reset to initial values.
-
-EOF
-
-echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected
+test_expect_success 'setup: messages' '
+ cat >msg <<-\EOF &&
+ second
+
+ Lorem ipsum dolor sit amet, consectetuer sadipscing elitr, sed diam nonumy
+ eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
+ voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
+ kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
+ ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
+ tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
+ vero eos et accusam et justo duo dolores et ea rebum.
+
+ EOF
+ q_to_tab <<-\EOF >>msg &&
+ QDuis autem vel eum iriure dolor in hendrerit in vulputate velit
+ Qesse molestie consequat, vel illum dolore eu feugiat nulla facilisis
+ Qat vero eros et accumsan et iusto odio dignissim qui blandit
+ Qpraesent luptatum zzril delenit augue duis dolore te feugait nulla
+ Qfacilisi.
+ EOF
+ cat >>msg <<-\EOF &&
+
+ Lorem ipsum dolor sit amet,
+ consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut
+ laoreet dolore magna aliquam erat volutpat.
+
+ git
+ ---
+ +++
+
+ Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
+ lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
+ dolor in hendrerit in vulputate velit esse molestie consequat, vel illum
+ dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio
+ dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te
+ feugait nulla facilisi.
+ EOF
+
+ cat >failmail <<-\EOF &&
+ From foo@example.com Fri May 23 10:43:49 2008
+ From: foo@example.com
+ To: bar@example.com
+ Subject: Re: [RFC/PATCH] git-foo.sh
+ Date: Fri, 23 May 2008 05:23:42 +0200
+
+ Sometimes we have to find out that there'\''s nothing left.
+
+ EOF
+
+ cat >pine <<-\EOF &&
+ From MAILER-DAEMON Fri May 23 10:43:49 2008
+ Date: 23 May 2008 05:23:42 +0200
+ From: Mail System Internal Data <MAILER-DAEMON@example.com>
+ Subject: DON'\''T DELETE THIS MESSAGE -- FOLDER INTERNAL DATA
+ Message-ID: <foo-0001@example.com>
+
+ This text is part of the internal format of your mail folder, and is not
+ a real message. It is created automatically by the mail system software.
+ If deleted, important folder data will be lost, and it will be re-created
+ with the data reset to initial values.
+
+ EOF
+
+ signoff="Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>"
+'
test_expect_success setup '
echo hello >file &&
@@ -71,11 +76,13 @@ test_expect_success setup '
test_tick &&
git commit -m first &&
git tag first &&
+
echo world >>file &&
git add file &&
test_tick &&
git commit -s -F msg &&
git tag second &&
+
git format-patch --stdout first >patch1 &&
{
echo "X-Fake-Field: Line One" &&
@@ -89,74 +96,101 @@ test_expect_success setup '
echo "X-Fake-Field: Line Three" &&
git format-patch --stdout first | sed -e "1d"
} | append_cr >patch1-crlf.eml &&
+
sed -n -e "3,\$p" msg >file &&
git add file &&
test_tick &&
git commit -m third &&
+
git format-patch --stdout first >patch2 &&
+
git checkout -b lorem &&
sed -n -e "11,\$p" msg >file &&
head -n 9 msg >>file &&
test_tick &&
git commit -a -m "moved stuff" &&
+
echo goodbye >another &&
git add another &&
test_tick &&
git commit -m "added another file" &&
- git format-patch --stdout master >lorem-move.patch
-'
-# reset time
-unset test_tick
-test_tick
+ git format-patch --stdout master >lorem-move.patch &&
+
+ git checkout -b rename &&
+ git mv file renamed &&
+ git commit -m "renamed a file" &&
+
+ git format-patch -M --stdout lorem >rename.patch &&
+
+ git reset --soft lorem^ &&
+ git commit -m "renamed a file and added another" &&
+
+ git format-patch -M --stdout lorem^ >rename-add.patch &&
+
+ # reset time
+ unset test_tick &&
+ test_tick
+'
test_expect_success 'am applies patch correctly' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
test_tick &&
git am <patch1 &&
! test -d .git/rebase-apply &&
- test -z "$(git diff second)" &&
+ git diff --exit-code second &&
test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
'
test_expect_success 'am applies patch e-mail not in a mbox' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
git am patch1.eml &&
! test -d .git/rebase-apply &&
- test -z "$(git diff second)" &&
+ git diff --exit-code second &&
test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
'
test_expect_success 'am applies patch e-mail not in a mbox with CRLF' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
git am patch1-crlf.eml &&
! test -d .git/rebase-apply &&
- test -z "$(git diff second)" &&
+ git diff --exit-code second &&
test "$(git rev-parse second)" = "$(git rev-parse HEAD)" &&
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
'
-GIT_AUTHOR_NAME="Another Thor"
-GIT_AUTHOR_EMAIL="a.thor@example.com"
-GIT_COMMITTER_NAME="Co M Miter"
-GIT_COMMITTER_EMAIL="c.miter@example.com"
-export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
+test_expect_success 'setup: new author and committer' '
+ GIT_AUTHOR_NAME="Another Thor" &&
+ GIT_AUTHOR_EMAIL="a.thor@example.com" &&
+ GIT_COMMITTER_NAME="Co M Miter" &&
+ GIT_COMMITTER_EMAIL="c.miter@example.com" &&
+ export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
+'
compare () {
- test "$(git cat-file commit "$2" | grep "^$1 ")" = \
- "$(git cat-file commit "$3" | grep "^$1 ")"
+ a=$(git cat-file commit "$2" | grep "^$1 ") &&
+ b=$(git cat-file commit "$3" | grep "^$1 ") &&
+ test "$a" = "$b"
}
test_expect_success 'am changes committer and keeps author' '
test_tick &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
git am patch2 &&
! test -d .git/rebase-apply &&
test "$(git rev-parse master^^)" = "$(git rev-parse HEAD^^)" &&
- test -z "$(git diff master..HEAD)" &&
- test -z "$(git diff master^..HEAD^)" &&
+ git diff --exit-code master..HEAD &&
+ git diff --exit-code master^..HEAD^ &&
compare author master HEAD &&
compare author master^ HEAD^ &&
test "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" = \
@@ -164,41 +198,55 @@ test_expect_success 'am changes committer and keeps author' '
'
test_expect_success 'am --signoff adds Signed-off-by: line' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout -b master2 first &&
git am --signoff <patch2 &&
+ printf "%s\n" "$signoff" >expected &&
echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >>expected &&
git cat-file commit HEAD^ | grep "Signed-off-by:" >actual &&
- test_cmp actual expected &&
+ test_cmp expected actual &&
echo "Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" >expected &&
git cat-file commit HEAD | grep "Signed-off-by:" >actual &&
- test_cmp actual expected
+ test_cmp expected actual
'
test_expect_success 'am stays in branch' '
- test "refs/heads/master2" = "$(git symbolic-ref HEAD)"
+ echo refs/heads/master2 >expected &&
+ git symbolic-ref HEAD >actual &&
+ test_cmp expected actual
'
test_expect_success 'am --signoff does not add Signed-off-by: line if already there' '
git format-patch --stdout HEAD^ >patch3 &&
sed -e "/^Subject/ s,\[PATCH,Re: Re: Re: & 1/5 v2," patch3 >patch4
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout HEAD^ &&
git am --signoff patch4 &&
- test "$(git cat-file commit HEAD | grep -c "^Signed-off-by:")" -eq 1
+ git cat-file commit HEAD >actual &&
+ test $(grep -c "^Signed-off-by:" actual) -eq 1
'
test_expect_success 'am without --keep removes Re: and [PATCH] stuff' '
- test "$(git rev-parse HEAD)" = "$(git rev-parse master2)"
+ git rev-parse HEAD >expected &&
+ git rev-parse master2 >actual &&
+ test_cmp expected actual
'
test_expect_success 'am --keep really keeps the subject' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout HEAD^ &&
git am --keep patch4 &&
! test -d .git/rebase-apply &&
- git cat-file commit HEAD |
- fgrep "Re: Re: Re: [PATCH 1/5 v2] third"
+ git cat-file commit HEAD >actual &&
+ grep "Re: Re: Re: \[PATCH 1/5 v2\] third" actual
'
test_expect_success 'am -3 falls back to 3-way merge' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout -b lorem2 master2 &&
sed -n -e "3,\$p" msg >file &&
head -n 9 msg >>file &&
@@ -207,34 +255,75 @@ test_expect_success 'am -3 falls back to 3-way merge' '
git commit -m "copied stuff" &&
git am -3 lorem-move.patch &&
! test -d .git/rebase-apply &&
- test -z "$(git diff lorem)"
+ git diff --exit-code lorem
+'
+
+test_expect_success 'am can rename a file' '
+ grep "^rename from" rename.patch &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout lorem^0 &&
+ git am rename.patch &&
+ ! test -d .git/rebase-apply &&
+ git update-index --refresh &&
+ git diff --exit-code rename
+'
+
+test_expect_success 'am -3 can rename a file' '
+ grep "^rename from" rename.patch &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout lorem^0 &&
+ git am -3 rename.patch &&
+ ! test -d .git/rebase-apply &&
+ git update-index --refresh &&
+ git diff --exit-code rename
+'
+
+test_expect_success 'am -3 can rename a file after falling back to 3-way merge' '
+ grep "^rename from" rename-add.patch &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout lorem^0 &&
+ git am -3 rename-add.patch &&
+ ! test -d .git/rebase-apply &&
+ git update-index --refresh &&
+ git diff --exit-code rename
'
test_expect_success 'am -3 -q is quiet' '
+ rm -fr .git/rebase-apply &&
+ git checkout -f lorem2 &&
git reset master2 --hard &&
sed -n -e "3,\$p" msg >file &&
head -n 9 msg >>file &&
git add file &&
test_tick &&
git commit -m "copied stuff" &&
- git am -3 -q lorem-move.patch > output.out 2>&1 &&
+ git am -3 -q lorem-move.patch >output.out 2>&1 &&
! test -s output.out
'
test_expect_success 'am pauses on conflict' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout lorem2^^ &&
test_must_fail git am lorem-move.patch &&
test -d .git/rebase-apply
'
test_expect_success 'am --skip works' '
+ echo goodbye >expected &&
git am --skip &&
! test -d .git/rebase-apply &&
- test -z "$(git diff lorem2^^ -- file)" &&
- test goodbye = "$(cat another)"
+ git diff --exit-code lorem2^^ -- file &&
+ test_cmp expected another
'
test_expect_success 'am --resolved works' '
+ echo goodbye >expected &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout lorem2^^ &&
test_must_fail git am lorem-move.patch &&
test -d .git/rebase-apply &&
@@ -242,22 +331,29 @@ test_expect_success 'am --resolved works' '
git add file &&
git am --resolved &&
! test -d .git/rebase-apply &&
- test goodbye = "$(cat another)"
+ test_cmp expected another
'
test_expect_success 'am takes patches from a Pine mailbox' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
cat pine patch1 | git am &&
! test -d .git/rebase-apply &&
- test -z "$(git diff master^..HEAD)"
+ git diff --exit-code master^..HEAD
'
test_expect_success 'am fails on mail without patch' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
test_must_fail git am <failmail &&
- rm -r .git/rebase-apply/
+ git am --abort &&
+ ! test -d .git/rebase-apply
'
test_expect_success 'am fails on empty patch' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
echo "---" >>failmail &&
test_must_fail git am <failmail &&
git am --skip &&
@@ -266,28 +362,34 @@ test_expect_success 'am fails on empty patch' '
test_expect_success 'am works from stdin in subdirectory' '
rm -fr subdir &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
(
mkdir -p subdir &&
cd subdir &&
git am <../patch1
) &&
- test -z "$(git diff second)"
+ git diff --exit-code second
'
test_expect_success 'am works from file (relative path given) in subdirectory' '
rm -fr subdir &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
(
mkdir -p subdir &&
cd subdir &&
git am ../patch1
) &&
- test -z "$(git diff second)"
+ git diff --exit-code second
'
test_expect_success 'am works from file (absolute path given) in subdirectory' '
rm -fr subdir &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
P=$(pwd) &&
(
@@ -295,27 +397,31 @@ test_expect_success 'am works from file (absolute path given) in subdirectory' '
cd subdir &&
git am "$P/patch1"
) &&
- test -z "$(git diff second)"
+ git diff --exit-code second
'
test_expect_success 'am --committer-date-is-author-date' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
test_tick &&
git am --committer-date-is-author-date patch1 &&
git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
- at=$(sed -ne "/^author /s/.*> //p" head1) &&
- ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
- test "$at" = "$ct"
+ sed -ne "/^author /s/.*> //p" head1 >at &&
+ sed -ne "/^committer /s/.*> //p" head1 >ct &&
+ test_cmp at ct
'
test_expect_success 'am without --committer-date-is-author-date' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
test_tick &&
git am patch1 &&
git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
- at=$(sed -ne "/^author /s/.*> //p" head1) &&
- ct=$(sed -ne "/^committer /s/.*> //p" head1) &&
- test "$at" != "$ct"
+ sed -ne "/^author /s/.*> //p" head1 >at &&
+ sed -ne "/^committer /s/.*> //p" head1 >ct &&
+ ! test_cmp at ct
'
# This checks for +0000 because TZ is set to UTC and that should
@@ -323,41 +429,51 @@ test_expect_success 'am without --committer-date-is-author-date' '
# by test_tick that uses -0700 timezone; if this feature does not
# work, we will see that instead of +0000.
test_expect_success 'am --ignore-date' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
test_tick &&
git am --ignore-date patch1 &&
git cat-file commit HEAD | sed -e "/^\$/q" >head1 &&
- at=$(sed -ne "/^author /s/.*> //p" head1) &&
- echo "$at" | grep "+0000"
+ sed -ne "/^author /s/.*> //p" head1 >at &&
+ grep "+0000" at
'
test_expect_success 'am into an unborn branch' '
+ git rev-parse first^{tree} >expected &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
rm -fr subdir &&
- mkdir -p subdir &&
+ mkdir subdir &&
git format-patch --numbered-files -o subdir -1 first &&
(
cd subdir &&
git init &&
git am 1
) &&
- result=$(
- cd subdir && git rev-parse HEAD^{tree}
+ (
+ cd subdir &&
+ git rev-parse HEAD^{tree} >../actual
) &&
- test "z$result" = "z$(git rev-parse first^{tree})"
+ test_cmp expected actual
'
test_expect_success 'am newline in subject' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
test_tick &&
- sed -e "s/second/second \\\n foo/" patch1 > patchnl &&
- git am < patchnl > output.out 2>&1 &&
+ sed -e "s/second/second \\\n foo/" patch1 >patchnl &&
+ git am <patchnl >output.out 2>&1 &&
grep "^Applying: second \\\n foo$" output.out
'
test_expect_success 'am -q is quiet' '
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
git checkout first &&
test_tick &&
- git am -q < patch1 > output.out 2>&1 &&
+ git am -q <patch1 >output.out 2>&1 &&
! test -s output.out
'
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 70856d0..36255d6 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -4,237 +4,391 @@
#
test_description='git rerere
+
+! [fifth] version1
+ ! [first] first
+ ! [fourth] version1
+ ! [master] initial
+ ! [second] prefer first over second
+ ! [third] version2
+------
+ + [third] version2
++ [fifth] version1
+ + [fourth] version1
++ + + [third^] third
+ - [second] prefer first over second
+ + + [first] first
+ + [second^] second
+++++++ [master] initial
'
. ./test-lib.sh
-test_expect_success 'setup' "
- cat > a1 <<- EOF &&
+test_expect_success 'setup' '
+ cat >a1 <<-\EOF &&
Some title
==========
- Whether 'tis nobler in the mind to suffer
+ Whether '\''tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them? To die: to sleep;
No more; and by a sleep to say we end
The heart-ache and the thousand natural shocks
- That flesh is heir to, 'tis a consummation
- Devoutly to be wish'd.
+ That flesh is heir to, '\''tis a consummation
+ Devoutly to be wish'\''d.
EOF
git add a1 &&
+ test_tick &&
git commit -q -a -m initial &&
- git checkout -b first &&
- cat >> a1 <<- EOF &&
+ cat >>a1 <<-\EOF &&
Some title
==========
To die, to sleep;
- To sleep: perchance to dream: ay, there's the rub;
+ To sleep: perchance to dream: ay, there'\''s the rub;
For in that sleep of death what dreams may come
When we have shuffled off this mortal coil,
- Must give us pause: there's the respect
+ Must give us pause: there'\''s the respect
That makes calamity of so long life;
EOF
+
+ git checkout -b first &&
+ test_tick &&
git commit -q -a -m first &&
git checkout -b second master &&
git show first:a1 |
- sed -e 's/To die, t/To die! T/' -e 's/Some title/Some Title/' > a1 &&
- echo '* END *' >>a1 &&
+ sed -e "s/To die, t/To die! T/" -e "s/Some title/Some Title/" >a1 &&
+ echo "* END *" >>a1 &&
+ test_tick &&
git commit -q -a -m second
-"
+'
test_expect_success 'nothing recorded without rerere' '
- (rm -rf .git/rr-cache; git config rerere.enabled false) &&
+ rm -rf .git/rr-cache &&
+ git config rerere.enabled false &&
test_must_fail git merge first &&
! test -d .git/rr-cache
'
-# activate rerere, old style
-test_expect_success 'conflicting merge' '
+test_expect_success 'activate rerere, old style (conflicting merge)' '
git reset --hard &&
mkdir .git/rr-cache &&
- git config --unset rerere.enabled &&
- test_must_fail git merge first
-'
+ test_might_fail git config --unset rerere.enabled &&
+ test_must_fail git merge first &&
-sha1=$(perl -pe 's/ .*//' .git/MERGE_RR)
-rr=.git/rr-cache/$sha1
-test_expect_success 'recorded preimage' "grep ^=======$ $rr/preimage"
+ sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
+ rr=.git/rr-cache/$sha1 &&
+ grep "^=======\$" $rr/preimage &&
+ ! test -f $rr/postimage &&
+ ! test -f $rr/thisimage
+'
test_expect_success 'rerere.enabled works, too' '
rm -rf .git/rr-cache &&
git config rerere.enabled true &&
git reset --hard &&
test_must_fail git merge first &&
+
+ sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
+ rr=.git/rr-cache/$sha1 &&
grep ^=======$ $rr/preimage
'
-test_expect_success 'no postimage or thisimage yet' \
- "test ! -f $rr/postimage -a ! -f $rr/thisimage"
+test_expect_success 'set up rr-cache' '
+ rm -rf .git/rr-cache &&
+ git config rerere.enabled true &&
+ git reset --hard &&
+ test_must_fail git merge first &&
+ sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
+ rr=.git/rr-cache/$sha1
+'
-test_expect_success 'preimage has right number of lines' '
+test_expect_success 'rr-cache looks sane' '
+ # no postimage or thisimage yet
+ ! test -f $rr/postimage &&
+ ! test -f $rr/thisimage &&
+ # preimage has right number of lines
cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
+ echo $cnt &&
test $cnt = 13
-
'
-git show first:a1 > a1
-
-cat > expect << EOF
---- a/a1
-+++ b/a1
-@@ -1,4 +1,4 @@
--Some Title
-+Some title
- ==========
- Whether 'tis nobler in the mind to suffer
- The slings and arrows of outrageous fortune,
-@@ -8,21 +8,11 @@
- The heart-ache and the thousand natural shocks
- That flesh is heir to, 'tis a consummation
- Devoutly to be wish'd.
--<<<<<<<
--Some Title
--==========
--To die! To sleep;
--=======
- Some title
- ==========
- To die, to sleep;
-->>>>>>>
- To sleep: perchance to dream: ay, there's the rub;
- For in that sleep of death what dreams may come
- When we have shuffled off this mortal coil,
- Must give us pause: there's the respect
- That makes calamity of so long life;
--<<<<<<<
--=======
--* END *
-->>>>>>>
-EOF
-git rerere diff > out
-
-test_expect_success 'rerere diff' 'test_cmp expect out'
-
-cat > expect << EOF
-a1
-EOF
-
-git rerere status > out
-
-test_expect_success 'rerere status' 'test_cmp expect out'
-
-test_expect_success 'commit succeeds' \
- "git commit -q -a -m 'prefer first over second'"
-
-test_expect_success 'recorded postimage' "test -f $rr/postimage"
-
-test_expect_success 'another conflicting merge' '
- git checkout -b third master &&
- git show second^:a1 | sed "s/To die: t/To die! T/" > a1 &&
- git commit -q -a -m third &&
- test_must_fail git pull . first
+test_expect_success 'rerere diff' '
+ git show first:a1 >a1 &&
+ cat >expect <<-\EOF &&
+ --- a/a1
+ +++ b/a1
+ @@ -1,4 +1,4 @@
+ -Some Title
+ +Some title
+ ==========
+ Whether '\''tis nobler in the mind to suffer
+ The slings and arrows of outrageous fortune,
+ @@ -8,21 +8,11 @@
+ The heart-ache and the thousand natural shocks
+ That flesh is heir to, '\''tis a consummation
+ Devoutly to be wish'\''d.
+ -<<<<<<<
+ -Some Title
+ -==========
+ -To die! To sleep;
+ -=======
+ Some title
+ ==========
+ To die, to sleep;
+ ->>>>>>>
+ To sleep: perchance to dream: ay, there'\''s the rub;
+ For in that sleep of death what dreams may come
+ When we have shuffled off this mortal coil,
+ Must give us pause: there'\''s the respect
+ That makes calamity of so long life;
+ -<<<<<<<
+ -=======
+ -* END *
+ ->>>>>>>
+ EOF
+ git rerere diff >out &&
+ test_cmp expect out
'
-git show first:a1 | sed 's/To die: t/To die! T/' > expect
-test_expect_success 'rerere kicked in' "! grep ^=======$ a1"
+test_expect_success 'rerere status' '
+ echo a1 >expect &&
+ git rerere status >out &&
+ test_cmp expect out
+'
-test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
+test_expect_success 'first postimage wins' '
+ git show first:a1 | sed "s/To die: t/To die! T/" >expect &&
-rm $rr/postimage
-echo "$sha1 a1" | perl -pe 'y/\012/\000/' > .git/MERGE_RR
+ git commit -q -a -m "prefer first over second" &&
+ test -f $rr/postimage &&
-test_expect_success 'rerere clear' 'git rerere clear'
+ oldmtimepost=$(test-chmtime -v -60 $rr/postimage | cut -f 1) &&
-test_expect_success 'clear removed the directory' "test ! -d $rr"
+ git checkout -b third master &&
+ git show second^:a1 | sed "s/To die: t/To die! T/" >a1 &&
+ git commit -q -a -m third &&
-mkdir $rr
-echo Hello > $rr/preimage
-echo World > $rr/postimage
+ test_must_fail git pull . first &&
+ # rerere kicked in
+ ! grep "^=======\$" a1 &&
+ test_cmp expect a1
+'
-sha2=4000000000000000000000000000000000000000
-rr2=.git/rr-cache/$sha2
-mkdir $rr2
-echo Hello > $rr2/preimage
+test_expect_success 'rerere updates postimage timestamp' '
+ newmtimepost=$(test-chmtime -v +0 $rr/postimage | cut -f 1) &&
+ test $oldmtimepost -lt $newmtimepost
+'
-almost_15_days_ago=$((60-15*86400))
-just_over_15_days_ago=$((-1-15*86400))
-almost_60_days_ago=$((60-60*86400))
-just_over_60_days_ago=$((-1-60*86400))
+test_expect_success 'rerere clear' '
+ rm $rr/postimage &&
+ echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR &&
+ git rerere clear &&
+ ! test -d $rr
+'
-test-chmtime =$almost_60_days_ago $rr/preimage
-test-chmtime =$almost_15_days_ago $rr2/preimage
+test_expect_success 'set up for garbage collection tests' '
+ mkdir -p $rr &&
+ echo Hello >$rr/preimage &&
+ echo World >$rr/postimage &&
-test_expect_success 'garbage collection (part1)' 'git rerere gc'
+ sha2=4000000000000000000000000000000000000000 &&
+ rr2=.git/rr-cache/$sha2 &&
+ mkdir $rr2 &&
+ echo Hello >$rr2/preimage &&
-test_expect_success 'young records still live' \
- "test -f $rr/preimage && test -f $rr2/preimage"
+ almost_15_days_ago=$((60-15*86400)) &&
+ just_over_15_days_ago=$((-1-15*86400)) &&
+ almost_60_days_ago=$((60-60*86400)) &&
+ just_over_60_days_ago=$((-1-60*86400)) &&
-test-chmtime =$just_over_60_days_ago $rr/preimage
-test-chmtime =$just_over_15_days_ago $rr2/preimage
+ test-chmtime =$just_over_60_days_ago $rr/preimage &&
+ test-chmtime =$almost_60_days_ago $rr/postimage &&
+ test-chmtime =$almost_15_days_ago $rr2/preimage
+'
-test_expect_success 'garbage collection (part2)' 'git rerere gc'
+test_expect_success 'gc preserves young or recently used records' '
+ git rerere gc &&
+ test -f $rr/preimage &&
+ test -f $rr2/preimage
+'
-test_expect_success 'old records rest in peace' \
- "test ! -f $rr/preimage && test ! -f $rr2/preimage"
+test_expect_success 'old records rest in peace' '
+ test-chmtime =$just_over_60_days_ago $rr/postimage &&
+ test-chmtime =$just_over_15_days_ago $rr2/preimage &&
+ git rerere gc &&
+ ! test -f $rr/preimage &&
+ ! test -f $rr2/preimage
+'
-test_expect_success 'file2 added differently in two branches' '
+test_expect_success 'setup: file2 added differently in two branches' '
git reset --hard &&
+
git checkout -b fourth &&
- echo Hallo > file2 &&
+ echo Hallo >file2 &&
git add file2 &&
+ test_tick &&
git commit -m version1 &&
+
git checkout third &&
- echo Bello > file2 &&
+ echo Bello >file2 &&
git add file2 &&
+ test_tick &&
git commit -m version2 &&
+
test_must_fail git merge fourth &&
- echo Cello > file2 &&
+ echo Cello >file2 &&
git add file2 &&
git commit -m resolution
'
test_expect_success 'resolution was recorded properly' '
+ echo Cello >expected &&
+
git reset --hard HEAD~2 &&
git checkout -b fifth &&
- echo Hallo > file3 &&
+
+ echo Hallo >file3 &&
git add file3 &&
+ test_tick &&
git commit -m version1 &&
+
git checkout third &&
- echo Bello > file3 &&
+ echo Bello >file3 &&
git add file3 &&
+ test_tick &&
git commit -m version2 &&
git tag version2 &&
+
test_must_fail git merge fifth &&
- test Cello = "$(cat file3)" &&
- test 0 != $(git ls-files -u | wc -l)
+ test_cmp expected file3 &&
+ test_must_fail git update-index --refresh
'
test_expect_success 'rerere.autoupdate' '
- git config rerere.autoupdate true
+ git config rerere.autoupdate true &&
git reset --hard &&
git checkout version2 &&
test_must_fail git merge fifth &&
- test 0 = $(git ls-files -u | wc -l)
+ git update-index --refresh
'
test_expect_success 'merge --rerere-autoupdate' '
- git config --unset rerere.autoupdate
+ test_might_fail git config --unset rerere.autoupdate &&
git reset --hard &&
git checkout version2 &&
test_must_fail git merge --rerere-autoupdate fifth &&
- test 0 = $(git ls-files -u | wc -l)
+ git update-index --refresh
'
test_expect_success 'merge --no-rerere-autoupdate' '
- git config rerere.autoupdate true
+ headblob=$(git rev-parse version2:file3) &&
+ mergeblob=$(git rev-parse fifth:file3) &&
+ cat >expected <<-EOF &&
+ 100644 $headblob 2 file3
+ 100644 $mergeblob 3 file3
+ EOF
+
+ git config rerere.autoupdate true &&
git reset --hard &&
git checkout version2 &&
test_must_fail git merge --no-rerere-autoupdate fifth &&
- test 2 = $(git ls-files -u | wc -l)
+ git ls-files -u >actual &&
+ test_cmp expected actual
+'
+
+test_expect_success 'set up an unresolved merge' '
+ headblob=$(git rev-parse version2:file3) &&
+ mergeblob=$(git rev-parse fifth:file3) &&
+ cat >expected.unresolved <<-EOF &&
+ 100644 $headblob 2 file3
+ 100644 $mergeblob 3 file3
+ EOF
+
+ test_might_fail git config --unset rerere.autoupdate &&
+ git reset --hard &&
+ git checkout version2 &&
+ fifth=$(git rev-parse fifth) &&
+ echo "$fifth branch 'fifth' of ." |
+ git fmt-merge-msg >msg &&
+ ancestor=$(git merge-base version2 fifth) &&
+ test_must_fail git merge-recursive "$ancestor" -- HEAD fifth &&
+
+ git ls-files --stage >failedmerge &&
+ cp file3 file3.conflict &&
+
+ git ls-files -u >actual &&
+ test_cmp expected.unresolved actual
+'
+
+test_expect_success 'explicit rerere' '
+ test_might_fail git config --unset rerere.autoupdate &&
+ git rm -fr --cached . &&
+ git update-index --index-info <failedmerge &&
+ cp file3.conflict file3 &&
+ test_must_fail git update-index --refresh -q &&
+
+ git rerere &&
+ git ls-files -u >actual &&
+ test_cmp expected.unresolved actual
+'
+
+test_expect_success 'explicit rerere with autoupdate' '
+ git config rerere.autoupdate true &&
+ git rm -fr --cached . &&
+ git update-index --index-info <failedmerge &&
+ cp file3.conflict file3 &&
+ test_must_fail git update-index --refresh -q &&
+
+ git rerere &&
+ git update-index --refresh
+'
+
+test_expect_success 'explicit rerere --rerere-autoupdate overrides' '
+ git config rerere.autoupdate false &&
+ git rm -fr --cached . &&
+ git update-index --index-info <failedmerge &&
+ cp file3.conflict file3 &&
+ git rerere &&
+ git ls-files -u >actual1 &&
+
+ git rm -fr --cached . &&
+ git update-index --index-info <failedmerge &&
+ cp file3.conflict file3 &&
+ git rerere --rerere-autoupdate &&
+ git update-index --refresh &&
+
+ git rm -fr --cached . &&
+ git update-index --index-info <failedmerge &&
+ cp file3.conflict file3 &&
+ git rerere --rerere-autoupdate --no-rerere-autoupdate &&
+ git ls-files -u >actual2 &&
+
+ git rm -fr --cached . &&
+ git update-index --index-info <failedmerge &&
+ cp file3.conflict file3 &&
+ git rerere --rerere-autoupdate --no-rerere-autoupdate --rerere-autoupdate &&
+ git update-index --refresh &&
+
+ test_cmp expected.unresolved actual1 &&
+ test_cmp expected.unresolved actual2
+'
+
+test_expect_success 'rerere --no-no-rerere-autoupdate' '
+ git rm -fr --cached . &&
+ git update-index --index-info <failedmerge &&
+ cp file3.conflict file3 &&
+ test_must_fail git rerere --no-no-rerere-autoupdate 2>err &&
+ grep [Uu]sage err &&
+ test_must_fail git update-index --refresh
+'
+
+test_expect_success 'rerere -h' '
+ test_must_fail git rerere -h >help &&
+ grep [Uu]sage help
'
test_done
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 2230e60..2e51356 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -100,13 +100,11 @@ test_expect_success 'oneline' '
test_expect_success 'diff-filter=A' '
- actual=$(git log --pretty="format:%s" --diff-filter=A HEAD) &&
- expect=$(echo fifth ; echo fourth ; echo third ; echo initial) &&
- test "$actual" = "$expect" || {
- echo Oops
- echo "Actual: $actual"
- false
- }
+ git log --pretty="format:%s" --diff-filter=A HEAD > actual &&
+ git log --pretty="format:%s" --diff-filter A HEAD > actual-separate &&
+ printf "fifth\nfourth\nthird\ninitial" > expect &&
+ test_cmp expect actual &&
+ test_cmp expect actual-separate
'
@@ -203,6 +201,13 @@ test_expect_success 'log --grep' '
test_cmp expect actual
'
+test_expect_success 'log --grep option parsing' '
+ echo second >expect &&
+ git log -1 --pretty="tformat:%s" --grep sec >actual &&
+ test_cmp expect actual &&
+ test_must_fail git log -1 --pretty="tformat:%s" --grep
+'
+
test_expect_success 'log -i --grep' '
echo Second >expect &&
git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
@@ -436,5 +441,17 @@ test_expect_success 'log.decorate configuration' '
'
-test_done
+test_expect_success 'show added path under "--follow -M"' '
+ # This tests for a regression introduced in v1.7.2-rc0~103^2~2
+ test_create_repo regression &&
+ (
+ cd regression &&
+ test_commit needs-another-commit &&
+ test_commit foo.bar &&
+ git log -M --follow -p foo.bar.t &&
+ git log -M --follow --stat foo.bar.t &&
+ git log -M --follow --name-only foo.bar.t
+ )
+'
+test_done
diff --git a/t/t5001-archive-attr.sh b/t/t5001-archive-attr.sh
index 426b319..02d4d22 100755
--- a/t/t5001-archive-attr.sh
+++ b/t/t5001-archive-attr.sh
@@ -4,7 +4,7 @@ test_description='git archive attribute tests'
. ./test-lib.sh
-SUBSTFORMAT=%H%n
+SUBSTFORMAT='%H (%h)%n'
test_expect_exists() {
test_expect_success " $1 exists" "test -e $1"
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 319e389..0b489f5 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -4,6 +4,11 @@ test_description='pulling into void'
. ./test-lib.sh
+modify () {
+ sed -e "$1" <"$2" >"$2.x" &&
+ mv "$2.x" "$2"
+}
+
D=`pwd`
test_expect_success setup '
@@ -160,4 +165,61 @@ test_expect_success 'pull --rebase works on branch yet to be born' '
test_cmp expect actual
'
+test_expect_success 'setup for detecting upstreamed changes' '
+ mkdir src &&
+ (cd src &&
+ git init &&
+ printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
+ git add stuff &&
+ git commit -m "Initial revision"
+ ) &&
+ git clone src dst &&
+ (cd src &&
+ modify s/5/43/ stuff &&
+ git commit -a -m "5->43" &&
+ modify s/6/42/ stuff &&
+ git commit -a -m "Make it bigger"
+ ) &&
+ (cd dst &&
+ modify s/5/43/ stuff &&
+ git commit -a -m "Independent discovery of 5->43"
+ )
+'
+
+test_expect_success 'git pull --rebase detects upstreamed changes' '
+ (cd dst &&
+ git pull --rebase &&
+ test -z "$(git ls-files -u)"
+ )
+'
+
+test_expect_success 'setup for avoiding reapplying old patches' '
+ (cd dst &&
+ test_might_fail git rebase --abort &&
+ git reset --hard origin/master
+ ) &&
+ git clone --bare src src-replace.git &&
+ rm -rf src &&
+ mv src-replace.git src &&
+ (cd dst &&
+ modify s/2/22/ stuff &&
+ git commit -a -m "Change 2" &&
+ modify s/3/33/ stuff &&
+ git commit -a -m "Change 3" &&
+ modify s/4/44/ stuff &&
+ git commit -a -m "Change 4" &&
+ git push &&
+
+ modify s/44/55/ stuff &&
+ git commit --amend -a -m "Modified Change 4"
+ )
+'
+
+test_expect_success 'git pull --rebase does not reapply old patches' '
+ (cd dst &&
+ test_must_fail git pull --rebase &&
+ test 1 = $(find .git/rebase-apply -name "000*" | wc -l)
+ )
+'
+
test_done
diff --git a/t/t5525-fetch-tagopt.sh b/t/t5525-fetch-tagopt.sh
new file mode 100755
index 0000000..4fbf7a1
--- /dev/null
+++ b/t/t5525-fetch-tagopt.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+test_description='tagopt variable affects "git fetch" and is overridden by commandline.'
+
+. ./test-lib.sh
+
+setup_clone () {
+ git clone --mirror . $1 &&
+ git remote add remote_$1 $1 &&
+ (cd $1 &&
+ git tag tag_$1)
+}
+
+test_expect_success setup '
+ test_commit test &&
+ setup_clone one &&
+ git config remote.remote_one.tagopt --no-tags &&
+ setup_clone two &&
+ git config remote.remote_two.tagopt --tags
+ '
+
+test_expect_success "fetch with tagopt=--no-tags does not get tag" '
+ git fetch remote_one &&
+ test_must_fail git show-ref tag_one
+ '
+
+test_expect_success "fetch --tags with tagopt=--no-tags gets tag" '
+ git fetch --tags remote_one &&
+ git show-ref tag_one
+ '
+
+test_expect_success "fetch --no-tags with tagopt=--tags does not get tag" '
+ git fetch --no-tags remote_two &&
+ test_must_fail git show-ref tag_two
+ '
+
+test_expect_success "fetch with tagopt=--tags gets tag" '
+ git fetch remote_two &&
+ git show-ref tag_two
+ '
+test_done
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 8617965..987e0c8 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -176,8 +176,14 @@ test_expect_success 'clone respects global branch.autosetuprebase' '
test_expect_success 'respect url-encoding of file://' '
git init x+y &&
- test_must_fail git clone "file://$PWD/x+y" xy-url &&
- git clone "file://$PWD/x%2By" xy-url
+ git clone "file://$PWD/x+y" xy-url-1 &&
+ git clone "file://$PWD/x%2By" xy-url-2
+'
+
+test_expect_success 'do not query-string-decode + in URLs' '
+ rm -rf x+y &&
+ git init "x y" &&
+ test_must_fail git clone "file://$PWD/x+y" xy-no-plus
'
test_expect_success 'do not respect url-encoding of non-url path' '
diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh
index 0144d9e..62197a3 100755
--- a/t/t6010-merge-base.sh
+++ b/t/t6010-merge-base.sh
@@ -3,175 +3,231 @@
# Copyright (c) 2005 Junio C Hamano
#
-test_description='Merge base computation.
+test_description='Merge base and parent list computation.
'
. ./test-lib.sh
-T=$(git write-tree)
-
-M=1130000000
-Z=+0000
-
-GIT_COMMITTER_EMAIL=git@comm.iter.xz
-GIT_COMMITTER_NAME='C O Mmiter'
-GIT_AUTHOR_NAME='A U Thor'
-GIT_AUTHOR_EMAIL=git@au.thor.xz
-export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL
-
-doit() {
- OFFSET=$1; shift
- NAME=$1; shift
- PARENTS=
- for P
- do
- PARENTS="${PARENTS}-p $P "
- done
- GIT_COMMITTER_DATE="$(($M + $OFFSET)) $Z"
- GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE
- export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
- commit=$(echo $NAME | git commit-tree $T $PARENTS)
- echo $commit >.git/refs/tags/$NAME
- echo $commit
-}
-
-# E---D---C---B---A
-# \'-_ \ \
-# \ `---------G \
-# \ \
-# F----------------H
-
-# Setup...
-E=$(doit 5 E)
-D=$(doit 4 D $E)
-F=$(doit 6 F $E)
-C=$(doit 3 C $D)
-B=$(doit 2 B $C)
-A=$(doit 1 A $B)
-G=$(doit 7 G $B $E)
-H=$(doit 8 H $A $F)
-
-test_expect_success 'compute merge-base (single)' \
- 'MB=$(git merge-base G H) &&
- expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"'
-
-test_expect_success 'compute merge-base (all)' \
- 'MB=$(git merge-base --all G H) &&
- expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"'
-
-test_expect_success 'compute merge-base with show-branch' \
- 'MB=$(git show-branch --merge-base G H) &&
- expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/B"'
-
-# Setup for second test to demonstrate that relying on timestamps in a
-# distributed SCM to provide a _consistent_ partial ordering of commits
-# leads to insanity.
-#
-# Relative
-# Structure timestamps
-#
-# PL PR +4 +4
-# / \/ \ / \/ \
-# L2 C2 R2 +3 -1 +3
-# | | | | | |
-# L1 C1 R1 +2 -2 +2
-# | | | | | |
-# L0 C0 R0 +1 -3 +1
-# \ | / \ | /
-# S 0
-#
-# The left and right chains of commits can be of any length and complexity as
-# long as all of the timestamps are greater than that of S.
+test_expect_success 'setup' '
+ T=$(git write-tree) &&
-S=$(doit 0 S)
+ M=1130000000 &&
+ Z=+0000 &&
-C0=$(doit -3 C0 $S)
-C1=$(doit -2 C1 $C0)
-C2=$(doit -1 C2 $C1)
+ GIT_COMMITTER_EMAIL=git@comm.iter.xz &&
+ GIT_COMMITTER_NAME="C O Mmiter" &&
+ GIT_AUTHOR_NAME="A U Thor" &&
+ GIT_AUTHOR_EMAIL=git@au.thor.xz &&
+ export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL &&
-L0=$(doit 1 L0 $S)
-L1=$(doit 2 L1 $L0)
-L2=$(doit 3 L2 $L1)
+ doit() {
+ OFFSET=$1 &&
+ NAME=$2 &&
+ shift 2 &&
-R0=$(doit 1 R0 $S)
-R1=$(doit 2 R1 $R0)
-R2=$(doit 3 R2 $R1)
+ PARENTS= &&
+ for P
+ do
+ PARENTS="${PARENTS}-p $P "
+ done &&
-PL=$(doit 4 PL $L2 $C2)
-PR=$(doit 4 PR $C2 $R2)
+ GIT_COMMITTER_DATE="$(($M + $OFFSET)) $Z" &&
+ GIT_AUTHOR_DATE=$GIT_COMMITTER_DATE &&
+ export GIT_COMMITTER_DATE GIT_AUTHOR_DATE &&
-test_expect_success 'compute merge-base (single)' \
- 'MB=$(git merge-base PL PR) &&
- expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/C2"'
+ commit=$(echo $NAME | git commit-tree $T $PARENTS) &&
-test_expect_success 'compute merge-base (all)' \
- 'MB=$(git merge-base --all PL PR) &&
- expr "$(git name-rev "$MB")" : "[0-9a-f]* tags/C2"'
+ echo $commit >.git/refs/tags/$NAME &&
+ echo $commit
+ }
+'
-# Another set to demonstrate base between one commit and a merge
-# in the documentation.
-#
-# * C (MMC) * B (MMB) * A (MMA)
-# * o * o * o
-# * o * o * o
-# * o * o * o
-# * o | _______/
-# | |/
-# | * 1 (MM1)
-# | _______/
-# |/
-# * root (MMR)
+test_expect_success 'set up G and H' '
+ # E---D---C---B---A
+ # \"-_ \ \
+ # \ `---------G \
+ # \ \
+ # F----------------H
+ E=$(doit 5 E) &&
+ D=$(doit 4 D $E) &&
+ F=$(doit 6 F $E) &&
+ C=$(doit 3 C $D) &&
+ B=$(doit 2 B $C) &&
+ A=$(doit 1 A $B) &&
+ G=$(doit 7 G $B $E) &&
+ H=$(doit 8 H $A $F)
+'
+
+test_expect_success 'merge-base G H' '
+ git name-rev $B >expected &&
+
+ MB=$(git merge-base G H) &&
+ git name-rev "$MB" >actual.single &&
+
+ MB=$(git merge-base --all G H) &&
+ git name-rev "$MB" >actual.all &&
+
+ MB=$(git show-branch --merge-base G H) &&
+ git name-rev "$MB" >actual.sb &&
+
+ test_cmp expected actual.single &&
+ test_cmp expected actual.all &&
+ test_cmp expected actual.sb
+'
+test_expect_success 'merge-base/show-branch --independent' '
+ git name-rev "$H" >expected1 &&
+ git name-rev "$H" "$G" >expected2 &&
+
+ parents=$(git merge-base --independent H) &&
+ git name-rev $parents >actual1.mb &&
+ parents=$(git merge-base --independent A H G) &&
+ git name-rev $parents >actual2.mb &&
+
+ parents=$(git show-branch --independent H) &&
+ git name-rev $parents >actual1.sb &&
+ parents=$(git show-branch --independent A H G) &&
+ git name-rev $parents >actual2.sb &&
+
+ test_cmp expected1 actual1.mb &&
+ test_cmp expected2 actual2.mb &&
+ test_cmp expected1 actual1.sb &&
+ test_cmp expected2 actual2.sb
+'
+
+test_expect_success 'unsynchronized clocks' '
+ # This test is to demonstrate that relying on timestamps in a distributed
+ # SCM to provide a _consistent_ partial ordering of commits leads to
+ # insanity.
+ #
+ # Relative
+ # Structure timestamps
+ #
+ # PL PR +4 +4
+ # / \/ \ / \/ \
+ # L2 C2 R2 +3 -1 +3
+ # | | | | | |
+ # L1 C1 R1 +2 -2 +2
+ # | | | | | |
+ # L0 C0 R0 +1 -3 +1
+ # \ | / \ | /
+ # S 0
+ #
+ # The left and right chains of commits can be of any length and complexity as
+ # long as all of the timestamps are greater than that of S.
+
+ S=$(doit 0 S) &&
+
+ C0=$(doit -3 C0 $S) &&
+ C1=$(doit -2 C1 $C0) &&
+ C2=$(doit -1 C2 $C1) &&
+
+ L0=$(doit 1 L0 $S) &&
+ L1=$(doit 2 L1 $L0) &&
+ L2=$(doit 3 L2 $L1) &&
+
+ R0=$(doit 1 R0 $S) &&
+ R1=$(doit 2 R1 $R0) &&
+ R2=$(doit 3 R2 $R1) &&
+
+ PL=$(doit 4 PL $L2 $C2) &&
+ PR=$(doit 4 PR $C2 $R2)
+
+ git name-rev $C2 >expected &&
+
+ MB=$(git merge-base PL PR) &&
+ git name-rev "$MB" >actual.single &&
+
+ MB=$(git merge-base --all PL PR) &&
+ git name-rev "$MB" >actual.all &&
+
+ test_cmp expected actual.single &&
+ test_cmp expected actual.all
+'
+
+test_expect_success '--independent with unsynchronized clocks' '
+ IB=$(doit 0 IB) &&
+ I1=$(doit -10 I1 $IB) &&
+ I2=$(doit -9 I2 $I1) &&
+ I3=$(doit -8 I3 $I2) &&
+ I4=$(doit -7 I4 $I3) &&
+ I5=$(doit -6 I5 $I4) &&
+ I6=$(doit -5 I6 $I5) &&
+ I7=$(doit -4 I7 $I6) &&
+ I8=$(doit -3 I8 $I7) &&
+ IH=$(doit -2 IH $I8) &&
+
+ echo $IH >expected &&
+ git merge-base --independent IB IH >actual &&
+ test_cmp expected actual
+'
test_expect_success 'merge-base for octopus-step (setup)' '
- test_tick && git commit --allow-empty -m root && git tag MMR &&
- test_tick && git commit --allow-empty -m 1 && git tag MM1 &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m A && git tag MMA &&
+ # Another set to demonstrate base between one commit and a merge
+ # in the documentation.
+ #
+ # * C (MMC) * B (MMB) * A (MMA)
+ # * o * o * o
+ # * o * o * o
+ # * o * o * o
+ # * o | _______/
+ # | |/
+ # | * 1 (MM1)
+ # | _______/
+ # |/
+ # * root (MMR)
+
+ test_commit MMR &&
+ test_commit MM1 &&
+ test_commit MM-o &&
+ test_commit MM-p &&
+ test_commit MM-q &&
+ test_commit MMA &&
git checkout MM1 &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m B && git tag MMB &&
+ test_commit MM-r &&
+ test_commit MM-s &&
+ test_commit MM-t &&
+ test_commit MMB &&
git checkout MMR &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m C && git tag MMC
+ test_commit MM-u &&
+ test_commit MM-v &&
+ test_commit MM-w &&
+ test_commit MM-x &&
+ test_commit MMC
'
test_expect_success 'merge-base A B C' '
- MB=$(git merge-base --all MMA MMB MMC) &&
- MM1=$(git rev-parse --verify MM1) &&
- test "$MM1" = "$MB"
-'
+ git rev-parse --verify MM1 >expected &&
+ git rev-parse --verify MMR >expected.sb &&
-test_expect_success 'merge-base A B C using show-branch' '
- MB=$(git show-branch --merge-base MMA MMB MMC) &&
- MMR=$(git rev-parse --verify MMR) &&
- test "$MMR" = "$MB"
+ git merge-base --all MMA MMB MMC >actual &&
+ git merge-base --all --octopus MMA MMB MMC >actual.common &&
+ git show-branch --merge-base MMA MMB MMC >actual.sb &&
+
+ test_cmp expected actual &&
+ test_cmp expected.sb actual.common &&
+ test_cmp expected.sb actual.sb
'
-test_expect_success 'criss-cross merge-base for octopus-step (setup)' '
+test_expect_success 'criss-cross merge-base for octopus-step' '
git reset --hard MMR &&
- test_tick && git commit --allow-empty -m 1 && git tag CC1 &&
+ test_commit CC1 &&
git reset --hard E &&
- test_tick && git commit --allow-empty -m 2 && git tag CC2 &&
- test_tick && git merge -s ours CC1 &&
- test_tick && git commit --allow-empty -m o &&
- test_tick && git commit --allow-empty -m B && git tag CCB &&
+ test_commit CC2 &&
+ test_tick &&
+ git merge -s ours CC1 &&
+ test_commit CC-o &&
+ test_commit CCB &&
git reset --hard CC1 &&
- test_tick && git merge -s ours CC2 &&
- test_tick && git commit --allow-empty -m A && git tag CCA
-'
+ git merge -s ours CC2 &&
+ test_commit CCA &&
+
+ git rev-parse CC1 CC2 >expected &&
+ git merge-base --all CCB CCA^^ CCA^^2 >actual &&
-test_expect_success 'merge-base B A^^ A^^2' '
- MB0=$(git merge-base --all CCB CCA^^ CCA^^2 | sort) &&
- MB1=$(git rev-parse CC1 CC2 | sort) &&
- test "$MB0" = "$MB1"
+ sort expected >expected.sorted &&
+ sort actual >actual.sorted &&
+ test_cmp expected.sorted actual.sorted
'
test_done
diff --git a/t/t6018-rev-list-glob.sh b/t/t6018-rev-list-glob.sh
index 58428d9..fb8291c 100755
--- a/t/t6018-rev-list-glob.sh
+++ b/t/t6018-rev-list-glob.sh
@@ -123,6 +123,12 @@ test_expect_success 'rev-list --glob=refs/heads/subspace/*' '
'
+test_expect_success 'rev-list --glob refs/heads/subspace/*' '
+
+ compare rev-list "subspace/one subspace/two" "--glob refs/heads/subspace/*"
+
+'
+
test_expect_success 'rev-list --glob=heads/subspace/*' '
compare rev-list "subspace/one subspace/two" "--glob=heads/subspace/*"
diff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh
index e71c687..490d397 100755
--- a/t/t6020-merge-df.sh
+++ b/t/t6020-merge-df.sh
@@ -22,7 +22,7 @@ git commit -m "File: dir"'
test_expect_code 1 'Merge with d/f conflicts' 'git merge "merge msg" B master'
-test_expect_failure 'F/D conflict' '
+test_expect_success 'F/D conflict' '
git reset --hard &&
git checkout master &&
rm .git/index &&
diff --git a/t/t6031-merge-recursive.sh b/t/t6031-merge-recursive.sh
index 66167e3..1cd649e 100755
--- a/t/t6031-merge-recursive.sh
+++ b/t/t6031-merge-recursive.sh
@@ -53,4 +53,35 @@ test_expect_success FILEMODE 'verify executable bit on file' '
test -x file2
'
+test_expect_success 'merging with triple rename across D/F conflict' '
+ git reset --hard HEAD &&
+ git checkout -b main &&
+ git rm -rf . &&
+
+ echo "just a file" >sub1 &&
+ mkdir -p sub2 &&
+ echo content1 >sub2/file1 &&
+ echo content2 >sub2/file2 &&
+ echo content3 >sub2/file3 &&
+ mkdir simple &&
+ echo base >simple/bar &&
+ git add -A &&
+ test_tick &&
+ git commit -m base &&
+
+ git checkout -b other &&
+ echo more >>simple/bar &&
+ test_tick &&
+ git commit -a -m changesimplefile &&
+
+ git checkout main &&
+ git rm sub1 &&
+ git mv sub2 sub1 &&
+ test_tick &&
+ git commit -m changefiletodir &&
+
+ test_tick &&
+ git merge other
+'
+
test_done
diff --git a/t/t6035-merge-dir-to-symlink.sh b/t/t6035-merge-dir-to-symlink.sh
index 28e8f2a..92e02d5 100755
--- a/t/t6035-merge-dir-to-symlink.sh
+++ b/t/t6035-merge-dir-to-symlink.sh
@@ -42,7 +42,7 @@ test_expect_success SYMLINKS 'setup for merge test' '
git tag baseline
'
-test_expect_success SYMLINKS 'do not lose a/b-2/c/d in merge (resolve)' '
+test_expect_success SYMLINKS 'Handle D/F conflict, do not lose a/b-2/c/d in merge (resolve)' '
git reset --hard &&
git checkout baseline^0 &&
git merge -s resolve master &&
@@ -50,7 +50,7 @@ test_expect_success SYMLINKS 'do not lose a/b-2/c/d in merge (resolve)' '
test -f a/b-2/c/d
'
-test_expect_failure 'do not lose a/b-2/c/d in merge (recursive)' '
+test_expect_success SYMLINKS 'Handle D/F conflict, do not lose a/b-2/c/d in merge (recursive)' '
git reset --hard &&
git checkout baseline^0 &&
git merge -s recursive master &&
@@ -58,6 +58,54 @@ test_expect_failure 'do not lose a/b-2/c/d in merge (recursive)' '
test -f a/b-2/c/d
'
+test_expect_success SYMLINKS 'Handle F/D conflict, do not lose a/b-2/c/d in merge (resolve)' '
+ git reset --hard &&
+ git checkout master^0 &&
+ git merge -s resolve baseline^0 &&
+ test -h a/b &&
+ test -f a/b-2/c/d
+'
+
+test_expect_success SYMLINKS 'Handle F/D conflict, do not lose a/b-2/c/d in merge (recursive)' '
+ git reset --hard &&
+ git checkout master^0 &&
+ git merge -s recursive baseline^0 &&
+ test -h a/b &&
+ test -f a/b-2/c/d
+'
+
+test_expect_failure SYMLINKS 'do not lose untracked in merge (resolve)' '
+ git reset --hard &&
+ git checkout baseline^0 &&
+ >a/b/c/e &&
+ test_must_fail git merge -s resolve master &&
+ test -f a/b/c/e &&
+ test -f a/b-2/c/d
+'
+
+test_expect_success SYMLINKS 'do not lose untracked in merge (recursive)' '
+ git reset --hard &&
+ git checkout baseline^0 &&
+ >a/b/c/e &&
+ test_must_fail git merge -s recursive master &&
+ test -f a/b/c/e &&
+ test -f a/b-2/c/d
+'
+
+test_expect_success SYMLINKS 'do not lose modifications in merge (resolve)' '
+ git reset --hard &&
+ git checkout baseline^0 &&
+ echo more content >>a/b/c/d &&
+ test_must_fail git merge -s resolve master
+'
+
+test_expect_success SYMLINKS 'do not lose modifications in merge (recursive)' '
+ git reset --hard &&
+ git checkout baseline^0 &&
+ echo more content >>a/b/c/d &&
+ test_must_fail git merge -s recursive master
+'
+
test_expect_success SYMLINKS 'setup a merge where dir a/b-2 changed to symlink' '
git reset --hard &&
git checkout start^0 &&
@@ -68,7 +116,7 @@ test_expect_success SYMLINKS 'setup a merge where dir a/b-2 changed to symlink'
git tag test2
'
-test_expect_success SYMLINKS 'merge should not have conflicts (resolve)' '
+test_expect_success SYMLINKS 'merge should not have D/F conflicts (resolve)' '
git reset --hard &&
git checkout baseline^0 &&
git merge -s resolve test2 &&
@@ -76,7 +124,7 @@ test_expect_success SYMLINKS 'merge should not have conflicts (resolve)' '
test -f a/b/c/d
'
-test_expect_failure 'merge should not have conflicts (recursive)' '
+test_expect_success SYMLINKS 'merge should not have D/F conflicts (recursive)' '
git reset --hard &&
git checkout baseline^0 &&
git merge -s recursive test2 &&
@@ -84,4 +132,12 @@ test_expect_failure 'merge should not have conflicts (recursive)' '
test -f a/b/c/d
'
+test_expect_success SYMLINKS 'merge should not have F/D conflicts (recursive)' '
+ git reset --hard &&
+ git checkout -b foo test2 &&
+ git merge -s recursive baseline^0 &&
+ test -h a/b-2 &&
+ test -f a/b/c/d
+'
+
test_done
diff --git a/t/t6037-merge-ours-theirs.sh b/t/t6037-merge-ours-theirs.sh
index 8ab3d61..2cf42c7 100755
--- a/t/t6037-merge-ours-theirs.sh
+++ b/t/t6037-merge-ours-theirs.sh
@@ -58,7 +58,7 @@ test_expect_success 'pull with -X' '
git reset --hard master && git pull -s recursive -X ours . side &&
git reset --hard master && git pull -s recursive -Xtheirs . side &&
git reset --hard master && git pull -s recursive -X theirs . side &&
- git reset --hard master && ! git pull -s recursive -X bork . side
+ git reset --hard master && test_must_fail git pull -s recursive -X bork . side
'
test_done
diff --git a/t/t6038-merge-text-auto.sh b/t/t6038-merge-text-auto.sh
new file mode 100755
index 0000000..52d0dc4
--- /dev/null
+++ b/t/t6038-merge-text-auto.sh
@@ -0,0 +1,189 @@
+#!/bin/sh
+
+test_description='CRLF merge conflict across text=auto change
+
+* [master] remove .gitattributes
+ ! [side] add line from b
+--
+ + [side] add line from b
+* [master] remove .gitattributes
+* [master^] add line from a
+* [master~2] normalize file
+*+ [side^] Initial
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ git config core.autocrlf false &&
+
+ echo first line | append_cr >file &&
+ echo first line >control_file &&
+ echo only line >inert_file &&
+
+ git add file control_file inert_file &&
+ test_tick &&
+ git commit -m "Initial" &&
+ git tag initial &&
+ git branch side &&
+
+ echo "* text=auto" >.gitattributes &&
+ touch file &&
+ git add .gitattributes file &&
+ test_tick &&
+ git commit -m "normalize file" &&
+
+ echo same line | append_cr >>file &&
+ echo same line >>control_file &&
+ git add file control_file &&
+ test_tick &&
+ git commit -m "add line from a" &&
+ git tag a &&
+
+ git rm .gitattributes &&
+ rm file &&
+ git checkout file &&
+ test_tick &&
+ git commit -m "remove .gitattributes" &&
+ git tag c &&
+
+ git checkout side &&
+ echo same line | append_cr >>file &&
+ echo same line >>control_file &&
+ git add file control_file &&
+ test_tick &&
+ git commit -m "add line from b" &&
+ git tag b &&
+
+ git checkout master
+'
+
+test_expect_success 'set up fuzz_conflict() helper' '
+ fuzz_conflict() {
+ sed -e "s/^\([<>=]......\) .*/\1/" "$@"
+ }
+'
+
+test_expect_success 'Merge after setting text=auto' '
+ cat <<-\EOF >expected &&
+ first line
+ same line
+ EOF
+
+ git config merge.renormalize true &&
+ git rm -fr . &&
+ rm -f .gitattributes &&
+ git reset --hard a &&
+ git merge b &&
+ test_cmp expected file
+'
+
+test_expect_success 'Merge addition of text=auto' '
+ cat <<-\EOF >expected &&
+ first line
+ same line
+ EOF
+
+ git config merge.renormalize true &&
+ git rm -fr . &&
+ rm -f .gitattributes &&
+ git reset --hard b &&
+ git merge a &&
+ test_cmp expected file
+'
+
+test_expect_success 'Detect CRLF/LF conflict after setting text=auto' '
+ q_to_cr <<-\EOF >expected &&
+ <<<<<<<
+ first line
+ same line
+ =======
+ first lineQ
+ same lineQ
+ >>>>>>>
+ EOF
+
+ git config merge.renormalize false &&
+ rm -f .gitattributes &&
+ git reset --hard a &&
+ test_must_fail git merge b &&
+ fuzz_conflict file >file.fuzzy &&
+ test_cmp expected file.fuzzy
+'
+
+test_expect_success 'Detect LF/CRLF conflict from addition of text=auto' '
+ q_to_cr <<-\EOF >expected &&
+ <<<<<<<
+ first lineQ
+ same lineQ
+ =======
+ first line
+ same line
+ >>>>>>>
+ EOF
+
+ git config merge.renormalize false &&
+ rm -f .gitattributes &&
+ git reset --hard b &&
+ test_must_fail git merge a &&
+ fuzz_conflict file >file.fuzzy &&
+ test_cmp expected file.fuzzy
+'
+
+test_expect_failure 'checkout -m after setting text=auto' '
+ cat <<-\EOF >expected &&
+ first line
+ same line
+ EOF
+
+ git config merge.renormalize true &&
+ git rm -fr . &&
+ rm -f .gitattributes &&
+ git reset --hard initial &&
+ git checkout a -- . &&
+ git checkout -m b &&
+ test_cmp expected file
+'
+
+test_expect_failure 'checkout -m addition of text=auto' '
+ cat <<-\EOF >expected &&
+ first line
+ same line
+ EOF
+
+ git config merge.renormalize true &&
+ git rm -fr . &&
+ rm -f .gitattributes file &&
+ git reset --hard initial &&
+ git checkout b -- . &&
+ git checkout -m a &&
+ test_cmp expected file
+'
+
+test_expect_failure 'cherry-pick patch from after text=auto was added' '
+ append_cr <<-\EOF >expected &&
+ first line
+ same line
+ EOF
+
+ git config merge.renormalize true &&
+ git rm -fr . &&
+ git reset --hard b &&
+ test_must_fail git cherry-pick a >err 2>&1 &&
+ grep "[Nn]othing added" err &&
+ test_cmp expected file
+'
+
+test_expect_success 'Test delete/normalize conflict' '
+ git checkout -f side &&
+ git rm -fr . &&
+ rm -f .gitattributes &&
+ git reset --hard initial &&
+ git rm file &&
+ git commit -m "remove file" &&
+ git checkout master &&
+ git reset --hard a^ &&
+ git merge side
+'
+
+test_done
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index 4185b7c..dd917d7 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -209,7 +209,7 @@ test_expect_success 'fetch branch with replacement' '
test_expect_success 'bisect and replacements' '
git bisect start $HASH7 $HASH1 &&
- test "$S" = "$(git rev-parse --verify HEAD)" &&
+ test "$PARA3" = "$(git rev-parse --verify HEAD)" &&
git bisect reset &&
GIT_NO_REPLACE_OBJECTS=1 git bisect start $HASH7 $HASH1 &&
test "$HASH4" = "$(git rev-parse --verify HEAD)" &&
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 42f8ece..71f6cad 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -70,14 +70,13 @@ test_expect_success setup '
i=$(($i+1))
done &&
- git show-branch
-'
+ git show-branch &&
-cat >expected <<\EOF
-Merge branch 'left'
-EOF
+ apos="'\''"
+'
-test_expect_success 'merge-msg test #1' '
+test_expect_success 'message for merging local branch' '
+ echo "Merge branch ${apos}left${apos}" >expected &&
git checkout master &&
git fetch . left &&
@@ -86,11 +85,8 @@ test_expect_success 'merge-msg test #1' '
test_cmp expected actual
'
-cat >expected <<EOF
-Merge branch 'left' of $(pwd)
-EOF
-
-test_expect_success 'merge-msg test #2' '
+test_expect_success 'message for merging external branch' '
+ echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
git checkout master &&
git fetch "$(pwd)" left &&
@@ -99,139 +95,140 @@ test_expect_success 'merge-msg test #2' '
test_cmp expected actual
'
-cat >expected <<\EOF
-Merge branch 'left'
-
-* left:
- Left #5
- Left #4
- Left #3
- Common #2
- Common #1
-EOF
+test_expect_success '[merge] summary/log configuration' '
+ cat >expected <<-EOF &&
+ Merge branch ${apos}left${apos}
-test_expect_success 'merge-msg test #3-1' '
+ * left:
+ Left #5
+ Left #4
+ Left #3
+ Common #2
+ Common #1
+ EOF
- git config --unset-all merge.log
- git config --unset-all merge.summary
git config merge.log true &&
+ test_might_fail git config --unset-all merge.summary &&
git checkout master &&
test_tick &&
git fetch . left &&
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- test_cmp expected actual
-'
-
-test_expect_success 'merge-msg test #3-2' '
+ git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary true &&
git checkout master &&
test_tick &&
git fetch . left &&
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- test_cmp expected actual
-'
-
-cat >expected <<\EOF
-Merge branches 'left' and 'right'
+ git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
-* left:
- Left #5
- Left #4
- Left #3
- Common #2
- Common #1
+ test_cmp expected actual1 &&
+ test_cmp expected actual2
+'
-* right:
- Right #5
- Right #4
- Right #3
- Common #2
- Common #1
-EOF
+test_expect_success 'fmt-merge-msg -m' '
+ echo "Sync with left" >expected &&
+ cat >expected.log <<-EOF &&
+ Sync with left
+
+ * ${apos}left${apos} of $(pwd):
+ Left #5
+ Left #4
+ Left #3
+ Common #2
+ Common #1
+ EOF
+
+ test_might_fail git config --unset merge.log &&
+ test_might_fail git config --unset merge.summary &&
+ git checkout master &&
+ git fetch "$(pwd)" left &&
+ git fmt-merge-msg -m "Sync with left" <.git/FETCH_HEAD >actual &&
+ git fmt-merge-msg --log -m "Sync with left" \
+ <.git/FETCH_HEAD >actual.log &&
+ git config merge.log true &&
+ git fmt-merge-msg -m "Sync with left" \
+ <.git/FETCH_HEAD >actual.log-config &&
+ git fmt-merge-msg --no-log -m "Sync with left" \
+ <.git/FETCH_HEAD >actual.nolog &&
+
+ test_cmp expected actual &&
+ test_cmp expected.log actual.log &&
+ test_cmp expected.log actual.log-config &&
+ test_cmp expected actual.nolog
+'
-test_expect_success 'merge-msg test #4-1' '
+test_expect_success 'setup: expected shortlog for two branches' '
+ cat >expected <<-EOF
+ Merge branches ${apos}left${apos} and ${apos}right${apos}
+
+ * left:
+ Left #5
+ Left #4
+ Left #3
+ Common #2
+ Common #1
+
+ * right:
+ Right #5
+ Right #4
+ Right #3
+ Common #2
+ Common #1
+ EOF
+'
- git config --unset-all merge.log
- git config --unset-all merge.summary
+test_expect_success 'shortlog for two branches' '
git config merge.log true &&
-
+ test_might_fail git config --unset-all merge.summary &&
git checkout master &&
test_tick &&
git fetch . left right &&
+ git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- test_cmp expected actual
-'
-
-test_expect_success 'merge-msg test #4-2' '
-
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary true &&
-
git checkout master &&
test_tick &&
git fetch . left right &&
+ git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- test_cmp expected actual
-'
-
-test_expect_success 'merge-msg test #5-1' '
-
- git config --unset-all merge.log
- git config --unset-all merge.summary
git config merge.log yes &&
-
+ test_might_fail git config --unset-all merge.summary &&
git checkout master &&
test_tick &&
git fetch . left right &&
+ git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- test_cmp expected actual
-'
-
-test_expect_success 'merge-msg test #5-2' '
-
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary yes &&
-
git checkout master &&
test_tick &&
git fetch . left right &&
+ git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
- git fmt-merge-msg <.git/FETCH_HEAD >actual &&
- test_cmp expected actual
+ test_cmp expected actual1 &&
+ test_cmp expected actual2 &&
+ test_cmp expected actual3 &&
+ test_cmp expected actual4
'
test_expect_success 'merge-msg -F' '
-
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary yes &&
-
git checkout master &&
test_tick &&
git fetch . left right &&
-
git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
test_cmp expected actual
'
test_expect_success 'merge-msg -F in subdirectory' '
-
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary yes &&
-
git checkout master &&
test_tick &&
git fetch . left right &&
@@ -245,11 +242,11 @@ test_expect_success 'merge-msg -F in subdirectory' '
'
test_expect_success 'merge-msg with nothing to merge' '
-
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary yes &&
+ >empty &&
+
(
cd remote &&
git checkout -b unrelated &&
@@ -258,22 +255,20 @@ test_expect_success 'merge-msg with nothing to merge' '
git fmt-merge-msg <.git/FETCH_HEAD >../actual
) &&
- test_cmp /dev/null actual
+ test_cmp empty actual
'
-cat >expected <<\EOF
-Merge tag 'tag-r3'
-
-* tag 'tag-r3':
- Right #3
- Common #2
- Common #1
-EOF
-
test_expect_success 'merge-msg tag' '
+ cat >expected <<-EOF &&
+ Merge tag ${apos}tag-r3${apos}
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ * tag ${apos}tag-r3${apos}:
+ Right #3
+ Common #2
+ Common #1
+ EOF
+
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary yes &&
git checkout master &&
@@ -284,26 +279,24 @@ test_expect_success 'merge-msg tag' '
test_cmp expected actual
'
-cat >expected <<\EOF
-Merge tags 'tag-r3' and 'tag-l5'
-
-* tag 'tag-r3':
- Right #3
- Common #2
- Common #1
-
-* tag 'tag-l5':
- Left #5
- Left #4
- Left #3
- Common #2
- Common #1
-EOF
-
test_expect_success 'merge-msg two tags' '
-
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ cat >expected <<-EOF &&
+ Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
+
+ * tag ${apos}tag-r3${apos}:
+ Right #3
+ Common #2
+ Common #1
+
+ * tag ${apos}tag-l5${apos}:
+ Left #5
+ Left #4
+ Left #3
+ Common #2
+ Common #1
+ EOF
+
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary yes &&
git checkout master &&
@@ -314,26 +307,24 @@ test_expect_success 'merge-msg two tags' '
test_cmp expected actual
'
-cat >expected <<\EOF
-Merge branch 'left', tag 'tag-r3'
-
-* tag 'tag-r3':
- Right #3
- Common #2
- Common #1
-
-* left:
- Left #5
- Left #4
- Left #3
- Common #2
- Common #1
-EOF
-
test_expect_success 'merge-msg tag and branch' '
-
- git config --unset-all merge.log
- git config --unset-all merge.summary
+ cat >expected <<-EOF &&
+ Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
+
+ * tag ${apos}tag-r3${apos}:
+ Right #3
+ Common #2
+ Common #1
+
+ * left:
+ Left #5
+ Left #4
+ Left #3
+ Common #2
+ Common #1
+ EOF
+
+ test_might_fail git config --unset-all merge.log &&
git config merge.summary yes &&
git checkout master &&
@@ -344,26 +335,27 @@ test_expect_success 'merge-msg tag and branch' '
test_cmp expected actual
'
-cat >expected <<\EOF
-Merge branch 'long'
-
-* long: (35 commits)
-EOF
-
test_expect_success 'merge-msg lots of commits' '
+ {
+ cat <<-EOF &&
+ Merge branch ${apos}long${apos}
+
+ * long: (35 commits)
+ EOF
+
+ i=29 &&
+ while test $i -gt 9
+ do
+ echo " $i" &&
+ i=$(($i-1))
+ done &&
+ echo " ..."
+ } >expected &&
git checkout master &&
test_tick &&
git fetch . long &&
- i=29 &&
- while test $i -gt 9
- do
- echo " $i" &&
- i=$(($i-1))
- done >>expected &&
- echo " ..." >>expected
-
git fmt-merge-msg <.git/FETCH_HEAD >actual &&
test_cmp expected actual
'
diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh
index 71d3cef..fb744e3 100755
--- a/t/t7006-pager.sh
+++ b/t/t7006-pager.sh
@@ -58,6 +58,21 @@ test_expect_success TTY 'some commands use a pager' '
test -e paginated.out
'
+test_expect_failure TTY 'pager runs from subdir' '
+ echo subdir/paginated.out >expected &&
+ mkdir -p subdir &&
+ rm -f paginated.out subdir/paginated.out &&
+ (
+ cd subdir &&
+ test_terminal git log
+ ) &&
+ {
+ ls paginated.out subdir/paginated.out ||
+ :
+ } >actual &&
+ test_cmp expected actual
+'
+
test_expect_success TTY 'some commands do not use a pager' '
rm -f paginated.out ||
cleanup_fail &&
@@ -106,6 +121,45 @@ test_expect_success TTY 'no pager with --no-pager' '
! test -e paginated.out
'
+test_expect_success TTY 'configuration can disable pager' '
+ rm -f paginated.out &&
+ test_might_fail git config --unset pager.grep &&
+ test_terminal git grep initial &&
+ test -e paginated.out &&
+
+ rm -f paginated.out &&
+ git config pager.grep false &&
+ test_when_finished "git config --unset pager.grep" &&
+ test_terminal git grep initial &&
+ ! test -e paginated.out
+'
+
+test_expect_success TTY 'git config uses a pager if configured to' '
+ rm -f paginated.out &&
+ git config pager.config true &&
+ test_when_finished "git config --unset pager.config" &&
+ test_terminal git config --list &&
+ test -e paginated.out
+'
+
+test_expect_success TTY 'configuration can enable pager (from subdir)' '
+ rm -f paginated.out &&
+ mkdir -p subdir &&
+ git config pager.bundle true &&
+ test_when_finished "git config --unset pager.bundle" &&
+
+ git bundle create test.bundle --all &&
+ rm -f paginated.out subdir/paginated.out &&
+ (
+ cd subdir &&
+ test_terminal git bundle unbundle ../test.bundle
+ ) &&
+ {
+ test -e paginated.out ||
+ test -e subdir/paginated.out
+ }
+'
+
# A colored commit log will begin with an appropriate ANSI escape
# for the first color; the text "commit" comes later.
colorful() {
@@ -369,4 +423,16 @@ test_GIT_PAGER_overrides expect_success test_must_fail 'git -p'
test_doesnt_paginate expect_failure test_must_fail 'git -p nonsense'
+test_pager_choices 'git shortlog'
+test_expect_success 'setup: configure shortlog not to paginate' '
+ git config pager.shortlog false
+'
+test_doesnt_paginate expect_success 'git shortlog'
+test_no_local_config_subdir expect_success 'git shortlog'
+test_default_pager expect_success 'git -p shortlog'
+test_core_pager_subdir expect_success 'git -p shortlog'
+
+test_core_pager_subdir expect_success test_must_fail \
+ 'git -p apply </dev/null'
+
test_done
diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh
index eb8ca88..c0f9f3f 100755
--- a/t/t7008-grep-binary.sh
+++ b/t/t7008-grep-binary.sh
@@ -61,7 +61,7 @@ test_expect_success 'git grep -Fi iLE a' '
# This test actually passes on platforms where regexec() supports the
# flag REG_STARTEND.
-test_expect_failure 'git grep ile a' '
+test_expect_success 'git grep ile a' '
git grep ile a
'
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index fe8abf6..7dbbea1 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -437,4 +437,20 @@ test_expect_success 'force removal of nested git work tree' '
! test -d bar
'
+test_expect_success 'git clean -e' '
+ rm -fr repo &&
+ mkdir repo &&
+ (
+ cd repo &&
+ git init &&
+ touch 1 2 3 known &&
+ git add known &&
+ git clean -f -e 1 -e 2 &&
+ test -e 1 &&
+ test -e 2 &&
+ ! (test -e 3) &&
+ test -e known
+ )
+'
+
test_done
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
index 7538756..02522f9 100755
--- a/t/t7403-submodule-sync.sh
+++ b/t/t7403-submodule-sync.sh
@@ -14,7 +14,7 @@ test_expect_success setup '
echo file > file &&
git add file &&
test_tick &&
- git commit -m upstream
+ git commit -m upstream &&
git clone . super &&
git clone super submodule &&
(cd super &&
@@ -42,7 +42,7 @@ test_expect_success 'change submodule url' '
) &&
mv submodule moved-submodule &&
(cd super &&
- git config -f .gitmodules submodule.submodule.url ../moved-submodule
+ git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
test_tick &&
git commit -a -m moved-submodule
)
@@ -58,6 +58,9 @@ test_expect_success '"git submodule sync" should update submodule URLs' '
(cd super-clone/submodule &&
git checkout master &&
git pull
+ ) &&
+ (cd super-clone &&
+ test -d "$(git config submodule.submodule.url)"
)
'
diff --git a/t/t7405-submodule-merge.sh b/t/t7405-submodule-merge.sh
index 4a7b893..7e2e258 100755
--- a/t/t7405-submodule-merge.sh
+++ b/t/t7405-submodule-merge.sh
@@ -54,21 +54,132 @@ test_expect_success setup '
git merge -s ours a
'
-test_expect_success 'merging with modify/modify conflict' '
+# History setup
+#
+# b
+# / \
+# a d
+# \ /
+# 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
+# b in the main repository.
+test_expect_success 'setup for merge search' '
+ mkdir merge-search &&
+ (cd merge-search &&
+ git init &&
+ mkdir sub &&
+ (cd sub &&
+ git init &&
+ echo "file-a" > file-a &&
+ git add file-a &&
+ git commit -m "sub-a" &&
+ git branch sub-a) &&
+ git add sub &&
+ git commit -m "a" &&
+ git branch a &&
+
+ git checkout -b b &&
+ (cd sub &&
+ git checkout -b sub-b &&
+ echo "file-b" > file-b &&
+ git add file-b &&
+ git commit -m "sub-b") &&
+ git commit -a -m "b" &&
+
+ git checkout -b c a &&
+ (cd sub &&
+ git checkout -b sub-c sub-a &&
+ echo "file-c" > file-c &&
+ git add file-c &&
+ git commit -m "sub-c") &&
+ git commit -a -m "c" &&
- git checkout -b test1 a &&
- test_must_fail git merge b &&
- test -f .git/MERGE_MSG &&
- git diff &&
- test -n "$(git ls-files -u)"
+ git checkout -b d a &&
+ (cd sub &&
+ git checkout -b sub-d sub-b &&
+ git merge sub-c) &&
+ git commit -a -m "d" &&
+ git branch test b)
'
-test_expect_success 'merging with a modify/modify conflict between merge bases' '
+test_expect_success 'merge with one side as a fast-forward of the other' '
+ (cd merge-search &&
+ git checkout -b test-forward b &&
+ git merge d &&
+ git ls-tree test-forward sub | cut -f1 | cut -f3 -d" " > actual &&
+ (cd sub &&
+ git rev-parse sub-d > ../expect) &&
+ test_cmp actual expect)
+'
+test_expect_success 'merging should conflict for non fast-forward' '
+ (cd merge-search &&
+ git checkout -b test-nonforward b &&
+ (cd sub &&
+ git rev-parse sub-d > ../expect) &&
+ test_must_fail git merge c 2> actual &&
+ grep $(cat expect) actual > /dev/null &&
+ git reset --hard)
+'
+
+test_expect_success 'merging should fail for ambiguous common parent' '
+ (cd merge-search &&
+ git checkout -b test-ambiguous b &&
+ (cd sub &&
+ git checkout -b ambiguous sub-b &&
+ git merge sub-c &&
+ git rev-parse sub-d > ../expect1 &&
+ git rev-parse ambiguous > ../expect2) &&
+ test_must_fail git merge c 2> actual &&
+ grep $(cat expect1) actual > /dev/null &&
+ grep $(cat expect2) actual > /dev/null &&
+ git reset --hard)
+'
+
+# in a situation like this
+#
+# submodule tree:
+#
+# sub-a --- sub-b --- sub-d
+#
+# main tree:
+#
+# e (sub-a)
+# /
+# bb (sub-b)
+# \
+# f (sub-d)
+#
+# A merge between e and f should fail because one of the submodule
+# commits (sub-a) does not descend from the submodule merge-base (sub-b).
+#
+test_expect_success 'merging should fail for changes that are backwards' '
+ (cd merge-search &&
+ git checkout -b bb a &&
+ (cd sub &&
+ git checkout sub-b) &&
+ git commit -a -m "bb" &&
+
+ git checkout -b e bb &&
+ (cd sub &&
+ git checkout sub-a) &&
+ git commit -a -m "e" &&
+
+ git checkout -b f bb &&
+ (cd sub &&
+ git checkout sub-d) &&
+ git commit -a -m "f" &&
+
+ git checkout -b test-backward e &&
+ test_must_fail git merge f)
+'
+
+test_expect_success 'merging with a modify/modify conflict between merge bases' '
git reset --hard HEAD &&
git checkout -b test2 c &&
git merge d
-
'
test_done
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 1382a8e..bfb4975 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -25,7 +25,7 @@ test_expect_success 'setup a submodule tree' '
echo file > file &&
git add file &&
test_tick &&
- git commit -m upstream
+ git commit -m upstream &&
git clone . super &&
git clone super submodule &&
git clone super rebasing &&
diff --git a/t/t7407-submodule-foreach.sh b/t/t7407-submodule-foreach.sh
index db9365b..905a8ba 100755
--- a/t/t7407-submodule-foreach.sh
+++ b/t/t7407-submodule-foreach.sh
@@ -16,7 +16,7 @@ test_expect_success 'setup a submodule tree' '
echo file > file &&
git add file &&
test_tick &&
- git commit -m upstream
+ git commit -m upstream &&
git clone . super &&
git clone super submodule &&
(
@@ -30,7 +30,7 @@ test_expect_success 'setup a submodule tree' '
submodule.sub2 submodule.foo2 &&
git config -f .gitmodules --rename-section \
submodule.sub3 submodule.foo3 &&
- git add .gitmodules
+ git add .gitmodules &&
test_tick &&
git commit -m "submodules" &&
git submodule init sub1 &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index ee0e573..18b07d9 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -808,24 +808,38 @@ test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository'
(exit $status)
'
+(cd sm && echo > bar && git add bar && git commit -q -m 'Add bar' && cd .. && git add sm)
+new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
+touch .gitmodules
+
cat > expect << EOF
# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# modified: sm
+#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: dir1/modified
#
+# Submodule changes to be committed:
+#
+# * sm $head...$new_head (1):
+# > Add bar
+#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
+# .gitmodules
# dir1/untracked
# dir2/modified
# dir2/untracked
# expect
# output
# untracked
-no changes added to commit (use "git add" and/or "git commit -a")
EOF
test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
@@ -834,19 +848,89 @@ test_expect_success '--ignore-submodules=untracked suppresses submodules with un
test_cmp expect output
'
+test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
+ git config diff.ignoreSubmodules dirty &&
+ git status >output &&
+ test_cmp expect output &&
+ git config --add -f .gitmodules submodule.subname.ignore untracked &&
+ git config --add -f .gitmodules submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config -f .gitmodules --remove-section submodule.subname &&
+ git config --unset diff.ignoreSubmodules
+'
+
+test_expect_success '.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 &&
+ git config --add submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config --remove-section submodule.subname &&
+ git config --remove-section -f .gitmodules submodule.subname
+'
+
test_expect_success '--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' '
+ git config diff.ignoreSubmodules dirty &&
+ git status >output &&
+ ! test -s actual &&
+ git config --add -f .gitmodules submodule.subname.ignore dirty &&
+ git config --add -f .gitmodules submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config -f .gitmodules --remove-section submodule.subname &&
+ git config --unset diff.ignoreSubmodules
+'
+
+test_expect_success '.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 &&
+ git config --add submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config --remove-section submodule.subname &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
test_expect_success '--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' '
+ git config --add -f .gitmodules submodule.subname.ignore dirty &&
+ git config --add -f .gitmodules submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
+test_expect_success '.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 &&
+ git config --add submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config --remove-section submodule.subname &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
cat > expect << EOF
# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# modified: sm
+#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
@@ -855,16 +939,21 @@ cat > expect << EOF
# modified: dir1/modified
# modified: sm (modified content)
#
+# Submodule changes to be committed:
+#
+# * sm $head...$new_head (1):
+# > Add bar
+#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
+# .gitmodules
# dir1/untracked
# dir2/modified
# dir2/untracked
# expect
# output
# untracked
-no changes added to commit (use "git add" and/or "git commit -a")
EOF
test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
@@ -872,10 +961,34 @@ test_expect_success "--ignore-submodules=untracked doesn't suppress submodules w
test_cmp expect output
'
+test_expect_success ".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 &&
+ test_cmp expect output &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
+test_expect_success ".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 &&
+ git config --add submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config --remove-section submodule.subname &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
cat > expect << EOF
# On branch master
+# Changes to be committed:
+# (use "git reset HEAD <file>..." to unstage)
+#
+# modified: sm
+#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
@@ -883,21 +996,26 @@ cat > expect << EOF
# modified: dir1/modified
# modified: sm (new commits)
#
+# Submodule changes to be committed:
+#
+# * sm $head...$new_head (1):
+# > Add bar
+#
# Submodules changed but not updated:
#
-# * sm $head...$head2 (1):
+# * sm $new_head...$head2 (1):
# > 2nd commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
+# .gitmodules
# dir1/untracked
# dir2/modified
# dir2/untracked
# expect
# output
# untracked
-no changes added to commit (use "git add" and/or "git commit -a")
EOF
test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
@@ -905,10 +1023,47 @@ test_expect_success "--ignore-submodules=untracked doesn't suppress submodule su
test_cmp expect output
'
+test_expect_success ".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 &&
+ test_cmp expect output &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
+test_expect_success ".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 &&
+ git config --add submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config --remove-section submodule.subname &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
test_expect_success "--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" '
+ git config --add -f .gitmodules submodule.subname.ignore dirty &&
+ git config --add -f .gitmodules submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
+test_expect_success ".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 &&
+ git config --add submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config --remove-section submodule.subname &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
cat > expect << EOF
# On branch master
@@ -921,6 +1076,7 @@ cat > expect << EOF
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
+# .gitmodules
# dir1/untracked
# dir2/modified
# dir2/untracked
@@ -935,4 +1091,23 @@ test_expect_success "--ignore-submodules=all suppresses submodule summary" '
test_cmp expect output
'
+test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
+ git config --add -f .gitmodules submodule.subname.ignore all &&
+ git config --add -f .gitmodules submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
+test_expect_failure '.git/config ignore=all suppresses 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 all &&
+ git config --add submodule.subname.path sm &&
+ git status > output &&
+ test_cmp expect output &&
+ git config --remove-section submodule.subname &&
+ git config -f .gitmodules --remove-section submodule.subname
+'
+
test_done
diff --git a/t/t7509-commit.sh b/t/t7509-commit.sh
index 3ea33db..643ab03 100755
--- a/t/t7509-commit.sh
+++ b/t/t7509-commit.sh
@@ -111,7 +111,7 @@ test_expect_success '--amend option with empty author' '
test_when_finished "git checkout Initial" &&
echo "Empty author test" >>foo &&
test_tick &&
- ! git commit -a -m "empty author" --amend 2>err &&
+ test_must_fail git commit -a -m "empty author" --amend 2>err &&
grep "empty ident" err
'
@@ -125,7 +125,7 @@ test_expect_success '--amend option with missing author' '
test_when_finished "git checkout Initial" &&
echo "Missing author test" >>foo &&
test_tick &&
- ! git commit -a -m "malformed author" --amend 2>err &&
+ test_must_fail git commit -a -m "malformed author" --amend 2>err &&
grep "empty ident" err
'
diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh
index cde8390..b4f40e4 100755
--- a/t/t7600-merge.sh
+++ b/t/t7600-merge.sh
@@ -5,189 +5,103 @@
test_description='git merge
-Testing basic merge operations/option parsing.'
+Testing basic merge operations/option parsing.
+
+! [c0] commit 0
+ ! [c1] commit 1
+ ! [c2] commit 2
+ ! [c3] commit 3
+ ! [c4] c4
+ ! [c5] c5
+ ! [c6] c6
+ * [master] Merge commit 'c1'
+--------
+ - [master] Merge commit 'c1'
+ + * [c1] commit 1
+ + [c6] c6
+ + [c5] c5
+ ++ [c4] c4
+ ++++ [c3] commit 3
+ + [c2] commit 2
++++++++* [c0] commit 0
+'
. ./test-lib.sh
-cat >file <<EOF
-1
-2
-3
-4
-5
-6
-7
-8
-9
-EOF
-
-cat >file.1 <<EOF
-1 X
-2
-3
-4
-5
-6
-7
-8
-9
-EOF
-
-cat >file.5 <<EOF
-1
-2
-3
-4
-5 X
-6
-7
-8
-9
-EOF
-
-cat >file.9 <<EOF
-1
-2
-3
-4
-5
-6
-7
-8
-9 X
-EOF
-
-cat >result.1 <<EOF
-1 X
-2
-3
-4
-5
-6
-7
-8
-9
-EOF
-
-cat >result.1-5 <<EOF
-1 X
-2
-3
-4
-5 X
-6
-7
-8
-9
-EOF
-
-cat >result.1-5-9 <<EOF
-1 X
-2
-3
-4
-5 X
-6
-7
-8
-9 X
-EOF
-
-create_merge_msgs() {
- echo "Merge commit 'c2'" >msg.1-5 &&
- echo "Merge commit 'c2'; commit 'c3'" >msg.1-5-9 &&
- echo "Squashed commit of the following:" >squash.1 &&
- echo >>squash.1 &&
- git log --no-merges ^HEAD c1 >>squash.1 &&
- echo "Squashed commit of the following:" >squash.1-5 &&
- echo >>squash.1-5 &&
- git log --no-merges ^HEAD c2 >>squash.1-5 &&
- echo "Squashed commit of the following:" >squash.1-5-9 &&
- echo >>squash.1-5-9 &&
- git log --no-merges ^HEAD c2 c3 >>squash.1-5-9 &&
- echo > msg.nolog &&
- echo "* commit 'c3':" >msg.log &&
- echo " commit 3" >>msg.log &&
- echo >>msg.log
-}
-
-verify_diff() {
- if ! test_cmp "$1" "$2"
- then
- echo "$3"
- false
- fi
-}
-
-verify_merge() {
- verify_diff "$2" "$1" "[OOPS] bad merge result" &&
- if test $(git ls-files -u | wc -l) -gt 0
- then
- echo "[OOPS] unmerged files"
- false
- fi &&
- if test_must_fail git diff --exit-code
- then
- echo "[OOPS] working tree != index"
- false
- fi &&
- if test -n "$3"
- then
- git show -s --pretty=format:%s HEAD >msg.act &&
- verify_diff "$3" msg.act "[OOPS] bad merge message"
- fi
-}
-
-verify_head() {
- if test "$1" != "$(git rev-parse HEAD)"
- then
- echo "[OOPS] HEAD != $1"
- false
- fi
-}
-
-verify_parents() {
- i=1
- while test $# -gt 0
- do
- if test "$1" != "$(git rev-parse HEAD^$i)"
+test_expect_success 'set up test data and helpers' '
+ printf "%s\n" 1 2 3 4 5 6 7 8 9 >file &&
+ printf "%s\n" "1 X" 2 3 4 5 6 7 8 9 >file.1 &&
+ printf "%s\n" 1 2 3 4 "5 X" 6 7 8 9 >file.5 &&
+ printf "%s\n" 1 2 3 4 5 6 7 8 "9 X" >file.9 &&
+ printf "%s\n" "1 X" 2 3 4 5 6 7 8 9 >result.1 &&
+ printf "%s\n" "1 X" 2 3 4 "5 X" 6 7 8 9 >result.1-5 &&
+ printf "%s\n" "1 X" 2 3 4 "5 X" 6 7 8 "9 X" >result.1-5-9 &&
+
+ create_merge_msgs() {
+ echo "Merge commit '\''c2'\''" >msg.1-5 &&
+ echo "Merge commit '\''c2'\''; commit '\''c3'\''" >msg.1-5-9 &&
+ {
+ echo "Squashed commit of the following:" &&
+ echo &&
+ git log --no-merges ^HEAD c1
+ } >squash.1 &&
+ {
+ echo "Squashed commit of the following:" &&
+ echo &&
+ git log --no-merges ^HEAD c2
+ } >squash.1-5 &&
+ {
+ echo "Squashed commit of the following:" &&
+ echo &&
+ git log --no-merges ^HEAD c2 c3
+ } >squash.1-5-9 &&
+ echo >msg.nolog &&
+ {
+ echo "* commit '\''c3'\'':" &&
+ echo " commit 3" &&
+ echo
+ } >msg.log
+ } &&
+
+ verify_merge() {
+ test_cmp "$2" "$1" &&
+ git update-index --refresh &&
+ git diff --exit-code &&
+ if test -n "$3"
then
- echo "[OOPS] HEAD^$i != $1"
- return 1
+ git show -s --pretty=format:%s HEAD >msg.act &&
+ test_cmp "$3" msg.act
fi
- i=$(expr $i + 1)
- shift
- done
-}
-
-verify_mergeheads() {
- i=1
- if ! test -f .git/MERGE_HEAD
- then
- echo "[OOPS] MERGE_HEAD is missing"
- false
- fi &&
- while test $# -gt 0
- do
- head=$(head -n $i .git/MERGE_HEAD | sed -ne \$p)
- if test "$1" != "$head"
- then
- echo "[OOPS] MERGE_HEAD $i != $1"
+ } &&
+
+ verify_head() {
+ echo "$1" >head.expected &&
+ git rev-parse HEAD >head.actual &&
+ test_cmp head.expected head.actual
+ } &&
+
+ verify_parents() {
+ printf "%s\n" "$@" >parents.expected &&
+ >parents.actual &&
+ i=1 &&
+ while test $i -le $#
+ do
+ git rev-parse HEAD^$i >>parents.actual &&
+ i=$(expr $i + 1) ||
return 1
- fi
- i=$(expr $i + 1)
- shift
- done
-}
+ done &&
+ test_cmp parents.expected parents.actual
+ } &&
-verify_no_mergehead() {
- if test -f .git/MERGE_HEAD
- then
- echo "[OOPS] MERGE_HEAD exists"
- false
- fi
-}
+ verify_mergeheads() {
+ printf "%s\n" "$@" >mergehead.expected &&
+ test_cmp mergehead.expected .git/MERGE_HEAD
+ } &&
+ verify_no_mergehead() {
+ ! test -e .git/MERGE_HEAD
+ }
+'
test_expect_success 'setup' '
git add file &&
@@ -219,7 +133,7 @@ test_expect_success 'setup' '
create_merge_msgs
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'test option parsing' '
test_must_fail git merge -$ c1 &&
@@ -235,13 +149,19 @@ test_expect_success 'reject non-strategy with a git-merge-foo name' '
'
test_expect_success 'merge c0 with c1' '
+ echo "OBJID HEAD@{0}: merge c1: Fast-forward" >reflog.expected &&
+
git reset --hard c0 &&
git merge c1 &&
verify_merge file result.1 &&
- verify_head "$c1"
+ verify_head "$c1" &&
+
+ git reflog -1 >reflog.actual &&
+ sed "s/$_x05[0-9a-f]*/OBJID/g" reflog.actual >reflog.fuzzy &&
+ test_cmp reflog.expected reflog.fuzzy
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c0 with c1 with --ff-only' '
git reset --hard c0 &&
@@ -251,7 +171,28 @@ test_expect_success 'merge c0 with c1 with --ff-only' '
verify_head "$c1"
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
+
+test_expect_success 'merge from unborn branch' '
+ git checkout -f master &&
+ test_might_fail git branch -D kid &&
+
+ echo "OBJID HEAD@{0}: initial pull" >reflog.expected &&
+
+ git checkout --orphan kid &&
+ test_when_finished "git checkout -f master" &&
+ git rm -fr . &&
+ test_tick &&
+ git merge --ff-only c1 &&
+ verify_merge file result.1 &&
+ verify_head "$c1" &&
+
+ git reflog -1 >reflog.actual &&
+ sed "s/$_x05[0-9a-f][0-9a-f]/OBJID/g" reflog.actual >reflog.fuzzy &&
+ test_cmp reflog.expected reflog.fuzzy
+'
+
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2' '
git reset --hard c1 &&
@@ -261,7 +202,7 @@ test_expect_success 'merge c1 with c2' '
verify_parents $c1 $c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 and c3' '
git reset --hard c1 &&
@@ -271,7 +212,7 @@ test_expect_success 'merge c1 with c2 and c3' '
verify_parents $c1 $c2 $c3
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'failing merges with --ff-only' '
git reset --hard c1 &&
@@ -288,7 +229,7 @@ test_expect_success 'merge c0 with c1 (no-commit)' '
verify_head $c1
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (no-commit)' '
git reset --hard c1 &&
@@ -298,7 +239,7 @@ test_expect_success 'merge c1 with c2 (no-commit)' '
verify_mergeheads $c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 and c3 (no-commit)' '
git reset --hard c1 &&
@@ -308,7 +249,7 @@ test_expect_success 'merge c1 with c2 and c3 (no-commit)' '
verify_mergeheads $c2 $c3
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c0 with c1 (squash)' '
git reset --hard c0 &&
@@ -316,10 +257,10 @@ test_expect_success 'merge c0 with c1 (squash)' '
verify_merge file result.1 &&
verify_head $c0 &&
verify_no_mergehead &&
- verify_diff squash.1 .git/SQUASH_MSG "[OOPS] bad squash message"
+ test_cmp squash.1 .git/SQUASH_MSG
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c0 with c1 (squash, ff-only)' '
git reset --hard c0 &&
@@ -327,10 +268,10 @@ test_expect_success 'merge c0 with c1 (squash, ff-only)' '
verify_merge file result.1 &&
verify_head $c0 &&
verify_no_mergehead &&
- verify_diff squash.1 .git/SQUASH_MSG "[OOPS] bad squash message"
+ test_cmp squash.1 .git/SQUASH_MSG
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (squash)' '
git reset --hard c1 &&
@@ -338,17 +279,17 @@ test_expect_success 'merge c1 with c2 (squash)' '
verify_merge file result.1-5 &&
verify_head $c1 &&
verify_no_mergehead &&
- verify_diff squash.1-5 .git/SQUASH_MSG "[OOPS] bad squash message"
+ test_cmp squash.1-5 .git/SQUASH_MSG
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'unsuccesful merge of c1 with c2 (squash, ff-only)' '
git reset --hard c1 &&
test_must_fail git merge --squash --ff-only c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 and c3 (squash)' '
git reset --hard c1 &&
@@ -356,10 +297,10 @@ test_expect_success 'merge c1 with c2 and c3 (squash)' '
verify_merge file result.1-5-9 &&
verify_head $c1 &&
verify_no_mergehead &&
- verify_diff squash.1-5-9 .git/SQUASH_MSG "[OOPS] bad squash message"
+ test_cmp squash.1-5-9 .git/SQUASH_MSG
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (no-commit in config)' '
git reset --hard c1 &&
@@ -370,7 +311,7 @@ test_expect_success 'merge c1 with c2 (no-commit in config)' '
verify_mergeheads $c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (squash in config)' '
git reset --hard c1 &&
@@ -379,10 +320,10 @@ test_expect_success 'merge c1 with c2 (squash in config)' '
verify_merge file result.1-5 &&
verify_head $c1 &&
verify_no_mergehead &&
- verify_diff squash.1-5 .git/SQUASH_MSG "[OOPS] bad squash message"
+ test_cmp squash.1-5 .git/SQUASH_MSG
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'override config option -n with --summary' '
git reset --hard c1 &&
@@ -412,7 +353,7 @@ test_expect_success 'override config option -n with --stat' '
fi
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'override config option --stat' '
git reset --hard c1 &&
@@ -428,7 +369,7 @@ test_expect_success 'override config option --stat' '
fi
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (override --no-commit)' '
git reset --hard c1 &&
@@ -439,7 +380,7 @@ test_expect_success 'merge c1 with c2 (override --no-commit)' '
verify_parents $c1 $c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c2 (override --squash)' '
git reset --hard c1 &&
@@ -450,7 +391,7 @@ test_expect_success 'merge c1 with c2 (override --squash)' '
verify_parents $c1 $c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c0 with c1 (no-ff)' '
git reset --hard c0 &&
@@ -461,7 +402,7 @@ test_expect_success 'merge c0 with c1 (no-ff)' '
verify_parents $c0 $c1
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'combining --squash and --no-ff is refused' '
test_must_fail git merge --squash --no-ff c1 &&
@@ -485,20 +426,20 @@ test_expect_success 'merge log message' '
git reset --hard c0 &&
git merge --no-log c2 &&
git show -s --pretty=format:%b HEAD >msg.act &&
- verify_diff msg.nolog msg.act "[OOPS] bad merge log message" &&
+ test_cmp msg.nolog msg.act &&
git merge --log c3 &&
git show -s --pretty=format:%b HEAD >msg.act &&
- verify_diff msg.log msg.act "[OOPS] bad merge log message" &&
+ test_cmp msg.log msg.act &&
git reset --hard HEAD^ &&
git config merge.log yes &&
git merge c3 &&
git show -s --pretty=format:%b HEAD >msg.act &&
- verify_diff msg.log msg.act "[OOPS] bad merge log message"
+ test_cmp msg.log msg.act
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
git reset --hard c1 &&
@@ -509,7 +450,7 @@ test_expect_success 'merge c1 with c0, c2, c0, and c1' '
verify_parents $c1 $c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c0, c2, c0, and c1' '
git reset --hard c1 &&
@@ -520,7 +461,7 @@ test_expect_success 'merge c1 with c0, c2, c0, and c1' '
verify_parents $c1 $c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge c1 with c1 and c2' '
git reset --hard c1 &&
@@ -531,7 +472,7 @@ test_expect_success 'merge c1 with c1 and c2' '
verify_parents $c1 $c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge fast-forward in a dirty tree' '
git reset --hard c0 &&
@@ -541,16 +482,16 @@ test_expect_success 'merge fast-forward in a dirty tree' '
git merge c2
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'in-index merge' '
git reset --hard c0 &&
- git merge --no-ff -s resolve c1 > out &&
+ git merge --no-ff -s resolve c1 >out &&
grep "Wonderful." out &&
verify_parents $c0 $c1
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'refresh the index before merging' '
git reset --hard c1 &&
@@ -558,31 +499,39 @@ test_expect_success 'refresh the index before merging' '
git merge c3
'
-cat >expected <<EOF
-Merge branch 'c5' (early part)
+cat >expected.branch <<\EOF
+Merge branch 'c5-branch' (early part)
+EOF
+cat >expected.tag <<\EOF
+Merge commit 'c5~1'
EOF
test_expect_success 'merge early part of c2' '
git reset --hard c3 &&
- echo c4 > c4.c &&
+ echo c4 >c4.c &&
git add c4.c &&
git commit -m c4 &&
git tag c4 &&
- echo c5 > c5.c &&
+ echo c5 >c5.c &&
git add c5.c &&
git commit -m c5 &&
git tag c5 &&
git reset --hard c3 &&
- echo c6 > c6.c &&
+ echo c6 >c6.c &&
git add c6.c &&
git commit -m c6 &&
git tag c6 &&
+ git branch -f c5-branch c5 &&
+ git merge c5-branch~1 &&
+ git show -s --pretty=format:%s HEAD >actual.branch &&
+ git reset --keep HEAD^ &&
git merge c5~1 &&
- git show -s --pretty=format:%s HEAD > actual &&
- test_cmp actual expected
+ git show -s --pretty=format:%s HEAD >actual.tag &&
+ test_cmp expected.branch actual.branch &&
+ test_cmp expected.tag actual.tag
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'merge --no-ff --no-commit && commit' '
git reset --hard c0 &&
@@ -591,13 +540,13 @@ test_expect_success 'merge --no-ff --no-commit && commit' '
verify_parents $c0 $c1
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_expect_success 'amending no-ff merge commit' '
EDITOR=: git commit --amend &&
verify_parents $c0 $c1
'
-test_debug 'gitk --all'
+test_debug 'git log --graph --decorate --oneline --all'
test_done
diff --git a/t/t7606-merge-custom.sh b/t/t7606-merge-custom.sh
index 52a451d..8e8c4d7 100755
--- a/t/t7606-merge-custom.sh
+++ b/t/t7606-merge-custom.sh
@@ -1,49 +1,93 @@
#!/bin/sh
-test_description='git merge
+test_description="git merge
-Testing a custom strategy.'
+Testing a custom strategy.
+
+* (HEAD, master) Merge commit 'c3'
+|\
+| * (tag: c3) c3
+* | (tag: c1) c1
+|/
+| * tag: c2) c2
+|/
+* (tag: c0) c0
+"
. ./test-lib.sh
-cat >git-merge-theirs <<EOF
-#!$SHELL_PATH
-eval git read-tree --reset -u \\\$\$#
-EOF
-chmod +x git-merge-theirs
-PATH=.:$PATH
-export PATH
+test_expect_success 'set up custom strategy' '
+ cat >git-merge-theirs <<-EOF &&
+ #!$SHELL_PATH
+ eval git read-tree --reset -u \\\$\$#
+ EOF
+
+ chmod +x git-merge-theirs &&
+ PATH=.:$PATH &&
+ export PATH
+'
test_expect_success 'setup' '
- echo c0 >c0.c &&
- git add c0.c &&
- git commit -m c0 &&
- git tag c0 &&
- echo c1 >c1.c &&
- git add c1.c &&
- git commit -m c1 &&
- git tag c1 &&
- git reset --hard c0 &&
+ test_commit c0 c0.c &&
+ test_commit c1 c1.c &&
+ git reset --keep c0 &&
echo c1c1 >c1.c &&
- echo c2 >c2.c &&
- git add c1.c c2.c &&
- git commit -m c2 &&
- git tag c2
+ git add c1.c &&
+ test_commit c2 c2.c &&
+ git reset --keep c0 &&
+ test_commit c3 c3.c
'
test_expect_success 'merge c2 with a custom strategy' '
git reset --hard c1 &&
+
+ git rev-parse c1 >head.old &&
+ git rev-parse c2 >second-parent.expected &&
+ git rev-parse c2^{tree} >tree.expected &&
git merge -s theirs c2 &&
- test "$(git rev-parse c1)" != "$(git rev-parse HEAD)" &&
- test "$(git rev-parse c1)" = "$(git rev-parse HEAD^1)" &&
- test "$(git rev-parse c2)" = "$(git rev-parse HEAD^2)" &&
- test "$(git rev-parse c2^{tree})" = "$(git rev-parse HEAD^{tree})" &&
+
+ git rev-parse HEAD >head.new &&
+ git rev-parse HEAD^1 >first-parent &&
+ git rev-parse HEAD^2 >second-parent &&
+ git rev-parse HEAD^{tree} >tree &&
+ git update-index --refresh &&
git diff --exit-code &&
git diff --exit-code c2 HEAD &&
git diff --exit-code c2 &&
+
+ ! test_cmp head.old head.new &&
+ test_cmp head.old first-parent &&
+ test_cmp second-parent.expected second-parent &&
+ test_cmp tree.expected tree &&
test -f c0.c &&
grep c1c1 c1.c &&
test -f c2.c
'
+test_expect_success 'trivial merge with custom strategy' '
+ git reset --hard c1 &&
+
+ git rev-parse c1 >head.old &&
+ git rev-parse c3 >second-parent.expected &&
+ git rev-parse c3^{tree} >tree.expected &&
+ git merge -s theirs c3 &&
+
+ git rev-parse HEAD >head.new &&
+ git rev-parse HEAD^1 >first-parent &&
+ git rev-parse HEAD^2 >second-parent &&
+ git rev-parse HEAD^{tree} >tree &&
+ git update-index --refresh &&
+ git diff --exit-code &&
+ git diff --exit-code c3 HEAD &&
+ git diff --exit-code c3 &&
+
+ ! test_cmp head.old head.new &&
+ test_cmp head.old first-parent &&
+ test_cmp second-parent.expected second-parent &&
+ test_cmp tree.expected tree &&
+ test -f c0.c &&
+ ! test -e c1.c &&
+ test -f c3.c
+'
+
test_done
diff --git a/t/t7607-merge-overwrite.sh b/t/t7607-merge-overwrite.sh
index 49f4e15..d82349a 100755
--- a/t/t7607-merge-overwrite.sh
+++ b/t/t7607-merge-overwrite.sh
@@ -31,7 +31,7 @@ test_expect_success 'setup' '
test_expect_success 'will not overwrite untracked file' '
git reset --hard c1 &&
cat important > c2.c &&
- ! git merge c2 &&
+ test_must_fail git merge c2 &&
test_cmp important c2.c
'
@@ -39,7 +39,7 @@ test_expect_success 'will not overwrite new file' '
git reset --hard c1 &&
cat important > c2.c &&
git add c2.c &&
- ! git merge c2 &&
+ test_must_fail git merge c2 &&
test_cmp important c2.c
'
@@ -48,7 +48,7 @@ test_expect_success 'will not overwrite staged changes' '
cat important > c2.c &&
git add c2.c &&
rm c2.c &&
- ! git merge c2 &&
+ test_must_fail git merge c2 &&
git checkout c2.c &&
test_cmp important c2.c
'
@@ -58,7 +58,7 @@ test_expect_success 'will not overwrite removed file' '
git rm c1.c &&
git commit -m "rm c1.c" &&
cat important > c1.c &&
- ! git merge c1a &&
+ test_must_fail git merge c1a &&
test_cmp important c1.c
'
@@ -68,7 +68,7 @@ test_expect_success 'will not overwrite re-added file' '
git commit -m "rm c1.c" &&
cat important > c1.c &&
git add c1.c &&
- ! git merge c1a &&
+ test_must_fail git merge c1a &&
test_cmp important c1.c
'
@@ -79,7 +79,7 @@ test_expect_success 'will not overwrite removed file with staged changes' '
cat important > c1.c &&
git add c1.c &&
rm c1.c &&
- ! git merge c1a &&
+ test_must_fail git merge c1a &&
git checkout c1.c &&
test_cmp important c1.c
'
diff --git a/t/t7609-merge-co-error-msgs.sh b/t/t7609-merge-co-error-msgs.sh
new file mode 100755
index 0000000..114d2bd
--- /dev/null
+++ b/t/t7609-merge-co-error-msgs.sh
@@ -0,0 +1,133 @@
+#!/bin/sh
+
+test_description='unpack-trees error messages'
+
+. ./test-lib.sh
+
+
+test_expect_success 'setup' '
+ echo one >one &&
+ git add one &&
+ git commit -a -m First &&
+
+ git checkout -b branch &&
+ echo two >two &&
+ echo three >three &&
+ echo four >four &&
+ echo five >five &&
+ git add two three four five &&
+ git commit -m Second &&
+
+ git checkout master &&
+ echo other >two &&
+ echo other >three &&
+ echo other >four &&
+ echo other >five
+'
+
+cat >expect <<\EOF
+error: The following untracked working tree files would be overwritten by merge:
+ two
+ three
+ four
+ five
+Please move or remove them before you can merge.
+EOF
+
+test_expect_success 'untracked files overwritten by merge (fast and non-fast forward)' '
+ test_must_fail git merge branch 2>out &&
+ test_cmp out expect &&
+ git commit --allow-empty -m empty &&
+ (
+ GIT_MERGE_VERBOSITY=0 &&
+ export GIT_MERGE_VERBOSITY &&
+ test_must_fail git merge branch 2>out2
+ ) &&
+ test_cmp out2 expect &&
+ git reset --hard HEAD^
+'
+
+cat >expect <<\EOF
+error: Your local changes to the following files would be overwritten by merge:
+ two
+ three
+ four
+Please, commit your changes or stash them before you can merge.
+error: The following untracked working tree files would be overwritten by merge:
+ five
+Please move or remove them before you can merge.
+EOF
+
+test_expect_success 'untracked files or local changes ovewritten by merge' '
+ git add two &&
+ git add three &&
+ git add four &&
+ test_must_fail git merge branch 2>out &&
+ test_cmp out expect
+'
+
+cat >expect <<\EOF
+error: Your local changes to the following files would be overwritten by checkout:
+ rep/two
+ rep/one
+Please, commit your changes or stash them before you can switch branches.
+EOF
+
+test_expect_success 'cannot switch branches because of local changes' '
+ git add five &&
+ mkdir rep &&
+ echo one >rep/one &&
+ echo two >rep/two &&
+ git add rep/one rep/two &&
+ git commit -m Fourth &&
+ git checkout master &&
+ echo uno >rep/one &&
+ echo dos >rep/two &&
+ test_must_fail git checkout branch 2>out &&
+ test_cmp out expect
+'
+
+cat >expect <<\EOF
+error: Your local changes to the following files would be overwritten by checkout:
+ rep/two
+ rep/one
+Please, commit your changes or stash them before you can switch branches.
+EOF
+
+test_expect_success 'not uptodate file porcelain checkout error' '
+ git add rep/one rep/two &&
+ test_must_fail git checkout branch 2>out &&
+ test_cmp out expect
+'
+
+cat >expect <<\EOF
+error: Updating the following directories would lose untracked files in it:
+ rep2
+ rep
+
+EOF
+
+test_expect_success 'not_uptodate_dir porcelain checkout error' '
+ git init uptodate &&
+ cd uptodate &&
+ mkdir rep &&
+ mkdir rep2 &&
+ touch rep/foo &&
+ touch rep2/foo &&
+ git add rep/foo rep2/foo &&
+ git commit -m init &&
+ git checkout -b branch &&
+ git rm rep -r &&
+ git rm rep2 -r &&
+ >rep &&
+ >rep2 &&
+ git add rep rep2&&
+ git commit -m "added test as a file" &&
+ git checkout master &&
+ >rep/untracked-file &&
+ >rep2/untracked-file &&
+ test_must_fail git checkout branch 2>out &&
+ test_cmp out ../expect
+'
+
+test_done
diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
index e768c3e..3bd7404 100755
--- a/t/t7610-mergetool.sh
+++ b/t/t7610-mergetool.sh
@@ -14,6 +14,7 @@ Testing basic merge tool invocation'
# running mergetool
test_expect_success 'setup' '
+ git config rerere.enabled true &&
echo master >file1 &&
mkdir subdir &&
echo master sub >subdir/file3 &&
@@ -67,23 +68,47 @@ test_expect_success 'mergetool crlf' '
'
test_expect_success 'mergetool in subdir' '
- git checkout -b test3 branch1
- cd subdir && (
- test_must_fail git merge master >/dev/null 2>&1 &&
- ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
- test "$(cat file3)" = "master new sub" )
+ git checkout -b test3 branch1 &&
+ (
+ cd subdir &&
+ test_must_fail git merge master >/dev/null 2>&1 &&
+ ( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
+ test "$(cat file3)" = "master new sub"
+ )
'
-# We can't merge files from parent directories when running mergetool
-# from a subdir. Is this a bug?
-#
-#test_expect_failure 'mergetool in subdir' '
-# cd subdir && (
-# ( yes "" | git mergetool ../file1 >/dev/null 2>&1 ) &&
-# ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) &&
-# test "$(cat ../file1)" = "master updated" &&
-# test "$(cat ../file2)" = "master new" &&
-# git commit -m "branch1 resolved with mergetool - subdir" )
-#'
+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 ) &&
+ test "$(cat ../file1)" = "master updated" &&
+ test "$(cat ../file2)" = "master new" &&
+ git commit -m "branch1 resolved with mergetool - subdir"
+ )
+'
+
+test_expect_success 'mergetool skips autoresolved' '
+ git checkout -b test4 branch1 &&
+ test_must_fail git merge master &&
+ test -n "$(git ls-files -u)" &&
+ output="$(git mergetool --no-prompt)" &&
+ test "$output" = "No files need merging" &&
+ git reset --hard
+'
+
+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 &&
+ test "$(cat ../file1)" = "master updated" &&
+ test "$(cat ../file2)" = "master new" &&
+ test "$(cat file3)" = "master new sub" &&
+ git add ../file1 ../file2 file3 &&
+ git commit -m "branch2 resolved by mergetool from subdir"
+ )
+'
test_done
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index 8a63227..023f225 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -65,7 +65,7 @@ do
test_expect_success "grep -w $L (w)" '
: >expected &&
- ! git grep -n -w -e "^w" >actual &&
+ test_must_fail git grep -n -w -e "^w" >actual &&
test_cmp expected actual
'
diff --git a/t/t9010-svn-fe.sh b/t/t9010-svn-fe.sh
new file mode 100755
index 0000000..a713dfc
--- /dev/null
+++ b/t/t9010-svn-fe.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+test_description='check svn dumpfile importer'
+
+. ./lib-git-svn.sh
+
+test_dump() {
+ label=$1
+ dump=$2
+ test_expect_success "$dump" '
+ svnadmin create "$label-svn" &&
+ svnadmin load "$label-svn" < "$TEST_DIRECTORY/$dump" &&
+ svn_cmd export "file://$PWD/$label-svn" "$label-svnco" &&
+ git init "$label-git" &&
+ test-svn-fe "$TEST_DIRECTORY/$dump" >"$label.fe" &&
+ (
+ cd "$label-git" &&
+ git fast-import < ../"$label.fe"
+ ) &&
+ (
+ cd "$label-svnco" &&
+ git init &&
+ git add . &&
+ git fetch "../$label-git" master &&
+ git diff --exit-code FETCH_HEAD
+ )
+ '
+}
+
+test_dump simple t9135/svn.dump
+
+test_done
diff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh
index d5ee39a..ec0a106 100755
--- a/t/t9130-git-svn-authors-file.sh
+++ b/t/t9130-git-svn-authors-file.sh
@@ -20,7 +20,7 @@ test_expect_success 'setup svnrepo' '
'
test_expect_success 'start import with incomplete authors file' '
- ! git svn clone --authors-file=svn-authors "$svnrepo" x
+ test_must_fail git svn clone --authors-file=svn-authors "$svnrepo" x
'
test_expect_success 'imported 2 revisions successfully' '
@@ -63,7 +63,7 @@ test_expect_success 'authors-file against globs' '
'
test_expect_success 'fetch fails on ee' '
- ( cd aa-work && ! git svn fetch --authors-file=../svn-authors )
+ ( cd aa-work && test_must_fail git svn fetch --authors-file=../svn-authors )
'
tmp_config_get () {
diff --git a/t/t9139-git-svn-non-utf8-commitencoding.sh b/t/t9139-git-svn-non-utf8-commitencoding.sh
index f337959..22d80b0 100755
--- a/t/t9139-git-svn-non-utf8-commitencoding.sh
+++ b/t/t9139-git-svn-non-utf8-commitencoding.sh
@@ -39,7 +39,7 @@ do
(
cd $H &&
git config --unset i18n.commitencoding &&
- ! git svn dcommit
+ test_must_fail git svn dcommit
)
'
done
diff --git a/t/t9140-git-svn-reset.sh b/t/t9140-git-svn-reset.sh
index 0735526..e855904 100755
--- a/t/t9140-git-svn-reset.sh
+++ b/t/t9140-git-svn-reset.sh
@@ -41,7 +41,7 @@ test_expect_success 'modify hidden file in SVN repo' '
test_expect_success 'fetch fails on modified hidden file' '
( cd g &&
git svn find-rev refs/remotes/git-svn > ../expect &&
- ! git svn fetch 2> ../errors &&
+ test_must_fail git svn fetch 2> ../errors &&
git svn find-rev refs/remotes/git-svn > ../expect2 ) &&
fgrep "not found in commit" errors &&
test_cmp expect expect2
diff --git a/t/t9155-git-svn-fetch-deleted-tag.sh b/t/t9155-git-svn-fetch-deleted-tag.sh
new file mode 100755
index 0000000..a486a98
--- /dev/null
+++ b/t/t9155-git-svn-fetch-deleted-tag.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='git svn fetch deleted tag'
+
+. ./lib-git-svn.sh
+
+test_expect_success 'setup svn repo' '
+ mkdir -p import/trunk/subdir &&
+ mkdir -p import/branches &&
+ mkdir -p import/tags &&
+ echo "base" >import/trunk/subdir/file &&
+ svn_cmd import -m "import for git svn" import "$svnrepo" &&
+ rm -rf import &&
+
+ svn_cmd mkdir -m "create mybranch directory" "$svnrepo/branches/mybranch" &&
+ svn_cmd cp -m "create branch mybranch" "$svnrepo/trunk" "$svnrepo/branches/mybranch/trunk" &&
+
+ svn_cmd co "$svnrepo/trunk" svn_project &&
+ (cd svn_project &&
+ echo "trunk change" >>subdir/file &&
+ svn_cmd ci -m "trunk change" subdir/file &&
+
+ svn_cmd switch "$svnrepo/branches/mybranch/trunk" &&
+ echo "branch change" >>subdir/file &&
+ svn_cmd ci -m "branch change" subdir/file
+ ) &&
+
+ svn_cmd cp -m "create mytag attempt 1" -r5 "$svnrepo/trunk/subdir" "$svnrepo/tags/mytag" &&
+ svn_cmd rm -m "delete mytag attempt 1" "$svnrepo/tags/mytag" &&
+ svn_cmd cp -m "create mytag attempt 2" -r5 "$svnrepo/branches/mybranch/trunk/subdir" "$svnrepo/tags/mytag"
+'
+
+test_expect_success 'fetch deleted tags from same revision with checksum error' '
+ git svn init --stdlayout "$svnrepo" git_project &&
+ cd git_project &&
+ git svn fetch &&
+
+ git diff --exit-code mybranch:trunk/subdir/file tags/mytag:file &&
+ git diff --exit-code master:subdir/file tags/mytag^:file
+'
+
+test_done
diff --git a/t/t9156-git-svn-fetch-deleted-tag-2.sh b/t/t9156-git-svn-fetch-deleted-tag-2.sh
new file mode 100755
index 0000000..5ce7e2f
--- /dev/null
+++ b/t/t9156-git-svn-fetch-deleted-tag-2.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+test_description='git svn fetch deleted tag 2'
+
+. ./lib-git-svn.sh
+
+test_expect_success 'setup svn repo' '
+ mkdir -p import/branches &&
+ mkdir -p import/tags &&
+ mkdir -p import/trunk/subdir1 &&
+ mkdir -p import/trunk/subdir2 &&
+ mkdir -p import/trunk/subdir3 &&
+ echo "file1" >import/trunk/subdir1/file &&
+ echo "file2" >import/trunk/subdir2/file &&
+ echo "file3" >import/trunk/subdir3/file &&
+ svn_cmd import -m "import for git svn" import "$svnrepo" &&
+ rm -rf import &&
+
+ svn_cmd co "$svnrepo/trunk" svn_project &&
+ (cd svn_project &&
+ echo "change1" >>subdir1/file &&
+ echo "change2" >>subdir2/file &&
+ echo "change3" >>subdir3/file &&
+ svn_cmd ci -m "change" .
+ ) &&
+
+ svn_cmd cp -m "create mytag 1" -r2 "$svnrepo/trunk/subdir1" "$svnrepo/tags/mytag" &&
+ svn_cmd rm -m "delete mytag 1" "$svnrepo/tags/mytag" &&
+ svn_cmd cp -m "create mytag 2" -r2 "$svnrepo/trunk/subdir2" "$svnrepo/tags/mytag" &&
+ svn_cmd rm -m "delete mytag 2" "$svnrepo/tags/mytag" &&
+ svn_cmd cp -m "create mytag 3" -r2 "$svnrepo/trunk/subdir3" "$svnrepo/tags/mytag"
+'
+
+test_expect_success 'fetch deleted tags from same revision with no checksum error' '
+ git svn init --stdlayout "$svnrepo" git_project &&
+ cd git_project &&
+ git svn fetch &&
+
+ git diff --exit-code master:subdir3/file tags/mytag:file &&
+ git diff --exit-code master:subdir2/file tags/mytag^:file &&
+ git diff --exit-code master:subdir1/file tags/mytag^^:file
+'
+
+test_done
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 2aeed7b..96d07f1 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -853,6 +853,60 @@ test_expect_success \
'git fast-import <input &&
test `git rev-parse N2^{tree}` = `git rev-parse N3^{tree}`'
+test_expect_success \
+ 'N: copy directory by id' \
+ 'cat >expect <<-\EOF &&
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
+ :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
+ EOF
+ subdir=$(git rev-parse refs/heads/branch^0:file2) &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/N4
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ copy by tree hash
+ COMMIT
+
+ from refs/heads/branch^0
+ M 040000 $subdir file3
+ INPUT_END
+ git fast-import <input &&
+ git diff-tree -C --find-copies-harder -r N4^ N4 >actual &&
+ compare_diff_raw expect actual'
+
+test_expect_success \
+ 'N: modify copied tree' \
+ 'cat >expect <<-\EOF &&
+ :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5
+ :100755 100755 f1fb5da718392694d0076d677d6d0e364c79b0bc f1fb5da718392694d0076d677d6d0e364c79b0bc C100 file2/newf file3/newf
+ :100644 100644 7123f7f44e39be127c5eb701e5968176ee9d78b1 7123f7f44e39be127c5eb701e5968176ee9d78b1 C100 file2/oldf file3/oldf
+ EOF
+ subdir=$(git rev-parse refs/heads/branch^0:file2) &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/N5
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ copy by tree hash
+ COMMIT
+
+ from refs/heads/branch^0
+ M 040000 $subdir file3
+
+ commit refs/heads/N5
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+ data <<COMMIT
+ modify directory copy
+ COMMIT
+
+ M 644 inline file3/file5
+ data <<EOF
+ $file5_data
+ EOF
+ INPUT_END
+ git fast-import <input &&
+ git diff-tree -C --find-copies-harder -r N5^^ N5 >actual &&
+ compare_diff_raw expect actual'
+
###
### series O
###
diff --git a/t/t9350-fast-export.sh b/t/t9350-fast-export.sh
index d43f37c..8c8e679 100755
--- a/t/t9350-fast-export.sh
+++ b/t/t9350-fast-export.sh
@@ -355,6 +355,20 @@ test_expect_failure 'no exact-ref revisions included' '
)
'
+test_expect_success 'path limiting with import-marks does not lose unmodified files' '
+ git checkout -b simple marks~2 &&
+ git fast-export --export-marks=marks simple -- file > /dev/null &&
+ echo more content >> file &&
+ test_tick &&
+ git commit -mnext file &&
+ git fast-export --import-marks=marks simple -- file file0 | grep file0
+'
+
+test_expect_success 'full-tree re-shows unmodified files' '
+ git checkout -f simple &&
+ test $(git fast-export --full-tree simple | grep -c file0) -eq 3
+'
+
test_expect_success 'set-up a few more tags for tag export tests' '
git checkout -f master &&
HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&
@@ -376,4 +390,28 @@ test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj'
test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag'
test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj'
+test_expect_success SYMLINKS 'directory becomes symlink' '
+ git init dirtosymlink &&
+ git init result &&
+ (
+ cd dirtosymlink &&
+ mkdir foo &&
+ mkdir bar &&
+ echo hello > foo/world &&
+ echo hello > bar/world &&
+ git add foo/world bar/world &&
+ git commit -q -mone &&
+ git rm -r foo &&
+ ln -s bar foo &&
+ git add foo &&
+ git commit -q -mtwo
+ ) &&
+ (
+ cd dirtosymlink &&
+ git fast-export master -- foo |
+ (cd ../result && git fast-import --quiet)
+ ) &&
+ (cd result && git show master:foo)
+'
+
test_done
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 67553f3..dff5e25 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -256,6 +256,10 @@ q_to_cr () {
tr Q '\015'
}
+q_to_tab () {
+ tr Q '\011'
+}
+
append_cr () {
sed -e 's/$/Q/' | tr Q '\015'
}
@@ -570,6 +574,38 @@ test_external_without_stderr () {
fi
}
+# debugging-friendly alternatives to "test [-f|-d|-e]"
+# The commands test the existence or non-existence of $1. $2 can be
+# given to provide a more precise diagnosis.
+test_path_is_file () {
+ if ! [ -f "$1" ]
+ then
+ echo "File $1 doesn't exist. $*"
+ false
+ fi
+}
+
+test_path_is_dir () {
+ if ! [ -d "$1" ]
+ then
+ echo "Directory $1 doesn't exist. $*"
+ false
+ fi
+}
+
+test_path_is_missing () {
+ if [ -e "$1" ]
+ then
+ echo "Path exists:"
+ ls -ld "$1"
+ if [ $# -ge 1 ]; then
+ echo "$*"
+ fi
+ false
+ fi
+}
+
+
# This is not among top-level (test_expect_success | test_expect_failure)
# but is a prefix that can be used in the test script, like:
#