On Sun, Apr 10, 2016 at 9:18 AM, Stephan Beyer <s-be...@gmx.net> wrote:
> 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-be...@gmx.net>
> ---
> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
> @@ -711,11 +711,17 @@ test_must_be_empty () {
> -# 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
>  }

The original code printed helpful diagnostic information when the
comparison failed, but the new code does not. Is this intentional?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to