about summary refs log tree commit diff
path: root/third_party/git/t/t6046-merge-skip-unneeded-updates.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/t6046-merge-skip-unneeded-updates.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/t6046-merge-skip-unneeded-updates.sh')
-rwxr-xr-xthird_party/git/t/t6046-merge-skip-unneeded-updates.sh217
1 files changed, 105 insertions, 112 deletions
diff --git a/third_party/git/t/t6046-merge-skip-unneeded-updates.sh b/third_party/git/t/t6046-merge-skip-unneeded-updates.sh
index 1ddc9e6626b8..3a47623ed316 100755
--- a/third_party/git/t/t6046-merge-skip-unneeded-updates.sh
+++ b/third_party/git/t/t6046-merge-skip-unneeded-updates.sh
@@ -36,10 +36,10 @@ test_description="merge cases"
 #   Commit B: b_3
 #   Expected: b_2
 
-test_setup_1a () {
-	test_create_repo 1a_$1 &&
+test_expect_success '1a-setup: Modify(A)/Modify(B), change on B subset of A' '
+	test_create_repo 1a &&
 	(
-		cd 1a_$1 &&
+		cd 1a &&
 
 		test_write_lines 1 2 3 4 5 6 7 8 9 10 >b &&
 		git add b &&
@@ -62,24 +62,26 @@ test_setup_1a () {
 		test_tick &&
 		git commit -m "B"
 	)
-}
+'
 
-test_expect_success '1a-L: Modify(A)/Modify(B), change on B subset of A' '
-	test_setup_1a L &&
+test_expect_success '1a-check-L: Modify(A)/Modify(B), change on B subset of A' '
+	test_when_finished "git -C 1a reset --hard" &&
+	test_when_finished "git -C 1a clean -fd" &&
 	(
-		cd 1a_L &&
+		cd 1a &&
 
 		git checkout A^0 &&
 
-		test-tool chmtime --get -3600 b >old-mtime &&
+		test-tool chmtime =31337 b &&
+		test-tool chmtime -v +0 b >expected-mtime &&
 
 		GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
 
+		test_i18ngrep "Skipped b" out &&
 		test_must_be_empty err &&
 
-		# Make sure b was NOT updated
-		test-tool chmtime --get b >new-mtime &&
-		test_cmp old-mtime new-mtime &&
+		test-tool chmtime -v +0 b >actual-mtime &&
+		test_cmp expected-mtime actual-mtime &&
 
 		git ls-files -s >index_files &&
 		test_line_count = 1 index_files &&
@@ -94,20 +96,17 @@ test_expect_success '1a-L: Modify(A)/Modify(B), change on B subset of A' '
 	)
 '
 
-test_expect_success '1a-R: Modify(A)/Modify(B), change on B subset of A' '
-	test_setup_1a R &&
+test_expect_success '1a-check-R: Modify(A)/Modify(B), change on B subset of A' '
+	test_when_finished "git -C 1a reset --hard" &&
+	test_when_finished "git -C 1a clean -fd" &&
 	(
-		cd 1a_R &&
+		cd 1a &&
 
 		git checkout B^0 &&
 
-		test-tool chmtime --get -3600 b >old-mtime &&
 		GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
 
-		# Make sure b WAS updated
-		test-tool chmtime --get b >new-mtime &&
-		test $(cat old-mtime) -lt $(cat new-mtime) &&
-
+		test_i18ngrep "Auto-merging b" out &&
 		test_must_be_empty err &&
 
 		git ls-files -s >index_files &&
@@ -134,10 +133,10 @@ test_expect_success '1a-R: Modify(A)/Modify(B), change on B subset of A' '
 #   Commit B: c_1
 #   Expected: c_2
 
-test_setup_2a () {
-	test_create_repo 2a_$1 &&
+test_expect_success '2a-setup: Modify(A)/rename(B)' '
+	test_create_repo 2a &&
 	(
-		cd 2a_$1 &&
+		cd 2a &&
 
 		test_seq 1 10 >b &&
 		git add b &&
@@ -159,19 +158,20 @@ test_setup_2a () {
 		test_tick &&
 		git commit -m "B"
 	)
-}
+'
 
-test_expect_success '2a-L: Modify/rename, merge into modify side' '
-	test_setup_2a L &&
+test_expect_success '2a-check-L: Modify/rename, merge into modify side' '
+	test_when_finished "git -C 2a reset --hard" &&
+	test_when_finished "git -C 2a clean -fd" &&
 	(
-		cd 2a_L &&
+		cd 2a &&
 
 		git checkout A^0 &&
 
-		test_path_is_missing c &&
 		GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
 
-		test_path_is_file c &&
+		test_i18ngrep ! "Skipped c" out &&
+		test_must_be_empty err &&
 
 		git ls-files -s >index_files &&
 		test_line_count = 1 index_files &&
@@ -189,20 +189,17 @@ test_expect_success '2a-L: Modify/rename, merge into modify side' '
 	)
 '
 
-test_expect_success '2a-R: Modify/rename, merge into rename side' '
-	test_setup_2a R &&
+test_expect_success '2a-check-R: Modify/rename, merge into rename side' '
+	test_when_finished "git -C 2a reset --hard" &&
+	test_when_finished "git -C 2a clean -fd" &&
 	(
-		cd 2a_R &&
+		cd 2a &&
 
 		git checkout B^0 &&
 
-		test-tool chmtime --get -3600 c >old-mtime &&
 		GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
 
-		# Make sure c WAS updated
-		test-tool chmtime --get c >new-mtime &&
-		test $(cat old-mtime) -lt $(cat new-mtime) &&
-
+		test_i18ngrep ! "Skipped c" out &&
 		test_must_be_empty err &&
 
 		git ls-files -s >index_files &&
@@ -227,10 +224,10 @@ test_expect_success '2a-R: Modify/rename, merge into rename side' '
 #   Commit B: b_3
 #   Expected: c_2
 
-test_setup_2b () {
-	test_create_repo 2b_$1 &&
+test_expect_success '2b-setup: Rename+Mod(A)/Mod(B), B mods subset of A' '
+	test_create_repo 2b &&
 	(
-		cd 2b_$1 &&
+		cd 2b &&
 
 		test_write_lines 1 2 3 4 5 6 7 8 9 10 >b &&
 		git add b &&
@@ -254,23 +251,26 @@ test_setup_2b () {
 		test_tick &&
 		git commit -m "B"
 	)
-}
+'
 
-test_expect_success '2b-L: Rename+Mod(A)/Mod(B), B mods subset of A' '
-	test_setup_2b L &&
+test_expect_success '2b-check-L: Rename+Mod(A)/Mod(B), B mods subset of A' '
+	test_when_finished "git -C 2b reset --hard" &&
+	test_when_finished "git -C 2b clean -fd" &&
 	(
-		cd 2b_L &&
+		cd 2b &&
 
 		git checkout A^0 &&
 
-		test-tool chmtime --get -3600 c >old-mtime &&
+		test-tool chmtime =31337 c &&
+		test-tool chmtime -v +0 c >expected-mtime &&
+
 		GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
 
+		test_i18ngrep "Skipped c" out &&
 		test_must_be_empty err &&
 
-		# Make sure c WAS updated
-		test-tool chmtime --get c >new-mtime &&
-		test_cmp old-mtime new-mtime &&
+		test-tool chmtime -v +0 c >actual-mtime &&
+		test_cmp expected-mtime actual-mtime &&
 
 		git ls-files -s >index_files &&
 		test_line_count = 1 index_files &&
@@ -288,19 +288,17 @@ test_expect_success '2b-L: Rename+Mod(A)/Mod(B), B mods subset of A' '
 	)
 '
 
-test_expect_success '2b-R: Rename+Mod(A)/Mod(B), B mods subset of A' '
-	test_setup_2b R &&
+test_expect_success '2b-check-R: Rename+Mod(A)/Mod(B), B mods subset of A' '
+	test_when_finished "git -C 2b reset --hard" &&
+	test_when_finished "git -C 2b clean -fd" &&
 	(
-		cd 2b_R &&
+		cd 2b &&
 
 		git checkout B^0 &&
 
-		test_path_is_missing c &&
 		GIT_MERGE_VERBOSITY=3 git merge -s recursive A^0 >out 2>err &&
 
-		# Make sure c now present (and thus was updated)
-		test_path_is_file c &&
-
+		test_i18ngrep "Auto-merging c" out &&
 		test_must_be_empty err &&
 
 		git ls-files -s >index_files &&
@@ -334,7 +332,7 @@ test_expect_success '2b-R: Rename+Mod(A)/Mod(B), B mods subset of A' '
 #         skip the update, then we're in trouble.  This test verifies we do
 #         not make that particular mistake.
 
-test_setup_2c () {
+test_expect_success '2c-setup: Modify b & add c VS rename b->c' '
 	test_create_repo 2c &&
 	(
 		cd 2c &&
@@ -360,26 +358,21 @@ test_setup_2c () {
 		test_tick &&
 		git commit -m "B"
 	)
-}
+'
 
-test_expect_success '2c: Modify b & add c VS rename b->c' '
-	test_setup_2c &&
+test_expect_success '2c-check: Modify b & add c VS rename b->c' '
 	(
 		cd 2c &&
 
 		git checkout A^0 &&
 
-		test-tool chmtime --get -3600 c >old-mtime &&
 		GIT_MERGE_VERBOSITY=3 &&
 		export GIT_MERGE_VERBOSITY &&
 		test_must_fail git merge -s recursive B^0 >out 2>err &&
 
 		test_i18ngrep "CONFLICT (rename/add): Rename b->c" out &&
-		test_must_be_empty err &&
-
-		# Make sure c WAS updated
-		test-tool chmtime --get c >new-mtime &&
-		test $(cat old-mtime) -lt $(cat new-mtime)
+		test_i18ngrep ! "Skipped c" out &&
+		test_must_be_empty err
 
 		# FIXME: rename/add conflicts are horribly broken right now;
 		# when I get back to my patch series fixing it and
@@ -435,10 +428,10 @@ test_expect_success '2c: Modify b & add c VS rename b->c' '
 #   Commit B: bq_1, bar/whatever
 #   Expected: bar/{bq_2, whatever}
 
-test_setup_3a () {
-	test_create_repo 3a_$1 &&
+test_expect_success '3a-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
+	test_create_repo 3a &&
 	(
-		cd 3a_$1 &&
+		cd 3a &&
 
 		mkdir foo &&
 		test_seq 1 10 >bq &&
@@ -463,22 +456,21 @@ test_setup_3a () {
 		test_tick &&
 		git commit -m "B"
 	)
-}
+'
 
-test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
-	test_setup_3a L &&
+test_expect_success '3a-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
+	test_when_finished "git -C 3a reset --hard" &&
+	test_when_finished "git -C 3a clean -fd" &&
 	(
-		cd 3a_L &&
+		cd 3a &&
 
 		git checkout A^0 &&
 
-		test_path_is_missing bar/bq &&
 		GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
 
+		test_i18ngrep ! "Skipped bar/bq" out &&
 		test_must_be_empty err &&
 
-		test_path_is_file bar/bq &&
-
 		git ls-files -s >index_files &&
 		test_line_count = 2 index_files &&
 
@@ -495,20 +487,19 @@ test_expect_success '3a-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
 	)
 '
 
-test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
-	test_setup_3a R &&
+test_expect_success '3a-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
+	test_when_finished "git -C 3a reset --hard" &&
+	test_when_finished "git -C 3a clean -fd" &&
 	(
-		cd 3a_R &&
+		cd 3a &&
 
 		git checkout B^0 &&
 
-		test_path_is_missing bar/bq &&
 		GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err &&
 
+		test_i18ngrep ! "Skipped bar/bq" out &&
 		test_must_be_empty err &&
 
-		test_path_is_file bar/bq &&
-
 		git ls-files -s >index_files &&
 		test_line_count = 2 index_files &&
 
@@ -531,10 +522,10 @@ test_expect_success '3a-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
 #   Commit B: bq_2, bar/whatever
 #   Expected: bar/{bq_2, whatever}
 
-test_setup_3b () {
-	test_create_repo 3b_$1 &&
+test_expect_success '3b-setup: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
+	test_create_repo 3b &&
 	(
-		cd 3b_$1 &&
+		cd 3b &&
 
 		mkdir foo &&
 		test_seq 1 10 >bq &&
@@ -559,22 +550,21 @@ test_setup_3b () {
 		test_tick &&
 		git commit -m "B"
 	)
-}
+'
 
-test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
-	test_setup_3b L &&
+test_expect_success '3b-check-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
+	test_when_finished "git -C 3b reset --hard" &&
+	test_when_finished "git -C 3b clean -fd" &&
 	(
-		cd 3b_L &&
+		cd 3b &&
 
 		git checkout A^0 &&
 
-		test_path_is_missing bar/bq &&
 		GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive B^0 >out 2>err &&
 
+		test_i18ngrep ! "Skipped bar/bq" out &&
 		test_must_be_empty err &&
 
-		test_path_is_file bar/bq &&
-
 		git ls-files -s >index_files &&
 		test_line_count = 2 index_files &&
 
@@ -591,20 +581,19 @@ test_expect_success '3b-L: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
 	)
 '
 
-test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
-	test_setup_3b R &&
+test_expect_success '3b-check-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
+	test_when_finished "git -C 3b reset --hard" &&
+	test_when_finished "git -C 3b clean -fd" &&
 	(
-		cd 3b_R &&
+		cd 3b &&
 
 		git checkout B^0 &&
 
-		test_path_is_missing bar/bq &&
 		GIT_MERGE_VERBOSITY=3 git -c merge.directoryRenames=true merge -s recursive A^0 >out 2>err &&
 
+		test_i18ngrep ! "Skipped bar/bq" out &&
 		test_must_be_empty err &&
 
-		test_path_is_file bar/bq &&
-
 		git ls-files -s >index_files &&
 		test_line_count = 2 index_files &&
 
@@ -632,7 +621,7 @@ test_expect_success '3b-R: bq_1->foo/bq_2 on A, foo/->bar/ on B' '
 #   Working copy: b_4
 #   Expected: b_2 for merge, b_4 in working copy
 
-test_setup_4a () {
+test_expect_success '4a-setup: Change on A, change on B subset of A, dirty mods present' '
 	test_create_repo 4a &&
 	(
 		cd 4a &&
@@ -658,7 +647,7 @@ test_setup_4a () {
 		test_tick &&
 		git commit -m "B"
 	)
-}
+'
 
 # NOTE: For as long as we continue using unpack_trees() without index_only
 #   set to true, it will error out on a case like this claiming the the locally
@@ -666,23 +655,25 @@ test_setup_4a () {
 #   correct requires doing the merge in-memory first, then realizing that no
 #   updates to the file are necessary, and thus that we can just leave the path
 #   alone.
-test_expect_failure '4a: Change on A, change on B subset of A, dirty mods present' '
-	test_setup_4a &&
+test_expect_failure '4a-check: Change on A, change on B subset of A, dirty mods present' '
+	test_when_finished "git -C 4a reset --hard" &&
+	test_when_finished "git -C 4a clean -fd" &&
 	(
 		cd 4a &&
 
 		git checkout A^0 &&
 		echo "File rewritten" >b &&
 
-		test-tool chmtime --get -3600 b >old-mtime &&
+		test-tool chmtime =31337 b &&
+		test-tool chmtime -v +0 b >expected-mtime &&
 
 		GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
 
+		test_i18ngrep "Skipped b" out &&
 		test_must_be_empty err &&
 
-		# Make sure b was NOT updated
-		test-tool chmtime --get b >new-mtime &&
-		test_cmp old-mtime new-mtime &&
+		test-tool chmtime -v +0 b >actual-mtime &&
+		test_cmp expected-mtime actual-mtime &&
 
 		git ls-files -s >index_files &&
 		test_line_count = 1 index_files &&
@@ -704,7 +695,7 @@ test_expect_failure '4a: Change on A, change on B subset of A, dirty mods presen
 #   Working copy: c_4
 #   Expected: c_2
 
-test_setup_4b () {
+test_expect_success '4b-setup: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' '
 	test_create_repo 4b &&
 	(
 		cd 4b &&
@@ -731,25 +722,27 @@ test_setup_4b () {
 		test_tick &&
 		git commit -m "B"
 	)
-}
+'
 
-test_expect_success '4b: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' '
-	test_setup_4b &&
+test_expect_success '4b-check: Rename+Mod(A)/Mod(B), change on B subset of A, dirty mods present' '
+	test_when_finished "git -C 4b reset --hard" &&
+	test_when_finished "git -C 4b clean -fd" &&
 	(
 		cd 4b &&
 
 		git checkout A^0 &&
 		echo "File rewritten" >c &&
 
-		test-tool chmtime --get -3600 c >old-mtime &&
+		test-tool chmtime =31337 c &&
+		test-tool chmtime -v +0 c >expected-mtime &&
 
 		GIT_MERGE_VERBOSITY=3 git merge -s recursive B^0 >out 2>err &&
 
+		test_i18ngrep "Skipped c" out &&
 		test_must_be_empty err &&
 
-		# Make sure c was NOT updated
-		test-tool chmtime --get c >new-mtime &&
-		test_cmp old-mtime new-mtime &&
+		test-tool chmtime -v +0 c >actual-mtime &&
+		test_cmp expected-mtime actual-mtime &&
 
 		git ls-files -s >index_files &&
 		test_line_count = 1 index_files &&