about summary refs log tree commit diff
path: root/third_party/git/t/t4060-diff-submodule-option-diff-format.sh
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/git/t/t4060-diff-submodule-option-diff-format.sh')
-rwxr-xr-xthird_party/git/t/t4060-diff-submodule-option-diff-format.sh126
1 files changed, 56 insertions, 70 deletions
diff --git a/third_party/git/t/t4060-diff-submodule-option-diff-format.sh b/third_party/git/t/t4060-diff-submodule-option-diff-format.sh
index fc8229c7260b..9dcb69df5c36 100755
--- a/third_party/git/t/t4060-diff-submodule-option-diff-format.sh
+++ b/third_party/git/t/t4060-diff-submodule-option-diff-format.sh
@@ -42,17 +42,6 @@ commit_file () {
 	git commit "$@" -m "Commit $*" >/dev/null
 }
 
-diff_cmp () {
-       for i in "$1" "$2"
-       do
-		sed -e 's/^index 0000000\.\.[0-9a-f]*/index 0000000..1234567/' \
-		-e 's/^index [0-9a-f]*\.\.[0-9a-f]*/index 1234567..89abcde/' \
-		"$i" >"$i.compare" || return 1
-       done &&
-       test_cmp "$1.compare" "$2.compare" &&
-       rm -f "$1.compare" "$2.compare"
-}
-
 test_expect_success 'setup repository' '
 	test_create_repo sm1 &&
 	add_file . foo &&
@@ -80,7 +69,7 @@ test_expect_success 'added submodule' '
 	@@ -0,0 +1 @@
 	+foo2
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'added submodule, set diff.submodule' '
@@ -104,7 +93,7 @@ test_expect_success 'added submodule, set diff.submodule' '
 	@@ -0,0 +1 @@
 	+foo2
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success '--submodule=short overrides diff.submodule' '
@@ -120,7 +109,7 @@ test_expect_success '--submodule=short overrides diff.submodule' '
 	@@ -0,0 +1 @@
 	+Subproject commit $fullhead1
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'diff.submodule does not affect plumbing' '
@@ -135,7 +124,7 @@ test_expect_success 'diff.submodule does not affect plumbing' '
 	@@ -0,0 +1 @@
 	+Subproject commit $fullhead1
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 commit_file sm1 &&
@@ -153,7 +142,7 @@ test_expect_success 'modified submodule(forward)' '
 	@@ -0,0 +1 @@
 	+foo3
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule(forward)' '
@@ -168,7 +157,7 @@ test_expect_success 'modified submodule(forward)' '
 	@@ -0,0 +1 @@
 	+foo3
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule(forward) --submodule' '
@@ -177,7 +166,7 @@ test_expect_success 'modified submodule(forward) --submodule' '
 	Submodule sm1 $head1..$head2:
 	  > Add foo3 ($added foo3)
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 fullhead2=$(cd sm1; git rev-parse --verify HEAD)
@@ -192,7 +181,7 @@ test_expect_success 'modified submodule(forward) --submodule=short' '
 	-Subproject commit $fullhead1
 	+Subproject commit $fullhead2
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 commit_file sm1 &&
@@ -221,7 +210,7 @@ test_expect_success 'modified submodule(backward)' '
 	@@ -1 +0,0 @@
 	-foo3
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 head4=$(add_file sm1 foo4 foo5)
@@ -258,7 +247,7 @@ test_expect_success 'modified submodule(backward and forward)' '
 	@@ -0,0 +1 @@
 	+foo5
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 commit_file sm1 &&
@@ -302,7 +291,7 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' '
 	@@ -0,0 +1 @@
 	+sm1
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'typechanged submodule(submodule->blob)' '
@@ -338,7 +327,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
 	@@ -0,0 +1 @@
 	+foo5
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 rm -rf sm1 &&
@@ -355,7 +344,7 @@ test_expect_success 'typechanged submodule(submodule->blob)' '
 	@@ -0,0 +1 @@
 	+sm1
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 rm -f sm1 &&
@@ -367,7 +356,7 @@ test_expect_success 'nonexistent commit' '
 	cat >expected <<-EOF &&
 	Submodule sm1 $head4...$head6 (commits not present)
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 commit_file
@@ -397,12 +386,11 @@ test_expect_success 'typechanged submodule(blob->submodule)' '
 	@@ -0,0 +1 @@
 	+foo7
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 commit_file sm1 &&
 test_expect_success 'submodule is up to date' '
-	head7=$(git -C sm1 rev-parse --short --verify HEAD) &&
 	git diff-index -p --submodule=diff HEAD >actual &&
 	test_must_be_empty actual
 '
