devtools: check for supported git version
Checks
Commit Message
The script devtools/parse-flow-support.sh uses the git-grep
option (-o, --only-matching), which is only supported from
git version 2.19 and onwards.[1]
The script now exits early providing a clear message to the user
about the required git version instead of showing the following
error messages multiple times:
error: unknown switch `o'
usage: git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]
[..]
[1] https://github.com/git/git/blob/v2.19.0/Documentation/RelNotes/2.19.0.txt
Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
devtools/parse-flow-support.sh | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Mon, Oct 24, 2022 at 5:38 PM Ali Alnubani <alialnu@nvidia.com> wrote:
>
> The script devtools/parse-flow-support.sh uses the git-grep
> option (-o, --only-matching), which is only supported from
> git version 2.19 and onwards.[1]
>
> The script now exits early providing a clear message to the user
> about the required git version instead of showing the following
> error messages multiple times:
> error: unknown switch `o'
> usage: git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]
> [..]
>
> [1] https://github.com/git/git/blob/v2.19.0/Documentation/RelNotes/2.19.0.txt
>
> Signed-off-by: Ali Alnubani <alialnu@nvidia.com>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> devtools/parse-flow-support.sh | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/devtools/parse-flow-support.sh b/devtools/parse-flow-support.sh
> index 63c0b20e23..9c322249da 100755
> --- a/devtools/parse-flow-support.sh
> +++ b/devtools/parse-flow-support.sh
> @@ -13,6 +13,12 @@ if [ -z "$dir" ]; then
> exit 1
> fi
>
> +# test git-grep for -o (--only-matching) option
> +if ! git grep -qo git -- devtools/parse-flow-support.sh >/dev/null 2>&1; then
Would it work with $0, to refer to the script itself?
> + echo "git version >= 2.19 is required" >&2
> + exit 1
> +fi
> +
> # sorting order
> export LC_COLLATE=C
>
> --
> 2.25.1
>
@@ -13,6 +13,12 @@ if [ -z "$dir" ]; then
exit 1
fi
+# test git-grep for -o (--only-matching) option
+if ! git grep -qo git -- devtools/parse-flow-support.sh >/dev/null 2>&1; then
+ echo "git version >= 2.19 is required" >&2
+ exit 1
+fi
+
# sorting order
export LC_COLLATE=C