devtools: check for supported git version
PATCH 1/1 devtools: check for supported git version
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
--- devtools/parse-flow-support.sh | 6 ++++++ 1 file changed, 6 insertions(+)
devtools/parse-flow-support.sh +6 -0
@@ -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
Signature · 1 line
2.25.1
Quoted 25 lines · Ali Alnubani
The script
devtools/parse-flow-support.shuses 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 <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>--- devtools/parse-flow-support.sh | 6 ++++++ 1 file changed, 6 insertions(+)devtools/parse-flow-support.sh +0
-0
devtools/parse-flow-support.sh if [ -z "$dir" ]; then · line 17
Quoted 5 lines
devtools/parse-flow-support.sh +2
-0@@ -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?
Quoted 10 lines
devtools/parse-flow-support.sh +4
-1+ echo "git version >= 2.19 is required" >&2 + exit 1 +fi + # sorting order export LC_COLLATE=C --2.25.1
Signature · 1 line
David Marchand
PATCH v2 1/1 devtools: check for supported git version
In reply to Ali AlnubaniThe 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
---
Changes in v2:
- Refer to filename by $0 (Suggested by David Marchand).
devtools/parse-flow-support.sh | 6 ++++++ 1 file changed, 6 insertions(+)
devtools/parse-flow-support.sh +6 -0
@@ -13,6 +13,12 @@ if [ -z "$dir" ]; then exit 1 fi +# test git-grep for -o (--only-matching) option +if ! git grep -qo git -- $0 >/dev/null 2>&1; then + echo "git version >= 2.19 is required" >&2 + exit 1 +fi + # sorting order export LC_COLLATE=C
Signature · 1 line
2.25.1
Quoted 12 lines · Ali Alnubani
The script
devtools/parse-flow-support.shuses 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>...] [..]
Quoted 4 lines
[1] https://github.com/git/git/blob/v2.19.0/Documentation/RelNotes/2.19.0.txt
Signed-off-by Ali Alnubani <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>
I don't have a "non working" git, but the patch lgtm.
Signature · 1 line
David Marchand
Quoted 13 lines · David Marchand
Quoted 12 lines · Ali Alnubani
The script
devtools/parse-flow-support.shuses 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>...] [..]
Quoted 9 lines
Quoted 4 lines
[1] https://github.com/git/git/blob/v2.19.0/Documentation/RelNotes/2.19.0.txt
Signed-off-by Ali Alnubani <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>I don't have a "non working" git, but the patch lgtm.
Acked-by David Marchand <[email protected]>
+Chaoyong,
He had observed the problem, perhaps he can help to test.
Quoted 21 lines · David Marchand
Quoted 20 lines · Ali Alnubani
Quoted 18 lines
The script
devtools/parse-flow-support.shuses 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
.txtSigned-off-by Ali Alnubani <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>
Quoted 8 lines
Quoted 4 lines
I don't have a "non working" git, but the patch lgtm.
Acked-by David Marchand <[email protected]>+Chaoyong,
He had observed the problem, perhaps he can help to test.
I test in my host, it does work.
$ git --version git version 2.18.5
Before this patch:
$ ./devtools/check-doc-vs-code.sh
error: unknown switch `o'
usage: git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]
--cached search in index instead of in the work tree
...
repeat many times.After this patch:
$ ./devtools/check-doc-vs-code.sh git version >= 2.19 is required
Thomas Monjalon
Applied26/10/2022 10:34, Chaoyong He:
Quoted 43 lines
Quoted 21 lines · David Marchand
Quoted 20 lines · Ali Alnubani
Quoted 18 lines
The script
devtools/parse-flow-support.shuses 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
.txtSigned-off-by Ali Alnubani <[email protected]>Signed-off-by Thomas Monjalon <[email protected]>Quoted 8 lines
Quoted 4 lines
I don't have a "non working" git, but the patch lgtm.
Acked-by David Marchand <[email protected]>+Chaoyong,
He had observed the problem, perhaps he can help to test.
I test in my host, it does work.
$ git --version git version 2.18.5Before this patch:
$ ./devtools/check-doc-vs-code.sh error: unknown switch `o' usage: git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...] --cached search in index instead of in the work tree ... repeat many times.
Quoted 3 lines
After this patch:
$ ./devtools/check-doc-vs-code.sh git version >= 2.19 is required
Applied, thanks.