]> git.ipfire.org Git - thirdparty/git.git/commitdiff
vimdiff: make script and tests work with zsh
authorbrian m. carlson <sandals@crustytoothpaste.net>
Fri, 26 Apr 2024 22:11:54 +0000 (22:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Apr 2024 23:31:46 +0000 (16:31 -0700)
When we process the $LAYOUT variable through sed, the result will end
with the character "#".  We then split it at the shell using IFS so that
we can process it a character at a time.

POSIX specifies that only "IFS white space shall be ignored at the
beginning and end of the input".  The hash mark is not a white space
character, so it is not ignored at the beginning and end of the input.

POSIX then specifies that "[e]ach occurrence in the input of an IFS
character that is not IFS white space, along with any adjacent IFS white
space, shall delimit a field, as described previously."  Thus, the final
hash mark delimits a field, and the final field is the empty string.

zsh implements this behavior strictly in compliance with POSIX (and
differently from most other shells), such that we end up with a trailing
empty field.  We don't want this empty field and processing it in the
normal way causes us to fail to parse properly and fail the tests with
"ERROR" entries, so let's just ignore it instead.  This is the behavior
of bash and dash anyway and what was clearly intended, so this is a
reasonable thing to do.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mergetools/vimdiff

index 97e376329bf510fce8c70c89a6de7a5465190d2b..734d15a03b025e537650ee535cfa8c5f70e2474c 100644 (file)
@@ -72,7 +72,6 @@ gen_cmd_aux () {
        nested=0
        nested_min=100
 
-
        # Step 1:
        #
        # Increase/decrease "start"/"end" indices respectively to get rid of
@@ -87,7 +86,7 @@ gen_cmd_aux () {
        IFS=#
        for c in $(echo "$LAYOUT" | sed 's:.:&#:g')
        do
-               if test "$c" = " "
+               if test -z "$c" || test "$c" = " "
                then
                        continue
                fi