Re: [PATCH v3 3/3] t3700: add a test_mode_in_index helper function

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

 



Ingo Brückl <ib@xxxxxxxxxxxxxxx> writes:

Ingo Brückl <ib@xxxxxxxxxxxxxxx> writes:

> The case statement to check the file mode of a staged file appears
> a number of times.
>
> Simplify the test by utilizing a test_mode_in_index helper function.
>
> Signed-off-by: Ingo Brückl <ib@xxxxxxxxxxxxxxx>
> ---
>  t/t3700-add.sh | 54 ++++++++++++++++++++++--------------------------------
>  1 file changed, 22 insertions(+), 32 deletions(-)

Nice.

> diff --git a/t/t3700-add.sh b/t/t3700-add.sh
> index 1fa5dfd..7b98483 100755
> --- a/t/t3700-add.sh
> +++ b/t/t3700-add.sh
> @@ -7,6 +7,20 @@ test_description='Test of git add, including the -- option.'
>
>  . ./test-lib.sh
>
> +# Test the file mode "$1" of the file "$2" in the index.
> +test_mode_in_index () {
> +	case "$(git ls-files --stage "$2")" in
> +		$1\ *"$2")
> +			echo pass
> +			;;
> +		*)
> +			echo fail
> +			git ls-files --stage "$2"
> +			return 1
> +			;;
> +	esac
> +}

This case/esac is misindented, but no need to resend; I can fix it
up trivially while queuing the patches.  It may be both easier to
read and more robust to tweak the pattern like this, though:

# Test the file mode "$1" of the file "$2" in the index.
test_mode_in_index () {
	case "$(git ls-files --stage "$2")" in
	"$1 "*"	$2")
		echo pass
		;;
	*)
		echo fail
		git ls-files --stage "$2"
		return 1
		;;
	esac
}

Thanks.
--
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]