summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Beyer <s-beyer@gmx.net>2016-04-10 15:18:56 +0200
committerJunio C Hamano <gitster@pobox.com>2016-04-15 12:27:29 -0700
commit60980a1eb28fe927f7917eac9848f0a2157d0e65 (patch)
tree5f1f1b6c67bc80fdc742686f2f5a4c1b247b8d15
parentf677edff43938eb1be09e1ab64f6835cf3e6ac61 (diff)
downloadgit-60980a1eb28fe927f7917eac9848f0a2157d0e65.tar.gz
t/test-lib-functions.sh: generalize test_cmp_rev
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@gmx.net>
-rw-r--r--t/test-lib-functions.sh14
1 files changed, 10 insertions, 4 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 8d99eb303f..8caf59ca4e 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