@@ -413,7 +401,7 @@ test_expect_success 'submodule contains untracked content' '
 	cat >expected <<-EOF &&
 	Submodule sm1 contains untracked content
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'submodule contains untracked content (untracked ignored)' '
@@ -445,7 +433,7 @@ test_expect_success 'submodule contains untracked and modified content' '
 	-foo6
 	+new
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 # NOT OK
@@ -462,7 +450,7 @@ test_expect_success 'submodule contains untracked and modified content (untracke
 	-foo6
 	+new
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'submodule contains untracked and modified content (dirty ignored)' '
@@ -490,7 +478,7 @@ test_expect_success 'submodule contains modified content' '
 	-foo6
 	+new
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 (cd sm1; git commit -mchange foo6 >/dev/null) &&
@@ -498,7 +486,7 @@ head8=$(cd sm1; git rev-parse --short --verify HEAD) &&
 test_expect_success 'submodule is modified' '
 	git diff-index -p --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $head7..$head8:
+	Submodule sm1 17243c9..$head8:
 	diff --git a/sm1/foo6 b/sm1/foo6
 	index 462398b..3e75765 100644
 	--- a/sm1/foo6
@@ -507,7 +495,7 @@ test_expect_success 'submodule is modified' '
 	-foo6
 	+new
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule contains untracked content' '
@@ -515,7 +503,7 @@ test_expect_success 'modified submodule contains untracked content' '
 	git diff-index -p --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 contains untracked content
-	Submodule sm1 $head7..$head8:
+	Submodule sm1 17243c9..$head8:
 	diff --git a/sm1/foo6 b/sm1/foo6
 	index 462398b..3e75765 100644
 	--- a/sm1/foo6
@@ -524,13 +512,13 @@ test_expect_success 'modified submodule contains untracked content' '
 	-foo6
 	+new
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule contains untracked content (untracked ignored)' '
 	git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $head7..$head8:
+	Submodule sm1 17243c9..$head8:
 	diff --git a/sm1/foo6 b/sm1/foo6
 	index 462398b..3e75765 100644
 	--- a/sm1/foo6
@@ -539,13 +527,13 @@ test_expect_success 'modified submodule contains untracked content (untracked ig
 	-foo6
 	+new
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule contains untracked content (dirty ignored)' '
 	git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $head7..$head8:
+	Submodule sm1 17243c9..cfce562:
 	diff --git a/sm1/foo6 b/sm1/foo6
 	index 462398b..3e75765 100644
 	--- a/sm1/foo6
@@ -554,7 +542,7 @@ test_expect_success 'modified submodule contains untracked content (dirty ignore
 	-foo6
 	+new
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule contains untracked content (all ignored)' '
@@ -568,7 +556,7 @@ test_expect_success 'modified submodule contains untracked and modified content'
 	cat >expected <<-EOF &&
 	Submodule sm1 contains untracked content
 	Submodule sm1 contains modified content
-	Submodule sm1 $head7..$head8:
+	Submodule sm1 17243c9..cfce562:
 	diff --git a/sm1/foo6 b/sm1/foo6
 	index 462398b..dfda541 100644
 	--- a/sm1/foo6
@@ -578,7 +566,7 @@ test_expect_success 'modified submodule contains untracked and modified content'
 	+new
 	+modification
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule contains untracked and modified content (untracked ignored)' '
@@ -586,7 +574,7 @@ test_expect_success 'modified submodule contains untracked and modified content
 	git diff-index -p --ignore-submodules=untracked --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 contains modified content
-	Submodule sm1 $head7..$head8:
+	Submodule sm1 17243c9..cfce562:
 	diff --git a/sm1/foo6 b/sm1/foo6
 	index 462398b..e20e2d9 100644
 	--- a/sm1/foo6
@@ -597,14 +585,14 @@ test_expect_success 'modified submodule contains untracked and modified content
 	+modification
 	+modification
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule contains untracked and modified content (dirty ignored)' '
 	echo modification >> sm1/foo6 &&
 	git diff-index -p --ignore-submodules=dirty --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $head7..$head8:
+	Submodule sm1 17243c9..cfce562:
 	diff --git a/sm1/foo6 b/sm1/foo6
 	index 462398b..3e75765 100644
 	--- a/sm1/foo6
@@ -613,7 +601,7 @@ test_expect_success 'modified submodule contains untracked and modified content
 	-foo6
 	+new
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'modified submodule contains untracked and modified content (all ignored)' '
@@ -628,7 +616,7 @@ test_expect_success 'modified submodule contains modified content' '
 	git diff-index -p --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
 	Submodule sm1 contains modified content
-	Submodule sm1 $head7..$head8:
+	Submodule sm1 17243c9..cfce562:
 	diff --git a/sm1/foo6 b/sm1/foo6
 	index 462398b..ac466ca 100644
 	--- a/sm1/foo6
@@ -641,29 +629,29 @@ test_expect_success 'modified submodule contains modified content' '
 	+modification
 	+modification
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 rm -rf sm1
 test_expect_success 'deleted submodule' '
 	git diff-index -p --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $head7...0000000 (submodule deleted)
+	Submodule sm1 17243c9...0000000 (submodule deleted)
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'create second submodule' '
 	test_create_repo sm2 &&
