userdiff: support Bash
authorVictor Engmark <victor@engmark.name>
Wed, 21 Oct 2020 23:45:08 +0000 (12:45 +1300)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Oct 2020 17:29:30 +0000 (10:29 -0700)
commit2ff6c34612057baccbd841524106c5a05f6be6d6
tree74d41a027c7ecc6297cc8553658006234cb93b44
parent69986e19ffcfb9af674ae5180689ab7bbf92ed28
userdiff: support Bash

Support POSIX, bashism and mixed function declarations, all four
compound command types, trailing comments and mixed whitespace.

Even though Bash allows locale-dependent characters in function names
<https://unix.stackexchange.com/a/245336/3645>, only detect function
names with characters allowed by POSIX.1-2017
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_235>
for simplicity. This should cover the vast majority of use cases, and
produces system-agnostic results.

Since a word pattern has to be specified, but there is no easy way to
know the default word pattern, use the default `IFS` characters for a
starter. A later patch can improve this.

Signed-off-by: Victor Engmark <victor@engmark.name>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 files changed:
Documentation/gitattributes.txt
t/t4018-diff-funcname.sh
t/t4018/bash-arithmetic-function [new file with mode: 0644]
t/t4018/bash-bashism-style-compact [new file with mode: 0644]
t/t4018/bash-bashism-style-function [new file with mode: 0644]
t/t4018/bash-bashism-style-whitespace [new file with mode: 0644]
t/t4018/bash-conditional-function [new file with mode: 0644]
t/t4018/bash-missing-parentheses [new file with mode: 0644]
t/t4018/bash-mixed-style-compact [new file with mode: 0644]
t/t4018/bash-mixed-style-function [new file with mode: 0644]
t/t4018/bash-nested-functions [new file with mode: 0644]
t/t4018/bash-other-characters [new file with mode: 0644]
t/t4018/bash-posix-style-compact [new file with mode: 0644]
t/t4018/bash-posix-style-function [new file with mode: 0644]
t/t4018/bash-posix-style-whitespace [new file with mode: 0644]
t/t4018/bash-subshell-function [new file with mode: 0644]
t/t4018/bash-trailing-comment [new file with mode: 0644]
userdiff.c