test z$foo = zbar (and Re: [PATCH 1/3] bisect: relax requirement for a working tree.)

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

 



Jon Seymour wrote:

> Now that bisection does not require checkout, it can work
> on bare repositories too.

Nice.

> --- a/git-bisect.sh
> +++ b/git-bisect.sh
> @@ -29,7 +29,6 @@ Please use "git help bisect" to get the full man page.'
>  OPTIONS_SPEC=
>  . git-sh-setup
>  . git-sh-i18n
> -require_work_tree
>  
>  _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
>  _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
> @@ -79,7 +78,12 @@ bisect_start() {
>  	orig_args=$(git rev-parse --sq-quote "$@")
>  	bad_seen=0
>  	eval=''
> -	mode=''
> +	if test "z$(git rev-parse --is-bare-repository)" != "zfalse"
> +	then
> +		mode='--no-checkout'
> +	else
> +		mode=''
> +	fi

Am I the only one who finds this

	test "z$foo" = "zbar"

style to be impossibly ugly?  It means every time someone considers
using the "test" utility, they decide "is this expression likely to
looks like an operator" and each time someone reads a use of the
"test" utility, there is a lingering question of whether that choice
was made correctly.  By contrast, if one follows the following simple
rules, everything works fine with the shells git supports:

 - _Do_ use the "z$foo" trick when using expr.
 - Do not use test's '(', '),' -a and -o operators; use && and ||
   instead.

The Autoconf manual says

	Posix also says that ‘test ! "string"’, ‘test -n "string"’ and
	‘test -z "string"’ work with any string, but many shells (such
	as Solaris, AIX 3.2, UNICOS 10.0.0.6, Digital Unix 4, etc.)
	get confused if string looks like an operator:

Notice that none of the mentioned shells is close enough to POSIX even
to support $( / ).  This is an area in which early POSIX work improved
shells immensely (the "-e" primary was introduced around the same
time).
--
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]