-	head9=$(add_file sm2 foo8 foo9) &&
+	head7=$(add_file sm2 foo8 foo9) &&
 	git add sm2
 '
 
 test_expect_success 'multiple submodules' '
 	git diff-index -p --submodule=diff HEAD >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $head7...0000000 (submodule deleted)
-	Submodule sm2 0000000...$head9 (new submodule)
+	Submodule sm1 17243c9...0000000 (submodule deleted)
+	Submodule sm2 0000000...a5a65c9 (new submodule)
 	diff --git a/sm2/foo8 b/sm2/foo8
 	new file mode 100644
 	index 0000000..db9916b
@@ -679,13 +667,13 @@ test_expect_success 'multiple submodules' '
 	@@ -0,0 +1 @@
 	+foo9
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'path filter' '
 	git diff-index -p --submodule=diff HEAD sm2 >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm2 0000000...$head9 (new submodule)
+	Submodule sm2 0000000...a5a65c9 (new submodule)
 	diff --git a/sm2/foo8 b/sm2/foo8
 	new file mode 100644
 	index 0000000..db9916b
@@ -701,15 +689,15 @@ test_expect_success 'path filter' '
 	@@ -0,0 +1 @@
 	+foo9
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 commit_file sm2
 test_expect_success 'given commit' '
 	git diff-index -p --submodule=diff HEAD^ >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $head7...0000000 (submodule deleted)
-	Submodule sm2 0000000...$head9 (new submodule)
+	Submodule sm1 17243c9...0000000 (submodule deleted)
+	Submodule sm2 0000000...a5a65c9 (new submodule)
 	diff --git a/sm2/foo8 b/sm2/foo8
 	new file mode 100644
 	index 0000000..db9916b
@@ -725,7 +713,7 @@ test_expect_success 'given commit' '
 	@@ -0,0 +1 @@
 	+foo9
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'setup .git file for sm2' '
@@ -738,8 +726,8 @@ test_expect_success 'setup .git file for sm2' '
 test_expect_success 'diff --submodule=diff with .git file' '
 	git diff --submodule=diff HEAD^ >actual &&
 	cat >expected <<-EOF &&
-	Submodule sm1 $head7...0000000 (submodule deleted)
-	Submodule sm2 0000000...$head9 (new submodule)
+	Submodule sm1 17243c9...0000000 (submodule deleted)
+	Submodule sm2 0000000...a5a65c9 (new submodule)
 	diff --git a/sm2/foo8 b/sm2/foo8
 	new file mode 100644
 	index 0000000..db9916b
@@ -755,27 +743,25 @@ test_expect_success 'diff --submodule=diff with .git file' '
 	@@ -0,0 +1 @@
 	+foo9
 	EOF
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'setup nested submodule' '
 	git submodule add -f ./sm2 &&
 	git commit -a -m "add sm2" &&
 	git -C sm2 submodule add ../sm2 nested &&
-	git -C sm2 commit -a -m "nested sub" &&
-	head10=$(git -C sm2 rev-parse --short --verify HEAD)
+	git -C sm2 commit -a -m "nested sub"
 '
 
 test_expect_success 'move nested submodule HEAD' '
 	echo "nested content" >sm2/nested/file &&
 	git -C sm2/nested add file &&
-	git -C sm2/nested commit --allow-empty -m "new HEAD" &&
-	head11=$(git -C sm2/nested rev-parse --short --verify HEAD)
+	git -C sm2/nested commit --allow-empty -m "new HEAD"
 '
 
 test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' '
 	cat >expected <<-EOF &&
-	Submodule nested $head9..$head11:
+	Submodule nested a5a65c9..b55928c:
 	diff --git a/nested/file b/nested/file
 	new file mode 100644
 	index 0000000..ca281f5
@@ -786,13 +772,13 @@ test_expect_success 'diff --submodule=diff with moved nested submodule HEAD' '
 	EOF
 	git -C sm2 diff --submodule=diff >actual 2>err &&
 	test_must_be_empty err &&
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_expect_success 'diff --submodule=diff recurses into nested submodules' '
 	cat >expected <<-EOF &&
 	Submodule sm2 contains modified content
-	Submodule sm2 $head9..$head10:
+	Submodule sm2 a5a65c9..280969a:
 	diff --git a/sm2/.gitmodules b/sm2/.gitmodules
 	new file mode 100644
 	index 0000000..3a816b8
@@ -802,7 +788,7 @@ test_expect_success 'diff --submodule=diff recurses into nested submodules' '
 	+[submodule "nested"]
 	+	path = nested
 	+	url = ../sm2
-	Submodule nested 0000000...$head11 (new submodule)
+	Submodule nested 0000000...b55928c (new submodule)
 	diff --git a/sm2/nested/file b/sm2/nested/file
 	new file mode 100644
 	index 0000000..ca281f5
@@ -827,7 +813,7 @@ test_expect_success 'diff --submodule=diff recurses into nested submodules' '
 	EOF
 	git diff --submodule=diff >actual 2>err &&
 	test_must_be_empty err &&
-	diff_cmp expected actual
+	test_cmp expected actual
 '
 
 test_done