Re: [PATCH 02/16] bisect: add test for the bisect algorithm
From: Matthieu Moy <hidden>
Date: 2016-06-15 23:08:31
Christian Couder [off-list ref] writes:
Hi Stephan, On Fri, Feb 26, 2016 at 10:38 PM, Stephan Beyer [off-list ref] wrote:quoted
Hi Christian, On 02/26/2016 07:53 AM, Christian Couder wrote:quoted
quoted
+test_expect_success 'bisect algorithm works in linear history with an odd number of commits' ' + git bisect start A7 && + git bisect next && + test "$(git rev-parse HEAD)" = "$(git rev-parse A3)" \ + -o "$(git rev-parse HEAD)" = "$(git rev-parse A4)"I thought that we should not use "-o" and "-a" but instead "|| test" and "&& test".Why is this?I think it is because it might not be very portable, but I am not sure I remember well the previous discussions about this.
See Documentation/CodingGuidelines:
- We do not write our "test" command with "-a" and "-o" and use "&&"
or "||" to concatenate multiple "test" commands instead, because
the use of "-a/-o" is often error-prone. E.g.
test -n "$x" -a "$a" = "$b"
is buggy and breaks when $x is "=", but
test -n "$x" && test "$a" = "$b"
does not have such a problem.
Regarding portability, test -a/-o is not strictly POSIX (it's in the XSI
extension), but AFAIK implemented by all reasonable shells.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/