tests: fix and add lint for non-portable grep --file
The --file option to grep isn't in POSIX[1], but -f is[1]. Let's check for that in the future, and fix the portability regression in f237c8b6fe ("commit-graph: implement git-commit-graph write", 2018-04-02) that broke e.g. AIX. 1. http://pubs.opengroup.org/onlinepubs/009695399/utilities/grep.html Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Aug 24, 2018 at 15:20 UTC
4a3ed638027343cbfc47821973c2c3784a5c53ed
2 files changed
+2
-1
t/check-non-portable-shell.pl
+1
@@ -43,6 +43,7 @@ while (<>) {
43
/\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)';
44
/\bhead\s+-c\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)';
45
/(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)';
46
+ /\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)';
47
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
48
/^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
49
err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
t/t5318-commit-graph.sh
+1
-1
@@ -134,7 +134,7 @@ test_expect_success 'Add one more commit' '
134
git branch commits/8 &&
135
ls $objdir/pack | grep idx >existing-idx &&
136
git repack &&
137
- ls $objdir/pack| grep idx | grep -v --file=existing-idx >new-idx
137
+ ls $objdir/pack| grep idx | grep -v -f existing-idx >new-idx
138
'
139
140
# Current graph structure: