Test updates.
* dl/test-must-fail-fixes-2:
t4124: only mark git command with test_must_fail
t3507: use test_path_is_missing()
t3507: fix indentation
t3504: do check for conflict marker after failed cherry-pick
t3419: stop losing return code of git command
t3415: increase granularity of test_auto_{fixup,squash}()
t3415: stop losing return codes of git commands
t3310: extract common notes_merge_files_gone()
t3030: use test_path_is_missing()
t2018: replace "sha" with "oid"
t2018: don't lose return code of git commands
t2018: teach do_checkout() to accept `!` arg
t2018: be more discerning when checking for expected exit codes
t2018: improve style of if-statement
t2018: add space between function name and ()
t2018: remove trailing space from test description
git rev-parse --symbolic-full-name HEAD >ref.actual &&
test_cmp ref.expect ref.actual &&
echo "$exp_oid" >oid.expect &&
git rev-parse --verify HEAD >oid.actual &&
test_cmp oid.expect oid.actual
fi
}
test $exp_ref = $(git rev-parse --symbolic-full-name HEAD) &&
test $exp_sha = $(git rev-parse --verify HEAD)
test_dirty_unmergeable () {
test_expect_code 1 git diff --exit-code
}
test_dirty_unmergeable() {
! git diff --exit-code >/dev/null
test_dirty_unmergeable_discards_changes () {
git diff --exit-code
}
setup_dirty_unmergeable() {
setup_dirty_unmergeable () {
echo >>file1 change2
}
test_dirty_mergeable() {
! git diff --cached --exit-code >/dev/null
test_dirty_mergeable () {
test_expect_code 1 git diff --cached --exit-code
}
test_dirty_mergeable_discards_changes () {
git diff --cached --exit-code
}
setup_dirty_mergeable() {
setup_dirty_mergeable () {
echo >file2 file2 &&
git add file2
}
@ -82,7 +108,7 @@ test_expect_success 'checkout -b to a new branch, set to an explicit ref' '
@@ -82,7 +108,7 @@ test_expect_success 'checkout -b to a new branch, set to an explicit ref' '
test_expect_success 'checkout -b to a new branch with unmergeable changes fails' '
setup_dirty_unmergeable &&
test_must_fail do_checkout branch2 $HEAD1 &&
do_checkout ! branch2 $HEAD1 &&
test_dirty_unmergeable
'
@ -93,7 +119,7 @@ test_expect_success 'checkout -f -b to a new branch with unmergeable changes dis
@@ -93,7 +119,7 @@ test_expect_success 'checkout -f -b to a new branch with unmergeable changes dis
# still dirty and on branch1
do_checkout branch2 $HEAD1 "-f -b" &&
test_must_fail test_dirty_unmergeable
test_dirty_unmergeable_discards_changes
'
test_expect_success 'checkout -b to a new branch preserves mergeable changes' '
@ -111,12 +137,12 @@ test_expect_success 'checkout -f -b to a new branch with mergeable changes disca
@@ -111,12 +137,12 @@ test_expect_success 'checkout -f -b to a new branch with mergeable changes disca
test_when_finished git reset --hard HEAD &&
setup_dirty_mergeable &&
do_checkout branch2 $HEAD1 "-f -b" &&
test_must_fail test_dirty_mergeable
test_dirty_mergeable_discards_changes
'
test_expect_success 'checkout -b to an existing branch fails' '
test_when_finished git reset --hard HEAD &&
test_must_fail do_checkout branch2 $HEAD2
do_checkout ! branch2 $HEAD2
'
test_expect_success 'checkout -b to @{-1} fails with the right branch name' '
@ -140,7 +166,8 @@ test_expect_success 'checkout -B to a merge base' '
@@ -140,7 +166,8 @@ test_expect_success 'checkout -B to a merge base' '
'
test_expect_success 'checkout -B to an existing branch from detached HEAD resets branch to HEAD' '
git checkout $(git rev-parse --verify HEAD) &&
head=$(git rev-parse --verify HEAD) &&
git checkout "$head" &&
do_checkout branch2 "" -B
'
@ -155,14 +182,14 @@ test_expect_success 'checkout -B to an existing branch with unmergeable changes
@@ -155,14 +182,14 @@ test_expect_success 'checkout -B to an existing branch with unmergeable changes
git checkout branch1 &&
setup_dirty_unmergeable &&
test_must_fail do_checkout branch2 $HEAD1 -B &&
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_dirty_unmergeable_discards_changes
'
test_expect_success 'checkout -B to an existing branch preserves mergeable changes' '
@ -179,7 +206,7 @@ test_expect_success 'checkout -f -B to an existing branch with mergeable changes
@@ -179,7 +206,7 @@ test_expect_success 'checkout -f -B to an existing branch with mergeable changes
test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
test_must_be_empty output &&
notes_merge_files_gone &&
# Merge commit has pre-merge y and pre-merge z as parents
test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&
test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&
@ -397,9 +401,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol
@@ -397,9 +401,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol
test_expect_success 'abort notes merge' '
git notes merge --abort &&
# No .git/NOTES_MERGE_* files left
test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
test_must_be_empty output &&
notes_merge_files_gone &&
# m has not moved (still == y)
test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" &&
# Verify that other notes refs has not changed (w, x, y and z)
@ -464,9 +466,7 @@ EOF
@@ -464,9 +466,7 @@ EOF
echo "new note on 5th commit" > .git/NOTES_MERGE_WORKTREE/$commit_sha5 &&
# Finalize merge
git notes merge --commit &&
# No .git/NOTES_MERGE_* files left
test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
test_must_be_empty output &&
notes_merge_files_gone &&
# Merge commit has pre-merge y and pre-merge z as parents
test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&
test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&
@ -553,9 +553,7 @@ EOF
@@ -553,9 +553,7 @@ EOF
test_expect_success 'resolve situation by aborting the notes merge' '
git notes merge --abort &&
# No .git/NOTES_MERGE_* files left
test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
test_must_be_empty output &&
notes_merge_files_gone &&
# m has not moved (still == w)
test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&
# Verify that other notes refs has not changed (w, x, y and z)
test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) &&
test 1 = $(git cat-file commit HEAD | grep first | wc -l)
echo 1 >expect &&
git cat-file blob HEAD^^:file1 >actual &&
test_cmp expect actual &&
git cat-file commit HEAD^^ >commit &&
grep first commit >actual &&
test_line_count = 2 actual &&
git cat-file commit HEAD >commit &&
grep first commit >actual &&
test_line_count = 1 actual
'
test_expect_success 'auto squash that matches a commit after the squash' '
@ -134,25 +173,38 @@ test_expect_success 'auto squash that matches a commit after the squash' '
@@ -134,25 +173,38 @@ test_expect_success 'auto squash that matches a commit after the squash' '
git log --oneline >actual &&
test_line_count = 5 actual &&
git diff --exit-code final-presquash &&
test 0 = "$(git cat-file blob HEAD^^:file1)" &&
test 1 = "$(git cat-file blob HEAD^:file1)" &&
test 1 = $(git cat-file commit HEAD | grep third | wc -l) &&
test 1 = $(git cat-file commit HEAD^ | grep third | wc -l)
echo 0 >expect &&
git cat-file blob HEAD^^:file1 >actual &&
test_cmp expect actual &&
echo 1 >expect &&
git cat-file blob HEAD^:file1 >actual &&
test_cmp expect actual &&
git cat-file commit HEAD >commit &&
grep third commit >actual &&
test_line_count = 1 actual &&
git cat-file commit HEAD^ >commit &&
grep third commit >actual &&
test_line_count = 1 actual
'
test_expect_success 'auto squash that matches a sha1' '