diff options
Diffstat (limited to 't')
-rw-r--r-- | t/annotate-tests.sh | 13 | ||||
-rwxr-xr-x | t/t1400-update-ref.sh | 2 | ||||
-rwxr-xr-x | t/t1501-worktree.sh | 7 | ||||
-rwxr-xr-x | t/t1506-rev-parse-diagnosis.sh | 7 | ||||
-rwxr-xr-x | t/t2011-checkout-invalid-head.sh | 2 | ||||
-rwxr-xr-x | t/t2200-add-update.sh | 24 | ||||
-rwxr-xr-x | t/t2201-add-update-typechange.sh | 2 | ||||
-rwxr-xr-x | t/t3200-branch.sh | 4 | ||||
-rwxr-xr-x | t/t3409-rebase-preserve-merges.sh | 32 | ||||
-rwxr-xr-x | t/t3600-rm.sh | 3 | ||||
-rwxr-xr-x | t/t3701-add-interactive.sh | 41 | ||||
-rwxr-xr-x | t/t4002-diff-basic.sh | 5 | ||||
-rwxr-xr-x | t/t4014-format-patch.sh | 42 | ||||
-rwxr-xr-x | t/t4020-diff-external.sh | 2 | ||||
-rwxr-xr-x | t/t4027-diff-submodule.sh | 1 | ||||
-rwxr-xr-x | t/t4046-diff-unmerged.sh | 87 | ||||
-rwxr-xr-x | t/t5400-send-pack.sh | 4 | ||||
-rwxr-xr-x | t/t6060-merge-index.sh | 100 | ||||
-rwxr-xr-x | t/t7011-skip-worktree-reading.sh | 4 | ||||
-rwxr-xr-x | t/t7012-skip-worktree-writing.sh | 2 | ||||
-rwxr-xr-x | t/t7060-wtstatus.sh | 62 | ||||
-rwxr-xr-x | t/t7600-merge.sh | 32 | ||||
-rwxr-xr-x | t/t7610-mergetool.sh | 290 | ||||
-rwxr-xr-x | t/t8002-blame.sh | 2 | ||||
-rw-r--r-- | t/test-lib.sh | 3 |
25 files changed, 721 insertions, 52 deletions
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh index d34208cc27..c56a77d237 100644 --- a/t/annotate-tests.sh +++ b/t/annotate-tests.sh @@ -1,5 +1,5 @@ # This file isn't used as a test script directly, instead it is -# sourced from t8001-annotate.sh and t8001-blame.sh. +# sourced from t8001-annotate.sh and t8002-blame.sh. check_count () { head= @@ -124,3 +124,14 @@ test_expect_success \ test_expect_success \ 'some edit' \ 'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1' + +test_expect_success \ + 'an obfuscated email added' \ + 'echo "No robots allowed" > file.new && + cat file >> file.new && + mv file.new file && + GIT_AUTHOR_NAME="E" GIT_AUTHOR_EMAIL="E at test dot git" git commit -a -m "norobots"' + +test_expect_success \ + 'obfuscated email parsed' \ + 'check_count A 1 B 1 B1 1 B2 1 "A U Thor" 1 C 1 D 1 E 1' diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index ff747f8229..4fd83a667a 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -6,7 +6,7 @@ test_description='Test git update-ref and basic ref logging' . ./test-lib.sh -Z=0000000000000000000000000000000000000000 +Z=$_z40 test_expect_success setup ' diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index da6252b117..63849836c8 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -7,7 +7,6 @@ test_expect_success 'setup' ' EMPTY_TREE=$(git write-tree) && EMPTY_BLOB=$(git hash-object -t blob --stdin </dev/null) && CHANGED_BLOB=$(echo changed | git hash-object -t blob --stdin) && - ZEROES=0000000000000000000000000000000000000000 && EMPTY_BLOB7=$(echo $EMPTY_BLOB | sed "s/\(.......\).*/\1/") && CHANGED_BLOB7=$(echo $CHANGED_BLOB | sed "s/\(.......\).*/\1/") && @@ -239,10 +238,10 @@ test_expect_success '_gently() groks relative GIT_DIR & GIT_WORK_TREE' ' test_expect_success 'diff-index respects work tree under .git dir' ' cat >diff-index-cached.expected <<-EOF && - :000000 100644 $ZEROES $EMPTY_BLOB A sub/dir/tracked + :000000 100644 $_z40 $EMPTY_BLOB A sub/dir/tracked EOF cat >diff-index.expected <<-EOF && - :000000 100644 $ZEROES $ZEROES A sub/dir/tracked + :000000 100644 $_z40 $_z40 A sub/dir/tracked EOF ( @@ -258,7 +257,7 @@ test_expect_success 'diff-index respects work tree under .git dir' ' test_expect_success 'diff-files respects work tree under .git dir' ' cat >diff-files.expected <<-EOF && - :100644 100644 $EMPTY_BLOB $ZEROES M sub/dir/tracked + :100644 100644 $EMPTY_BLOB $_z40 M sub/dir/tracked EOF ( diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh index 4a6396f9e3..0843a1c13b 100755 --- a/t/t1506-rev-parse-diagnosis.sh +++ b/t/t1506-rev-parse-diagnosis.sh @@ -8,8 +8,11 @@ exec </dev/null test_did_you_mean () { - printf "fatal: Path '$2$3' $4, but not ${5:-'$3'}.\n" >expected && - printf "Did you mean '$1:$2$3'${2:+ aka '$1:./$3'}?\n" >>expected && + sq="'" && + cat >expected <<-EOF && + fatal: Path '$2$3' $4, but not ${5:-$sq$3$sq}. + Did you mean '$1:$2$3'${2:+ aka $sq$1:./$3$sq}? + EOF test_cmp expected error } diff --git a/t/t2011-checkout-invalid-head.sh b/t/t2011-checkout-invalid-head.sh index 15ebdc26eb..300f8bf25c 100755 --- a/t/t2011-checkout-invalid-head.sh +++ b/t/t2011-checkout-invalid-head.sh @@ -15,7 +15,7 @@ test_expect_success 'checkout should not start branch from a tree' ' ' test_expect_success 'checkout master from invalid HEAD' ' - echo 0000000000000000000000000000000000000000 >.git/HEAD && + echo $_z40 >.git/HEAD && git checkout master -- ' diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh index 856e7da1f2..7206c13741 100755 --- a/t/t2200-add-update.sh +++ b/t/t2200-add-update.sh @@ -149,31 +149,21 @@ test_expect_success 'add -u resolves unmerged paths' ' echo 3 >path1 && echo 2 >path3 && echo 2 >path5 && - git add -u && - git ls-files -s path1 path2 path3 path4 path5 path6 >actual && - { - echo "100644 $three 0 path1" - echo "100644 $one 1 path3" - echo "100644 $one 1 path4" - echo "100644 $one 3 path5" - echo "100644 $one 3 path6" - } >expect && - test_cmp expect actual && - # Bonus tests. Explicit resolving - git add path3 path5 && + # Explicit resolving by adding removed paths should fail test_must_fail git add path4 && test_must_fail git add path6 && - git rm path4 && - git rm path6 && - git ls-files -s "path?" >actual && + # "add -u" should notice removals no matter what stages + # the index entries are in. + git add -u && + git ls-files -s path1 path2 path3 path4 path5 path6 >actual && { echo "100644 $three 0 path1" echo "100644 $two 0 path3" echo "100644 $two 0 path5" - } >expect - + } >expect && + test_cmp expect actual ' test_expect_success '"add -u non-existent" should fail' ' diff --git a/t/t2201-add-update-typechange.sh b/t/t2201-add-update-typechange.sh index 2e8f702452..954fc51e5b 100755 --- a/t/t2201-add-update-typechange.sh +++ b/t/t2201-add-update-typechange.sh @@ -4,8 +4,6 @@ test_description='more git add -u' . ./test-lib.sh -_z40=0000000000000000000000000000000000000000 - test_expect_success setup ' >xyzzy && _empty=$(git hash-object --stdin <xyzzy) && diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 286a2a6869..463ef1909f 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -46,7 +46,7 @@ test_expect_success \ 'git branch a/b/c && test -f .git/refs/heads/a/b/c' cat >expect <<EOF -0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master +$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master EOF test_expect_success \ 'git branch -l d/e/f should create a branch and a log' \ @@ -230,7 +230,7 @@ test_expect_success \ # Keep this test last, as it changes the current branch cat >expect <<EOF -0000000000000000000000000000000000000000 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master +$_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master EOF test_expect_success \ 'git checkout -b g/h/i -l should create a branch and a log' \ diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh index 19341e5ca1..08201e2331 100755 --- a/t/t3409-rebase-preserve-merges.sh +++ b/t/t3409-rebase-preserve-merges.sh @@ -27,7 +27,17 @@ export GIT_AUTHOR_EMAIL # \ # B2 <-- origin/topic # -# In both cases, 'topic' is rebased onto 'origin/topic'. +# Clone 3 (no-ff merge): +# +# A1--A2--B3 <-- origin/master +# \ +# B1------M <-- topic +# \ / +# \--A3 <-- topic2 +# \ +# B2 <-- origin/topic +# +# In all cases, 'topic' is rebased onto 'origin/topic'. test_expect_success 'setup for merge-preserving rebase' \ 'echo First > A && @@ -61,6 +71,16 @@ test_expect_success 'setup for merge-preserving rebase' \ git commit -m "Merge origin/master into topic" ) && + git clone ./. clone3 && + ( + cd clone3 && + git checkout -b topic2 origin/topic && + echo Sixth > A && + git commit -a -m "Modify A3" && + git checkout -b topic origin/topic && + git merge --no-ff topic2 + ) && + git checkout topic && echo Fourth >> B && git commit -a -m "Modify B2" @@ -93,4 +113,14 @@ test_expect_success '--continue works after a conflict' ' ) ' +test_expect_success 'rebase -p preserves no-ff merges' ' + ( + cd clone3 && + git fetch && + git rebase -p origin/topic && + test 3 = $(git rev-list --all --pretty=oneline | grep "Modify A" | wc -l) && + test 1 = $(git rev-list --all --pretty=oneline | grep "Merge branch" | wc -l) + ) +' + test_done diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index cd093bd347..9fd28bcf34 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -240,11 +240,10 @@ test_expect_success 'refresh index before checking if it is up-to-date' ' test_expect_success 'choking "git rm" should not let it die with cruft' ' git reset -q --hard && - H=0000000000000000000000000000000000000000 && i=0 && while test $i -lt 12000 do - echo "100644 $H 0 some-file-$i" + echo "100644 $_z40 0 some-file-$i" i=$(( $i + 1 )) done | git update-index --index-info && git rm -n "some-file-*" | :; diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index d6327e7c74..9e236f9cc0 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -82,10 +82,9 @@ EOF ' test_expect_success PERL 'setup fake editor' ' - cat >fake_editor.sh <<EOF - EOF + >fake_editor.sh && chmod a+x fake_editor.sh && - test_set_editor "$(pwd)/fake_editor.sh" && + test_set_editor "$(pwd)/fake_editor.sh" ' test_expect_success PERL 'dummy edit works' ' @@ -295,4 +294,40 @@ test_expect_success PERL 'deleting an empty file' ' test_cmp expected diff ' +test_expect_success PERL 'split hunk setup' ' + git reset --hard && + for i in 10 20 30 40 50 60 + do + echo $i + done >test && + git add test && + test_tick && + git commit -m test && + + for i in 10 15 20 21 22 23 24 30 40 50 60 + do + echo $i + done >test +' + +test_expect_success PERL 'split hunk "add -p (edit)"' ' + # Split, say Edit and do nothing. Then: + # + # 1. Broken version results in a patch that does not apply and + # only takes [y/n] (edit again) so the first q is discarded + # and then n attempts to discard the edit. Repeat q enough + # times to get out. + # + # 2. Correct version applies the (not)edited version, and asks + # about the next hunk, against wich we say q and program + # exits. + for a in s e q n q q + do + echo $a + done | + EDITOR=: git add -p && + git diff >actual && + ! grep "^+15" actual +' + test_done diff --git a/t/t4002-diff-basic.sh b/t/t4002-diff-basic.sh index 9fb8ca06a8..a5e8b83083 100755 --- a/t/t4002-diff-basic.sh +++ b/t/t4002-diff-basic.sh @@ -126,15 +126,12 @@ cat >.test-recursive-AB <<\EOF :100644 100644 3fdbe17fd013303a2e981e1ca1c6cd6e72789087 7e09d6a3a14bd630913e8c75693cea32157b606d M Z/NM EOF -x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' -x40="$x40$x40$x40$x40$x40$x40$x40$x40" -z40='0000000000000000000000000000000000000000' cmp_diff_files_output () { # diff-files never reports additions. Also it does not fill in the # object ID for the changed files because it wants you to look at the # filesystem. sed <"$2" >.test-tmp \ - -e '/^:000000 /d;s/'$x40'\( [MCRNDU][0-9]*\) /'$z40'\1 /' && + -e '/^:000000 /d;s/'$_x40'\( [MCRNDU][0-9]*\) /'$_z40'\1 /' && test_cmp "$1" .test-tmp } diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh index c3cdb52053..dd406c44b5 100755 --- a/t/t4014-format-patch.sh +++ b/t/t4014-format-patch.sh @@ -793,4 +793,46 @@ test_expect_success 'format-patch wraps extremely long headers (rfc2047)' ' test_cmp expect subject ' +check_author() { + echo content >>file && + git add file && + GIT_AUTHOR_NAME=$1 git commit -m author-check && + git format-patch --stdout -1 >patch && + grep ^From: patch >actual && + test_cmp expect actual +} + +cat >expect <<'EOF' +From: "Foo B. Bar" <author@example.com> +EOF +test_expect_success 'format-patch quotes dot in headers' ' + check_author "Foo B. Bar" +' + +cat >expect <<'EOF' +From: "Foo \"The Baz\" Bar" <author@example.com> +EOF +test_expect_success 'format-patch quotes double-quote in headers' ' + check_author "Foo \"The Baz\" Bar" +' + +cat >expect <<'EOF' +From: =?UTF-8?q?"F=C3=B6o=20B.=20Bar"?= <author@example.com> +EOF +test_expect_success 'rfc2047-encoded headers also double-quote 822 specials' ' + check_author "Föo B. Bar" +' + +cat >expect <<'EOF' +Subject: header with . in it +EOF +test_expect_success 'subject lines do not have 822 atom-quoting' ' + echo content >>file && + git add file && + git commit -m "header with . in it" && + git format-patch -k -1 --stdout >patch && + grep ^Subject: patch >actual && + test_cmp expect actual +' + test_done diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh index a7602cf923..083f62d1d6 100755 --- a/t/t4020-diff-external.sh +++ b/t/t4020-diff-external.sh @@ -4,8 +4,6 @@ test_description='external diff interface test' . ./test-lib.sh -_z40=0000000000000000000000000000000000000000 - test_expect_success setup ' test_tick && diff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh index 241a74d2a2..518bf9524e 100755 --- a/t/t4027-diff-submodule.sh +++ b/t/t4027-diff-submodule.sh @@ -5,7 +5,6 @@ test_description='difference in submodules' . ./test-lib.sh . "$TEST_DIRECTORY"/diff-lib.sh -_z40=0000000000000000000000000000000000000000 test_expect_success setup ' test_tick && test_create_repo sub && diff --git a/t/t4046-diff-unmerged.sh b/t/t4046-diff-unmerged.sh new file mode 100755 index 0000000000..25d50a654a --- /dev/null +++ b/t/t4046-diff-unmerged.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +test_description='diff with unmerged index entries' +. ./test-lib.sh + +test_expect_success setup ' + for i in 0 1 2 3 + do + blob=$(echo $i | git hash-object --stdin) && + eval "blob$i=$blob" && + eval "m$i=\"100644 \$blob$i $i\"" || break + done && + paths= && + for b in o x + do + for o in o x + do + for t in o x + do + path="$b$o$t" && + case "$path" in ooo) continue ;; esac + paths="$paths$path " && + p=" $path" && + case "$b" in x) echo "$m1$p" ;; esac && + case "$o" in x) echo "$m2$p" ;; esac && + case "$t" in x) echo "$m3$p" ;; esac || + break + done || break + done || break + done >ls-files-s.expect && + git update-index --index-info <ls-files-s.expect && + git ls-files -s >ls-files-s.actual && + test_cmp ls-files-s.expect ls-files-s.actual +' + +test_expect_success 'diff-files -0' ' + for path in $paths + do + >"$path" && + echo ":000000 100644 $_z40 $_z40 U $path" + done >diff-files-0.expect && + git diff-files -0 >diff-files-0.actual && + test_cmp diff-files-0.expect diff-files-0.actual +' + +test_expect_success 'diff-files -1' ' + for path in $paths + do + >"$path" && + echo ":000000 100644 $_z40 $_z40 U $path" && + case "$path" in + x??) echo ":100644 100644 $blob1 $_z40 M $path" + esac + done >diff-files-1.expect && + git diff-files -1 >diff-files-1.actual && + test_cmp diff-files-1.expect diff-files-1.actual +' + +test_expect_success 'diff-files -2' ' + for path in $paths + do + >"$path" && + echo ":000000 100644 $_z40 $_z40 U $path" && + case "$path" in + ?x?) echo ":100644 100644 $blob2 $_z40 M $path" + esac + done >diff-files-2.expect && + git diff-files -2 >diff-files-2.actual && + test_cmp diff-files-2.expect diff-files-2.actual && + git diff-files >diff-files-default-2.actual && + test_cmp diff-files-2.expect diff-files-default-2.actual +' + +test_expect_success 'diff-files -3' ' + for path in $paths + do + >"$path" && + echo ":000000 100644 $_z40 $_z40 U $path" && + case "$path" in + ??x) echo ":100644 100644 $blob3 $_z40 M $path" + esac + done >diff-files-3.expect && + git diff-files -3 >diff-files-3.actual && + test_cmp diff-files-3.expect diff-files-3.actual +' + +test_done diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh index b0b2684a1f..0eace37a03 100755 --- a/t/t5400-send-pack.sh +++ b/t/t5400-send-pack.sh @@ -190,7 +190,7 @@ test_expect_success 'pushing explicit refspecs respects forcing' ' +refs/heads/master:refs/heads/master ) && parent_head=$(cd parent && git rev-parse --verify master) && - child_head=$(cd parent && git rev-parse --verify master) && + child_head=$(cd child && git rev-parse --verify master) && test "$parent_head" = "$child_head" ' @@ -210,7 +210,7 @@ test_expect_success 'pushing wildcard refspecs respects forcing' ' "+refs/heads/*:refs/heads/*" ) && parent_head=$(cd parent && git rev-parse --verify master) && - child_head=$(cd parent && git rev-parse --verify master) && + child_head=$(cd child && git rev-parse --verify master) && test "$parent_head" = "$child_head" ' diff --git a/t/t6060-merge-index.sh b/t/t6060-merge-index.sh new file mode 100755 index 0000000000..debadbd299 --- /dev/null +++ b/t/t6060-merge-index.sh @@ -0,0 +1,100 @@ +#!/bin/sh + +test_description='basic git merge-index / git-merge-one-file tests' +. ./test-lib.sh + +test_expect_success 'setup diverging branches' ' + for i in 1 2 3 4 5 6 7 8 9 10; do + echo $i + done >file && + git add file && + git commit -m base && + git tag base && + sed s/2/two/ <file >tmp && + mv tmp file && + git commit -a -m two && + git tag two && + git checkout -b other HEAD^ && + sed s/10/ten/ <file >tmp && + mv tmp file && + git commit -a -m ten && + git tag ten +' + +cat >expect-merged <<'EOF' +1 +two +3 +4 +5 +6 +7 +8 +9 +ten +EOF + +test_expect_success 'read-tree does not resolve content merge' ' + git read-tree -i -m base ten two && + echo file >expect && + git diff-files --name-only --diff-filter=U >unmerged && + test_cmp expect unmerged +' + +test_expect_success 'git merge-index git-merge-one-file resolves' ' + git merge-index git-merge-one-file -a && + git diff-files --name-only --diff-filter=U >unmerged && + >expect && + test_cmp expect unmerged && + test_cmp expect-merged file && + git cat-file blob :file >file-index && + test_cmp expect-merged file-index +' + +test_expect_success 'setup bare merge' ' + git clone --bare . bare.git && + (cd bare.git && + GIT_INDEX_FILE=$PWD/merge.index && + export GIT_INDEX_FILE && + git read-tree -i -m base ten two + ) +' + +test_expect_success 'merge-one-file fails without a work tree' ' + (cd bare.git && + GIT_INDEX_FILE=$PWD/merge.index && + export GIT_INDEX_FILE && + test_must_fail git merge-index git-merge-one-file -a + ) +' + +test_expect_success 'merge-one-file respects GIT_WORK_TREE' ' + (cd bare.git && + mkdir work && + GIT_WORK_TREE=$PWD/work && + export GIT_WORK_TREE && + GIT_INDEX_FILE=$PWD/merge.index && + export GIT_INDEX_FILE && + git merge-index git-merge-one-file -a && + git cat-file blob :file >work/file-index + ) && + test_cmp expect-merged bare.git/work/file && + test_cmp expect-merged bare.git/work/file-index +' + +test_expect_success 'merge-one-file respects core.worktree' ' + mkdir subdir && + git clone . subdir/child && + (cd subdir && + GIT_DIR=$PWD/child/.git && + export GIT_DIR && + git config core.worktree "$PWD/child" && + git read-tree -i -m base ten two && + git merge-index git-merge-one-file -a && + git cat-file blob :file >file-index + ) && + test_cmp expect-merged subdir/child/file && + test_cmp expect-merged subdir/file-index +' + +test_done diff --git a/t/t7011-skip-worktree-reading.sh b/t/t7011-skip-worktree-reading.sh index bb4066f767..8f3b54d826 100755 --- a/t/t7011-skip-worktree-reading.sh +++ b/t/t7011-skip-worktree-reading.sh @@ -24,7 +24,7 @@ H sub/2 EOF NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 -ZERO_SHA0=0000000000000000000000000000000000000000 + setup_absent() { test -f 1 && rm 1 git update-index --remove 1 && @@ -120,7 +120,7 @@ test_expect_success 'grep with skip-worktree file' ' test "$(git grep --no-ext-grep test)" = "1:test" ' -echo ":000000 100644 $ZERO_SHA0 $NULL_SHA1 A 1" > expected +echo ":000000 100644 $_z40 $NULL_SHA1 A 1" > expected test_expect_success 'diff-index does not examine skip-worktree absent entries' ' setup_absent && git diff-index HEAD -- 1 > result && diff --git a/t/t7012-skip-worktree-writing.sh b/t/t7012-skip-worktree-writing.sh index 14fcb1c7f5..c4104009e1 100755 --- a/t/t7012-skip-worktree-writing.sh +++ b/t/t7012-skip-worktree-writing.sh @@ -54,7 +54,7 @@ test_expect_success 'read-tree removes worktree, dirty case' ' ' NULL_SHA1=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 -ZERO_SHA0=0000000000000000000000000000000000000000 + setup_absent() { test -f 1 && rm 1 git update-index --remove 1 && diff --git a/t/t7060-wtstatus.sh b/t/t7060-wtstatus.sh index b4fcc86a10..3a5d927f83 100755 --- a/t/t7060-wtstatus.sh +++ b/t/t7060-wtstatus.sh @@ -56,4 +56,66 @@ test_expect_success C_LOCALE_OUTPUT 'M/D conflict does not segfault' ' ) ' +test_expect_success 'rename & unmerged setup' ' + git rm -f -r . && + cat "$TEST_DIRECTORY/README" >ONE && + git add ONE && + test_tick && + git commit -m "One commit with ONE" && + + echo Modified >TWO && + cat ONE >>TWO && + cat ONE >>THREE && + git add TWO THREE && + sha1=$(git rev-parse :ONE) && + git rm --cached ONE && + ( + echo "100644 $sha1 1 ONE" && + echo "100644 $sha1 2 ONE" && + echo "100644 $sha1 3 ONE" + ) | git update-index --index-info && + echo Further >>THREE +' + +test_expect_success 'rename & unmerged status' ' + git status -suno >actual && + cat >expect <<-EOF && + UU ONE + AM THREE + A TWO + EOF + test_cmp expect actual +' + +test_expect_success 'git diff-index --cached shows 2 added + 1 unmerged' ' + cat >expected <<-EOF && + U ONE + A THREE + A TWO + EOF + git diff-index --cached --name-status HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'git diff-index --cached -M shows 2 added + 1 unmerged' ' + cat >expected <<-EOF && + U ONE + A THREE + A TWO + EOF + git diff-index --cached --name-status HEAD >actual && + test_cmp expected actual +' + +test_expect_success 'git diff-index --cached -C shows 2 copies + 1 unmerged' ' + cat >expected <<-EOF && + U ONE + C ONE THREE + C ONE TWO + EOF + git diff-index --cached -C --name-status HEAD | + sed "s/^C[0-9]*/C/g" >actual && + test_cmp expected actual +' + test_done diff --git a/t/t7600-merge.sh b/t/t7600-merge.sh index 87d5d788cb..5463f87e68 100755 --- a/t/t7600-merge.sh +++ b/t/t7600-merge.sh @@ -324,6 +324,38 @@ test_expect_success 'merge c1 with c2 (no-commit in config)' ' test_debug 'git log --graph --decorate --oneline --all' +test_expect_success 'merge c1 with c2 (log in config)' ' + git config branch.master.mergeoptions "" && + git reset --hard c1 && + git merge --log c2 && + git show -s --pretty=tformat:%s%n%b >expect && + + git config branch.master.mergeoptions --log && + git reset --hard c1 && + git merge c2 && + git show -s --pretty=tformat:%s%n%b >actual && + + test_cmp expect actual +' + +test_expect_success 'merge c1 with c2 (log in config gets overridden)' ' + ( + git config --remove-section branch.master + git config --remove-section merge + ) + git reset --hard c1 && + git merge c2 && + git show -s --pretty=tformat:%s%n%b >expect && + + git config branch.master.mergeoptions "--no-log" && + git config merge.log true && + git reset --hard c1 && + git merge c2 && + git show -s --pretty=tformat:%s%n%b >actual && + + test_cmp expect actual +' + test_expect_success 'merge c1 with c2 (squash in config)' ' git reset --hard c1 && git config branch.master.mergeoptions "--squash" && diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh index dc838c93bc..cbc08e3276 100755 --- a/t/t7610-mergetool.sh +++ b/t/t7610-mergetool.sh @@ -22,26 +22,50 @@ test_expect_success 'setup' ' echo master file14 >file14 && mkdir subdir && echo master sub >subdir/file3 && - git add file1 file1[1-4] subdir/file3 && + test_create_repo submod && + ( + cd submod && + : >foo && + git add foo && + git commit -m "Add foo" + ) && + git submodule add git://example.com/submod submod && + git add file1 file1[1-4] subdir/file3 .gitmodules submod && git commit -m "add initial versions" && git checkout -b branch1 master && + git submodule update -N && echo branch1 change >file1 && echo branch1 newfile >file2 && echo branch1 change file11 >file11 && echo branch1 change file13 >file13 && echo branch1 sub >subdir/file3 && - git add file1 file11 file13 file2 subdir/file3 && + ( + cd submod && + echo branch1 submodule >bar && + git add bar && + git commit -m "Add bar on branch1" && + git checkout -b submod-branch1 + ) && + git add file1 file11 file13 file2 subdir/file3 submod && git rm file12 && git commit -m "branch1 changes" && git checkout master && + git submodule update -N && echo master updated >file1 && echo master new >file2 && echo master updated file12 >file12 && echo master updated file14 >file14 && echo master new sub >subdir/file3 && - git add file1 file12 file14 file2 subdir/file3 && + ( + cd submod && + echo master submodule >bar && + git add bar && + git commit -m "Add bar on master" && + git checkout -b submod-master + ) && + git add file1 file12 file14 file2 subdir/file3 submod && git rm file11 && git commit -m "master updates" && @@ -52,15 +76,18 @@ test_expect_success 'setup' ' test_expect_success 'custom mergetool' ' git checkout -b test1 branch1 && + git submodule update -N && test_must_fail git merge master >/dev/null 2>&1 && ( yes "" | git mergetool file1 >/dev/null 2>&1 ) && ( yes "" | git mergetool file2 >/dev/null 2>&1 ) && ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && + ( yes "l" | git mergetool submod >/dev/null 2>&1 ) && test "$(cat file1)" = "master updated" && test "$(cat file2)" = "master new" && test "$(cat subdir/file3)" = "master new sub" && + test "$(cat submod/bar)" = "branch1 submodule" && git commit -m "branch1 resolved with mergetool" ' @@ -73,9 +100,12 @@ test_expect_success 'mergetool crlf' ' ( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && + ( yes "r" | git mergetool submod >/dev/null 2>&1 ) && test "$(printf x | cat file1 -)" = "$(printf "master updated\r\nx")" && test "$(printf x | cat file2 -)" = "$(printf "master new\r\nx")" && test "$(printf x | cat subdir/file3 -)" = "$(printf "master new sub\r\nx")" && + git submodule update -N && + test "$(cat submod/bar)" = "master submodule" && git commit -m "branch1 resolved with mergetool - autocrlf" && git config core.autocrlf false && git reset --hard @@ -83,6 +113,7 @@ test_expect_success 'mergetool crlf' ' test_expect_success 'mergetool in subdir' ' git checkout -b test3 branch1 && + git submodule update -N && ( cd subdir && test_must_fail git merge master >/dev/null 2>&1 && @@ -98,18 +129,22 @@ test_expect_success 'mergetool on file in parent dir' ' ( yes "" | git mergetool ../file2 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool ../file12 >/dev/null 2>&1 ) && + ( yes "l" | git mergetool ../submod >/dev/null 2>&1 ) && test "$(cat ../file1)" = "master updated" && test "$(cat ../file2)" = "master new" && + test "$(cat ../submod/bar)" = "branch1 submodule" && git commit -m "branch1 resolved with mergetool - subdir" ) ' test_expect_success 'mergetool skips autoresolved' ' git checkout -b test4 branch1 && + git submodule update -N && test_must_fail git merge master && test -n "$(git ls-files -u)" && ( yes "d" | git mergetool file11 >/dev/null 2>&1 ) && ( yes "d" | git mergetool file12 >/dev/null 2>&1 ) && + ( yes "l" | git mergetool submod >/dev/null 2>&1 ) && output="$(git mergetool --no-prompt)" && test "$output" = "No files need merging" && git reset --hard @@ -120,10 +155,13 @@ test_expect_success 'mergetool merges all from subdir' ' cd subdir && git config rerere.enabled false && test_must_fail git merge master && + ( yes "r" | git mergetool ../submod ) && ( yes "d" "d" | git mergetool --no-prompt ) && test "$(cat ../file1)" = "master updated" && test "$(cat ../file2)" = "master new" && test "$(cat file3)" = "master new sub" && + ( cd .. && git submodule update -N ) && + test "$(cat ../submod/bar)" = "master submodule" && git commit -m "branch2 resolved by mergetool from subdir" ) ' @@ -132,11 +170,257 @@ test_expect_success 'mergetool skips resolved paths when rerere is active' ' git config rerere.enabled true && rm -rf .git/rr-cache && git checkout -b test5 branch1 + git submodule update -N && test_must_fail git merge master >/dev/null 2>&1 && + ( yes "l" | git mergetool --no-prompt submod >/dev/null 2>&1 ) && ( yes "d" "d" | git mergetool --no-prompt >/dev/null 2>&1 ) && + git submodule update -N && output="$(yes "n" | git mergetool --no-prompt)" && test "$output" = "No files need merging" && git reset --hard ' +test_expect_success 'deleted vs modified submodule' ' + git checkout -b test6 branch1 && + git submodule update -N && + mv submod submod-movedaside && + git rm submod && + git commit -m "Submodule deleted from branch" && + git checkout -b test6.a test6 && + test_must_fail git merge master && + test -n "$(git ls-files -u)" && + ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "r" | git mergetool submod ) && + rmdir submod && mv submod-movedaside submod && + test "$(cat submod/bar)" = "branch1 submodule" && + git submodule update -N && + test "$(cat submod/bar)" = "master submodule" && + output="$(git mergetool --no-prompt)" && + test "$output" = "No files need merging" && + git commit -m "Merge resolved by keeping module" && + + mv submod submod-movedaside && + git checkout -b test6.b test6 && + git submodule update -N && + test_must_fail git merge master && + test -n "$(git ls-files -u)" && + ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "l" | git mergetool submod ) && + test ! -e submod && + output="$(git mergetool --no-prompt)" && + test "$output" = "No files need merging" && + git commit -m "Merge resolved by deleting module" && + + mv submod-movedaside submod && + git checkout -b test6.c master && + git submodule update -N && + test_must_fail git merge test6 && + test -n "$(git ls-files -u)" && + ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "r" | git mergetool submod ) && + test ! -e submod && + test -d submod.orig && + git submodule update -N && + output="$(git mergetool --no-prompt)" && + test "$output" = "No files need merging" && + git commit -m "Merge resolved by deleting module" && + mv submod.orig submod && + + git checkout -b test6.d master && + git submodule update -N && + test_must_fail git merge test6 && + test -n "$(git ls-files -u)" && + ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "l" | git mergetool submod ) && + test "$(cat submod/bar)" = "master submodule" && + git submodule update -N && + test "$(cat submod/bar)" = "master submodule" && + output="$(git mergetool --no-prompt)" && + test "$output" = "No files need merging" && + git commit -m "Merge resolved by keeping module" && + git reset --hard HEAD +' + +test_expect_success 'file vs modified submodule' ' + git checkout -b test7 branch1 && + git submodule update -N && + mv submod submod-movedaside && + git rm submod && + echo not a submodule >submod && + git add submod && + git commit -m "Submodule path becomes file" && + git checkout -b test7.a branch1 && + test_must_fail git merge master && + test -n "$(git ls-files -u)" && + ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "r" | git mergetool submod ) && + rmdir submod && mv submod-movedaside submod && + test "$(cat submod/bar)" = "branch1 submodule" && + git submodule update -N && + test "$(cat submod/bar)" = "master submodule" && + output="$(git mergetool --no-prompt)" && + test "$output" = "No files need merging" && + git commit -m "Merge resolved by keeping module" && + + mv submod submod-movedaside && + git checkout -b test7.b test7 && + test_must_fail git merge master && + test -n "$(git ls-files -u)" && + ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "l" | git mergetool submod ) && + git submodule update -N && + test "$(cat submod)" = "not a submodule" && + output="$(git mergetool --no-prompt)" && + test "$output" = "No files need merging" && + git commit -m "Merge resolved by keeping file" && + + git checkout -b test7.c master && + rmdir submod && mv submod-movedaside submod && + test ! -e submod.orig && + git submodule update -N && + test_must_fail git merge test7 && + test -n "$(git ls-files -u)" && + ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "r" | git mergetool submod ) && + test -d submod.orig && + git submodule update -N && + test "$(cat submod)" = "not a submodule" && + output="$(git mergetool --no-prompt)" && + test "$output" = "No files need merging" && + git commit -m "Merge resolved by keeping file" && + + git checkout -b test7.d master && + rmdir submod && mv submod.orig submod && + git submodule update -N && + test_must_fail git merge test7 && + test -n "$(git ls-files -u)" && + ( yes "" | git mergetool file1 file2 subdir/file3 >/dev/null 2>&1 ) && + ( yes "d" | git mergetool file11 file12 >/dev/null 2>&1 ) && + ( yes "l" | git mergetool submod ) && + test "$(cat submod/bar)" = "master submodule" && + git submodule update -N && + test "$(cat submod/bar)" = "master submodule" && + output="$(git mergetool --no-prompt)" && + test "$output" = "No files need merging" && + git commit -m "Merge resolved by keeping module" +' + +test_expect_success 'submodule in subdirectory' ' + git checkout -b test10 branch1 && + git submodule update -N && + ( + cd subdir && + test_create_repo subdir_module && + ( + cd subdir_module && + : >file15 && + git add file15 && + git commit -m "add initial versions" + ) + ) && + git submodule add git://example.com/subsubmodule subdir/subdir_module && + git add subdir/subdir_module && + git commit -m "add submodule in subdirectory" && + + git checkout -b test10.a test10 && + git submodule update -N && + ( + cd subdir/subdir_module && + git checkout -b super10.a && + echo test10.a >file15 && + git add file15 && + git commit -m "on branch 10.a" + ) && + git add subdir/subdir_module && + git commit -m "change submodule in subdirectory on test10.a" && + + git checkout -b test10.b test10 && + git submodule update -N && + ( + cd subdir/subdir_module && + git checkout -b super10.b && + echo test10.b >file15 && + git add file15 && + git commit -m "on branch 10.b" + ) && + git add subdir/subdir_module && + git commit -m "change submodule in subdirectory on test10.b" && + + test_must_fail git merge test10.a >/dev/null 2>&1 && + ( + cd subdir && + ( yes "l" | git mergetool subdir_module ) + ) && + test "$(cat subdir/subdir_module/file15)" = "test10.b" && + git submodule update -N && + test "$(cat subdir/subdir_module/file15)" = "test10.b" && + git reset --hard && + git submodule update -N && + + test_must_fail git merge test10.a >/dev/null 2>&1 && + ( yes "r" | git mergetool subdir/subdir_module ) && + test "$(cat subdir/subdir_module/file15)" = "test10.b" && + git submodule update -N && + test "$(cat subdir/subdir_module/file15)" = "test10.a" && + git commit -m "branch1 resolved with mergetool" && + rm -rf subdir/subdir_module +' + +test_expect_success 'directory vs modified submodule' ' + git checkout -b test11 branch1 && + mv submod submod-movedaside && + git rm submod && + mkdir submod && + echo not a submodule >submod/file16 && + git add submod/file16 && + git commit -m "Submodule path becomes directory" && + + test_must_fail git merge master && + test -n "$(git ls-files -u)" && + ( yes "l" | git mergetool submod ) && + test "$(cat submod/file16)" = "not a submodule" && + rm -rf submod.orig && + + git reset --hard && + test_must_fail git merge master && + test -n "$(git ls-files -u)" && + test ! -e submod.orig && + ( yes "r" | git mergetool submod ) && + test -d submod.orig && + test "$(cat submod.orig/file16)" = "not a submodule" && + rm -r submod.orig && + mv submod-movedaside/.git submod && + ( cd submod && git clean -f && git reset --hard ) && + git submodule update -N && + test "$(cat submod/bar)" = "master submodule" && + git reset --hard && rm -rf submod-movedaside && + + git checkout -b test11.c master && + git submodule update -N && + test_must_fail git merge test11 && + test -n "$(git ls-files -u)" && + ( yes "l" | git mergetool submod ) && + git submodule update -N && + test "$(cat submod/bar)" = "master submodule" && + + git reset --hard && + git submodule update -N && + test_must_fail git merge test11 && + test -n "$(git ls-files -u)" && + test ! -e submod.orig && + ( yes "r" | git mergetool submod ) && + test "$(cat submod/file16)" = "not a submodule" && + + git reset --hard master && + ( cd submod && git clean -f && git reset --hard ) && + git submodule update -N +' + test_done diff --git a/t/t8002-blame.sh b/t/t8002-blame.sh index d3a51e1269..e2896cffc1 100755 --- a/t/t8002-blame.sh +++ b/t/t8002-blame.sh @@ -8,7 +8,7 @@ PROG='git blame -c' PROG='git blame -c -e' test_expect_success 'Blame --show-email works' ' - check_count "<A@test.git>" 1 "<B@test.git>" 1 "<B1@test.git>" 1 "<B2@test.git>" 1 "<author@example.com>" 1 "<C@test.git>" 1 "<D@test.git>" 1 + check_count "<A@test.git>" 1 "<B@test.git>" 1 "<B1@test.git>" 1 "<B2@test.git>" 1 "<author@example.com>" 1 "<C@test.git>" 1 "<D@test.git>" 1 "<E at test dot git>" 1 ' test_done diff --git a/t/test-lib.sh b/t/test-lib.sh index abc47f3abc..8a274fbe79 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -89,6 +89,9 @@ esac _x05='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x05$_x05$_x05$_x05$_x05$_x05$_x05$_x05" +# Zero SHA-1 +_z40=0000000000000000000000000000000000000000 + # Each test should start with something like this, after copyright notices: # # test_description='Description of this test... |