[PATCH v4 26/27] t7700: make references to SHA-1 generic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make the test more hash-agnostic by renaming variables from "sha1" to
"oid" (case-insensitively). Also, replace the regex, `[0-9a-f]\{40\}`
with `$OID_REGEX`.

Signed-off-by: Denton Liu <liu.denton@xxxxxxxxx>
---
 t/t7700-repack.sh | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/t/t7700-repack.sh b/t/t7700-repack.sh
index 2493cc4e9b..d96b1a5949 100755
--- a/t/t7700-repack.sh
+++ b/t/t7700-repack.sh
@@ -6,31 +6,31 @@ test_description='git repack works correctly'
 
 commit_and_pack () {
 	test_commit "$@" 1>&2 &&
-	SHA1=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack </dev/null) &&
-	echo pack-${SHA1}.pack
+	OID=$(git pack-objects --all --unpacked --incremental .git/objects/pack/pack </dev/null) &&
+	echo pack-${OID}.pack
 }
 
 test_no_missing_in_packs () {
 	myidx=$(ls -1 .git/objects/pack/*.idx) &&
 	test_path_is_file "$myidx" &&
 	git verify-pack -v alt_objects/pack/*.idx >orig.raw &&
-	grep "^[0-9a-f]\{40\}" orig.raw | cut -d" " -f1 | sort >orig &&
+	grep "^$OID_REGEX" orig.raw | cut -d" " -f1 | sort >orig &&
 	git verify-pack -v $myidx >dest.raw &&
 	cut -d" " -f1 dest.raw | sort >dest &&
 	comm -23 orig dest >missing &&
 	test_must_be_empty missing
 }
 
-# we expect $packsha1 and $objsha1 to be defined
+# we expect $packoid and $objoid to be defined
 test_has_duplicate_object () {
 	want_duplicate_object="$1"
 	found_duplicate_object=false
 	for p in .git/objects/pack/*.idx
 	do
 		idx=$(basename $p)
-		test "pack-$packsha1.idx" = "$idx" && continue
+		test "pack-$packoid.idx" = "$idx" && continue
 		git verify-pack -v $p >packlist || return $?
-		if grep "^$objsha1" packlist
+		if grep "^$objoid" packlist
 		then
 			found_duplicate_object=true
 			echo "DUPLICATE OBJECT FOUND"
@@ -51,11 +51,11 @@ test_expect_success 'objects in packs marked .keep are not repacked' '
 	git rev-list --objects --all | grep -v file2 |
 		git pack-objects pack &&
 	# The second pack will contain the excluded object
-	packsha1=$(git rev-list --objects --all | grep file2 |
+	packoid=$(git rev-list --objects --all | grep file2 |
 		git pack-objects pack) &&
-	>pack-$packsha1.keep &&
-	objsha1=$(git verify-pack -v pack-$packsha1.idx | head -n 1 |
-		sed -e "s/^\([0-9a-f]\{40\}\).*/\1/") &&
+	>pack-$packoid.keep &&
+	objoid=$(git verify-pack -v pack-$packoid.idx | head -n 1 |
+		sed -e "s/^\($OID_REGEX\).*/\1/") &&
 	mv pack-* .git/objects/pack/ &&
 	git repack -A -d -l &&
 	git prune-packed &&
@@ -63,13 +63,13 @@ test_expect_success 'objects in packs marked .keep are not repacked' '
 '
 
 test_expect_success 'writing bitmaps via command-line can duplicate .keep objects' '
-	# build on $objsha1, $packsha1, and .keep state from previous
+	# build on $objoid, $packoid, and .keep state from previous
 	git repack -Adbl &&
 	test_has_duplicate_object true
 '
 
 test_expect_success 'writing bitmaps via config can duplicate .keep objects' '
-	# build on $objsha1, $packsha1, and .keep state from previous
+	# build on $objoid, $packoid, and .keep state from previous
 	git -c repack.writebitmaps=true repack -Adl &&
 	test_has_duplicate_object true
 '
@@ -78,7 +78,7 @@ test_expect_success 'loose objects in alternate ODB are not repacked' '
 	mkdir alt_objects &&
 	echo $(pwd)/alt_objects >.git/objects/info/alternates &&
 	echo content3 >file3 &&
-	objsha1=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
+	objoid=$(GIT_OBJECT_DIRECTORY=alt_objects git hash-object -w file3) &&
 	git add file3 &&
 	test_tick &&
 	git commit -m commit_file3 &&
@@ -124,7 +124,7 @@ test_expect_success 'packed obs in alternate ODB kept pack are repacked' '
 test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
 	rm -f alt_objects/pack/*.keep &&
 	mv .git/objects/pack/* alt_objects/pack/ &&
-	csha1=$(git rev-parse HEAD^{commit}) &&
+	coid=$(git rev-parse HEAD^{commit}) &&
 	git reset --hard HEAD^ &&
 	test_tick &&
 	git reflog expire --expire=$test_tick --expire-unreachable=$test_tick --all &&
@@ -135,14 +135,14 @@ test_expect_success 'packed unreachable obs in alternate ODB are not loosened' '
 	rm -f .git/objects/pack/* &&
 	mv pack-* .git/objects/pack/ &&
 	test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
-		grep "^$csha1 " | sort | uniq | wc -l) &&
+		grep "^$coid " | sort | uniq | wc -l) &&
 	echo >.git/objects/info/alternates &&
-	test_must_fail git show $csha1
+	test_must_fail git show $coid
 '
 
 test_expect_success 'local packed unreachable obs that exist in alternate ODB are not loosened' '
 	echo $(pwd)/alt_objects >.git/objects/info/alternates &&
-	echo "$csha1" | git pack-objects --non-empty --all --reflog pack &&
+	echo "$coid" | git pack-objects --non-empty --all --reflog pack &&
 	rm -f .git/objects/pack/* &&
 	mv pack-* .git/objects/pack/ &&
 	# The pack-objects call on the next line is equivalent to
@@ -152,9 +152,9 @@ test_expect_success 'local packed unreachable obs that exist in alternate ODB ar
 	rm -f .git/objects/pack/* &&
 	mv pack-* .git/objects/pack/ &&
 	test 0 = $(git verify-pack -v -- .git/objects/pack/*.idx |
-		grep "^$csha1 " | sort | uniq | wc -l) &&
+		grep "^$coid " | sort | uniq | wc -l) &&
 	echo >.git/objects/info/alternates &&
-	test_must_fail git show $csha1
+	test_must_fail git show $coid
 '
 
 test_expect_success 'objects made unreachable by grafts only are kept' '
-- 
2.24.0.504.g3cd56eb17d




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux