[PATCH v2 03/21] t/test-lib-functions.sh: generalize test_cmp_rev

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

 



test_cmp_rev() took exactly two parameters, the expected revision
and the revision to test. This commit generalizes this function
such that it takes any number of at least two revisions: the
expected one and a list of actual ones. The function returns true
if and only if at least one actual revision coincides with the
expected revision.

While at it, the side effect of generating two (temporary) files
is removed.

Signed-off-by: Stephan Beyer <s-beyer@xxxxxxx>
---
 t/test-lib-functions.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 8d99eb3..8caf59c 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -711,11 +711,17 @@ test_must_be_empty () {
 	fi
 }
 
-# Tests that its two parameters refer to the same revision
+# Tests that the first parameter refers to the same revision
+# of at least one other parameter
 test_cmp_rev () {
-	git rev-parse --verify "$1" >expect.rev &&
-	git rev-parse --verify "$2" >actual.rev &&
-	test_cmp expect.rev actual.rev
+	hash1="$(git rev-parse --verify "$1")" || return
+	shift
+	for rev
+	do
+		hash2="$(git rev-parse --verify "$rev")" || return
+		test "$hash1" = "$hash2" && return 0
+	done
+	return 1
 }
 
 # Print a sequence of numbers or letters in increasing order.  This is
-- 
2.8.1.137.g522756c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]