tests: fix and add lint for non-portable grep --file
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 24 Aug 2018 15:20:16 +0000 (15:20 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2018 21:07:32 +0000 (14:07 -0700)
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>
t/check-non-portable-shell.pl
t/t5318-commit-graph.sh
index 75f38298d7dbe1f9dec4099a2799b2c64d5e2e66..b45bdac688c40104dd42ef68a07690420d96c142 100755 (executable)
@@ -43,6 +43,7 @@ sub err {
        /\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)';
        /\bhead\s+-c\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)';
        /(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)';
+       /\bgrep\b.*--file\b/ and err 'grep --file FILE is not portable (use grep -f FILE)';
        /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
        /^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
                err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
index 3c1ffad49144d177a56f2f6a0b26612899e25adb..0c500f7ca2641a2752f5d4819bb11efcf5f588bf 100755 (executable)
@@ -134,7 +134,7 @@ test_expect_success 'Add one more commit' '
        git branch commits/8 &&
        ls $objdir/pack | grep idx >existing-idx &&
        git repack &&
-       ls $objdir/pack| grep idx | grep -v --file=existing-idx >new-idx
+       ls $objdir/pack| grep idx | grep -v -existing-idx >new-idx
 '
 
 # Current graph structure: