about summary refs log tree commit diff
path: root/third_party/git/t/t3415-rebase-autosquash.sh
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-25T23·06+0100
committerVincent Ambo <tazjin@google.com>2020-05-25T23·06+0100
commit93ba78d6f4632ef1c5228965e3edc8c0faf88c1e (patch)
tree85730c182a9f5f492ade8e8ccdb1c2356f9900bd /third_party/git/t/t3415-rebase-autosquash.sh
parent6f8fbf4aa4b1654ab27d4829e114538761817de0 (diff)
revert(3p/git): Revert merge of git upstream at v2.26.2 r/852
This causes cgit to serve error pages, which is undesirable.

This reverts commit 5229c9b232de5bfa959ad6ebbb4c8192ac513352, reversing
changes made to f2b211131f2347342dde63975b09cf603149f1a3.
Diffstat (limited to 'third_party/git/t/t3415-rebase-autosquash.sh')
-rwxr-xr-xthird_party/git/t/t3415-rebase-autosquash.sh153
1 files changed, 39 insertions, 114 deletions
diff --git a/third_party/git/t/t3415-rebase-autosquash.sh b/third_party/git/t/t3415-rebase-autosquash.sh
index 093de9005b76..22d218698e95 100755
--- a/third_party/git/t/t3415-rebase-autosquash.sh
+++ b/third_party/git/t/t3415-rebase-autosquash.sh
@@ -25,13 +25,6 @@ test_expect_success setup '
 '
 
 test_auto_fixup () {
-	no_squash= &&
-	if test "x$1" = 'x!'
-	then
-		no_squash=true
-		shift
-	fi &&
-
 	git reset --hard base &&
 	echo 1 >file1 &&
 	git add -u &&
@@ -42,19 +35,10 @@ test_auto_fixup () {
 	test_tick &&
 	git rebase $2 -i HEAD^^^ &&
 	git log --oneline >actual &&
-	if test -n "$no_squash"
-	then
-		test_line_count = 4 actual
-	else
-		test_line_count = 3 actual &&
-		git diff --exit-code $1 &&
-		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 = 1 actual
-	fi
+	test_line_count = 3 actual &&
+	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)' '
@@ -64,19 +48,12 @@ test_expect_success 'auto fixup (option)' '
 test_expect_success 'auto fixup (config)' '
 	git config rebase.autosquash true &&
 	test_auto_fixup final-fixup-config-true &&
-	test_auto_fixup ! fixup-config-true-no --no-autosquash &&
+	test_must_fail test_auto_fixup fixup-config-true-no --no-autosquash &&
 	git config rebase.autosquash false &&
-	test_auto_fixup ! final-fixup-config-false
+	test_must_fail test_auto_fixup final-fixup-config-false
 '
 
 test_auto_squash () {
-	no_squash= &&
-	if test "x$1" = 'x!'
-	then
-		no_squash=true
-		shift
-	fi &&
-
 	git reset --hard base &&
 	echo 1 >file1 &&
 	git add -u &&
@@ -87,19 +64,10 @@ test_auto_squash () {
 	test_tick &&
 	git rebase $2 -i HEAD^^^ &&
 	git log --oneline >actual &&
-	if test -n "$no_squash"
-	then
-		test_line_count = 4 actual
-	else
-		test_line_count = 3 actual &&
-		git diff --exit-code $1 &&
-		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
-	fi
+	test_line_count = 3 actual &&
+	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)' '
@@ -109,9 +77,9 @@ test_expect_success 'auto squash (option)' '
 test_expect_success 'auto squash (config)' '
 	git config rebase.autosquash true &&
 	test_auto_squash final-squash-config-true &&
-	test_auto_squash ! squash-config-true-no --no-autosquash &&
+	test_must_fail test_auto_squash squash-config-true-no --no-autosquash &&
 	git config rebase.autosquash false &&
-	test_auto_squash ! final-squash-config-false
+	test_must_fail test_auto_squash final-squash-config-false
 '
 
 test_expect_success 'misspelled auto squash' '
@@ -126,8 +94,7 @@ test_expect_success 'misspelled auto squash' '
 	git log --oneline >actual &&
 	test_line_count = 4 actual &&
 	git diff --exit-code final-missquash &&
-	git rev-list final-missquash...HEAD >list &&
-	test_must_be_empty list
+	test 0 = $(git rev-list final-missquash...HEAD | wc -l)
 '
 
 test_expect_success 'auto squash that matches 2 commits' '
@@ -146,15 +113,9 @@ test_expect_success 'auto squash that matches 2 commits' '
 	git log --oneline >actual &&
 	test_line_count = 4 actual &&
 	git diff --exit-code final-multisquash &&
-	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 1 = "$(git cat-file blob HEAD^^:file1)" &&
+	test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) &&
+	test 1 = $(git cat-file commit HEAD | grep first | wc -l)
 '
 
 test_expect_success 'auto squash that matches a commit after the squash' '
@@ -173,38 +134,25 @@ 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 &&
-	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 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)
 '
 test_expect_success 'auto squash that matches a sha1' '
 	git reset --hard base &&
 	echo 1 >file1 &&
 	git add -u &&
 	test_tick &&
