From: Stephan Beyer Date: Sun, 10 Apr 2016 13:18:56 GMT Subject: [PATCH v2 03/21] t/test-lib-functions.sh: generalize test_cmp_rev Message-ID: <1460294354-7031-4-git-send-email-s-beyer@gmx.net> In-Reply-To: <1460294354-7031-1-git-send-email-s-beyer@gmx.net> 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 --- 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