-	oid=$(git rev-parse --short HEAD^) &&
-	git commit -m "squash! $oid" &&
+	git commit -m "squash! $(git rev-parse --short HEAD^)" &&
 	git tag final-shasquash &&
 	test_tick &&
 	git rebase --autosquash -i HEAD^^^ &&
 	git log --oneline >actual &&
 	test_line_count = 3 actual &&
 	git diff --exit-code final-shasquash &&
-	echo 1 >expect &&
-	git cat-file blob HEAD^:file1 >actual &&
-	test_cmp expect actual &&
-	git cat-file commit HEAD^ >commit &&
-	grep squash commit >actual &&
-	test_line_count = 1 actual
+	test 1 = "$(git cat-file blob HEAD^:file1)" &&
+	test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
 '
 
 test_expect_success 'auto squash that matches longer sha1' '
@@ -212,20 +160,15 @@ test_expect_success 'auto squash that matches longer sha1' '
 	echo 1 >file1 &&
 	git add -u &&
 	test_tick &&
-	oid=$(git rev-parse --short=11 HEAD^) &&
-	git commit -m "squash! $oid" &&
+	git commit -m "squash! $(git rev-parse --short=11 HEAD^)" &&
 	git tag final-longshasquash &&
 	test_tick &&
 	git rebase --autosquash -i HEAD^^^ &&
 	git log --oneline >actual &&
 	test_line_count = 3 actual &&
 	git diff --exit-code final-longshasquash &&
-	echo 1 >expect &&
-	git cat-file blob HEAD^:file1 >actual &&
-	test_cmp expect actual &&
-	git cat-file commit HEAD^ >commit &&
-	grep squash commit >actual &&
-	test_line_count = 1 actual
+	test 1 = "$(git cat-file blob HEAD^:file1)" &&
+	test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
 '
 
 test_auto_commit_flags () {
@@ -240,12 +183,8 @@ test_auto_commit_flags () {
 	git log --oneline >actual &&
 	test_line_count = 3 actual &&
 	git diff --exit-code final-commit-$1 &&
-	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
+	test 1 = "$(git cat-file blob HEAD^:file1)" &&
+	test $2 = $(git cat-file commit HEAD^ | grep first | wc -l)
 }
 
 test_expect_success 'use commit --fixup' '
@@ -271,15 +210,11 @@ test_auto_fixup_fixup () {
 	(
 		set_cat_todo_editor &&
 		test_must_fail git rebase --autosquash -i HEAD^^^^ >actual &&
-		head=$(git rev-parse --short HEAD) &&
-		parent1=$(git rev-parse --short HEAD^) &&
-		parent2=$(git rev-parse --short HEAD^^) &&
-		parent3=$(git rev-parse --short HEAD^^^) &&
 		cat >expected <<-EOF &&
-		pick $parent3 first commit
-		$1 $parent1 $1! first
-		$1 $head $1! $2! first
-		pick $parent2 second commit
+		pick $(git rev-parse --short HEAD^^^) first commit
+		$1 $(git rev-parse --short HEAD^) $1! first
+		$1 $(git rev-parse --short HEAD) $1! $2! first
+		pick $(git rev-parse --short HEAD^^) second commit
 		EOF
 		test_cmp expected actual
 	) &&
@@ -287,17 +222,13 @@ test_auto_fixup_fixup () {
 	git log --oneline >actual &&
 	test_line_count = 3 actual
 	git diff --exit-code "final-$1-$2" &&
-	echo 2 >expect &&
-	git cat-file blob HEAD^:file1 >actual &&
-	test_cmp expect actual &&
-	git cat-file commit HEAD^ >commit &&
-	grep first commit >actual &&
+	test 2 = "$(git cat-file blob HEAD^:file1)" &&
 	if test "$1" = "fixup"
 	then
-		test_line_count = 1 actual
+		test 1 = $(git cat-file commit HEAD^ | grep first | wc -l)
 	elif test "$1" = "squash"
 	then
-		test_line_count = 3 actual
+		test 3 = $(git cat-file commit HEAD^ | grep first | wc -l)
 	else
 		false
 	fi
@@ -325,25 +256,19 @@ test_expect_success C_LOCALE_OUTPUT 'autosquash with custom inst format' '
 	echo 2 >file1 &&
 	git add -u &&
 	test_tick &&
-	oid=$(git rev-parse --short HEAD^) &&
-	git commit -m "squash! $oid" &&
+	git commit -m "squash! $(git rev-parse --short HEAD^)" &&
 	echo 1 >file1 &&
 	git add -u &&
 	test_tick &&
-	subject=$(git log -n 1 --format=%s HEAD~2) &&
-	git commit -m "squash! $subject" &&
+	git commit -m "squash! $(git log -n 1 --format=%s HEAD~2)" &&
 	git tag final-squash-instFmt &&
 	test_tick &&
 	git rebase --autosquash -i HEAD~4 &&
 	git log --oneline >actual &&
 	test_line_count = 3 actual &&
 	git diff --exit-code final-squash-instFmt &&
-	echo 1 >expect &&
-	git cat-file blob HEAD^:file1 >actual &&
-	test_cmp expect actual &&
-	git cat-file commit HEAD^ >commit &&
-	grep squash commit >actual &&
-	test_line_count = 2 actual
+	test 1 = "$(git cat-file blob HEAD^:file1)" &&
+	test 2 = $(git cat-file commit HEAD^ | grep squash | wc -l)
 '
 
 test_expect_success 'autosquash with empty custom instructionFormat' '