зеркало из https://github.com/microsoft/git.git
Merge branch 'ab/portable-more'
Portability fix. * ab/portable-more: tests: fix non-portable iconv invocation tests: fix non-portable "${var:-"str"}" construct tests: fix and add lint for non-portable grep --file tests: fix version-specific portability issue in Perl JSON tests: use shorter labels in chainlint.sed for AIX sed tests: fix comment syntax in chainlint.sed for AIX sed tests: fix and add lint for non-portable seq tests: fix and add lint for non-portable head -c N
This commit is contained in:
Коммит
28d294a5ea
|
@ -97,11 +97,11 @@
|
|||
/<<[ ]*[-\\']*[A-Za-z0-9_]/ {
|
||||
s/^\(.*\)<<[ ]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<</
|
||||
s/[ ]*<<//
|
||||
:hereslurp
|
||||
:hered
|
||||
N
|
||||
/^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{
|
||||
s/\n.*$//
|
||||
bhereslurp
|
||||
bhered
|
||||
}
|
||||
s/^<[^>]*>//
|
||||
s/\n.*$//
|
||||
|
@ -131,9 +131,8 @@ b
|
|||
b
|
||||
|
||||
:subshell
|
||||
# bare "(" line?
|
||||
# bare "(" line? -- stash for later printing
|
||||
/^[ ]*([ ]*$/ {
|
||||
# stash for later printing
|
||||
h
|
||||
bnextline
|
||||
}
|
||||
|
@ -150,7 +149,7 @@ s/.*\n//
|
|||
|
||||
:slurp
|
||||
# incomplete line "...\"
|
||||
/\\$/bincomplete
|
||||
/\\$/bicmplte
|
||||
# multi-line quoted string "...\n..."?
|
||||
/"/bdqstring
|
||||
# multi-line quoted string '...\n...'? (but not contraction in string "it's")
|
||||
|
@ -172,7 +171,7 @@ s/.*\n//
|
|||
/"[^"]*#[^"]*"/!s/[ ]#.*$//
|
||||
}
|
||||
# one-liner "case ... esac"
|
||||
/^[ ]*case[ ]*..*esac/bcheckchain
|
||||
/^[ ]*case[ ]*..*esac/bchkchn
|
||||
# multi-line "case ... esac"
|
||||
/^[ ]*case[ ]..*[ ]in/bcase
|
||||
# multi-line "for ... done" or "while ... done"
|
||||
|
@ -201,32 +200,32 @@ s/.*\n//
|
|||
/^[ ]*fi[ ]*[<>|]/bdone
|
||||
/^[ ]*fi[ ]*)/bdone
|
||||
# nested one-liner "(...) &&"
|
||||
/^[ ]*(.*)[ ]*&&[ ]*$/bcheckchain
|
||||
/^[ ]*(.*)[ ]*&&[ ]*$/bchkchn
|
||||
# nested one-liner "(...)"
|
||||
/^[ ]*(.*)[ ]*$/bcheckchain
|
||||
/^[ ]*(.*)[ ]*$/bchkchn
|
||||
# nested one-liner "(...) >x" (or "2>x" or "<x" or "|x")
|
||||
/^[ ]*(.*)[ ]*[0-9]*[<>|]/bcheckchain
|
||||
/^[ ]*(.*)[ ]*[0-9]*[<>|]/bchkchn
|
||||
# nested multi-line "(...\n...)"
|
||||
/^[ ]*(/bnest
|
||||
# multi-line "{...\n...}"
|
||||
/^[ ]*{/bblock
|
||||
# closing ")" on own line -- exit subshell
|
||||
/^[ ]*)/bclosesolo
|
||||
/^[ ]*)/bclssolo
|
||||
# "$((...))" -- arithmetic expansion; not closing ")"
|
||||
/\$(([^)][^)]*))[^)]*$/bcheckchain
|
||||
/\$(([^)][^)]*))[^)]*$/bchkchn
|
||||
# "$(...)" -- command substitution; not closing ")"
|
||||
/\$([^)][^)]*)[^)]*$/bcheckchain
|
||||
/\$([^)][^)]*)[^)]*$/bchkchn
|
||||
# multi-line "$(...\n...)" -- command substitution; treat as nested subshell
|
||||
/\$([^)]*$/bnest
|
||||
# "=(...)" -- Bash array assignment; not closing ")"
|
||||
/=(/bcheckchain
|
||||
/=(/bchkchn
|
||||
# closing "...) &&"
|
||||
/)[ ]*&&[ ]*$/bclose
|
||||
# closing "...)"
|
||||
/)[ ]*$/bclose
|
||||
# closing "...) >x" (or "2>x" or "<x" or "|x")
|
||||
/)[ ]*[<>|]/bclose
|
||||
:checkchain
|
||||
:chkchn
|
||||
# mark suspect if line uses ";" internally rather than "&&" (but not ";" in a
|
||||
# string and not ";;" in one-liner "case...esac")
|
||||
/;/{
|
||||
|
@ -245,7 +244,7 @@ n
|
|||
bslurp
|
||||
|
||||
# found incomplete line "...\" -- slurp up next line
|
||||
:incomplete
|
||||
:icmplte
|
||||
N
|
||||
s/\\\n//
|
||||
bslurp
|
||||
|
@ -283,11 +282,11 @@ bfolded
|
|||
:heredoc
|
||||
s/^\(.*\)<<[ ]*[-\\']*\([A-Za-z0-9_][A-Za-z0-9_]*\)'*/<\2>\1<</
|
||||
s/[ ]*<<//
|
||||
:hereslurpsub
|
||||
:heredsub
|
||||
N
|
||||
/^<\([^>]*\)>.*\n[ ]*\1[ ]*$/!{
|
||||
s/\n.*$//
|
||||
bhereslurpsub
|
||||
bheredsub
|
||||
}
|
||||
s/^<[^>]*>//
|
||||
s/\n.*$//
|
||||
|
@ -317,43 +316,43 @@ x
|
|||
# is 'done' or 'fi' cuddled with ")" to close subshell?
|
||||
/done.*)/bclose
|
||||
/fi.*)/bclose
|
||||
bcheckchain
|
||||
bchkchn
|
||||
|
||||
# found nested multi-line "(...\n...)" -- pass through untouched
|
||||
:nest
|
||||
x
|
||||
:nestslurp
|
||||
:nstslurp
|
||||
n
|
||||
# closing ")" on own line -- stop nested slurp
|
||||
/^[ ]*)/bnestclose
|
||||
/^[ ]*)/bnstclose
|
||||
# comment -- not closing ")" if in comment
|
||||
/^[ ]*#/bnestcontinue
|
||||
/^[ ]*#/bnstcnt
|
||||
# "$((...))" -- arithmetic expansion; not closing ")"
|
||||
/\$(([^)][^)]*))[^)]*$/bnestcontinue
|
||||
/\$(([^)][^)]*))[^)]*$/bnstcnt
|
||||
# "$(...)" -- command substitution; not closing ")"
|
||||
/\$([^)][^)]*)[^)]*$/bnestcontinue
|
||||
/\$([^)][^)]*)[^)]*$/bnstcnt
|
||||
# closing "...)" -- stop nested slurp
|
||||
/)/bnestclose
|
||||
:nestcontinue
|
||||
/)/bnstclose
|
||||
:nstcnt
|
||||
x
|
||||
bnestslurp
|
||||
:nestclose
|
||||
bnstslurp
|
||||
:nstclose
|
||||
s/^/>>/
|
||||
# is it "))" which closes nested and parent subshells?
|
||||
/)[ ]*)/bslurp
|
||||
bcheckchain
|
||||
bchkchn
|
||||
|
||||
# found multi-line "{...\n...}" block -- pass through untouched
|
||||
:block
|
||||
x
|
||||
n
|
||||
# closing "}" -- stop block slurp
|
||||
/}/bcheckchain
|
||||
/}/bchkchn
|
||||
bblock
|
||||
|
||||
# found closing ")" on own line -- drop "suspect" from final line of subshell
|
||||
# since that line legitimately lacks "&&" and exit subshell loop
|
||||
:closesolo
|
||||
:clssolo
|
||||
x
|
||||
s/?!AMP?!//
|
||||
p
|
||||
|
|
|
@ -41,6 +41,9 @@ while (<>) {
|
|||
/^\s*[^#]\s*which\s/ and err 'which is not portable (use type)';
|
||||
/\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)';
|
||||
/\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"';
|
||||
|
|
|
@ -34,6 +34,9 @@ sub dump_item {
|
|||
} elsif (ref($value) eq 'HASH') {
|
||||
print "$label_in hash\n";
|
||||
dump_hash($label_in, $value);
|
||||
} elsif (ref $value) {
|
||||
my $bool = $value ? 1 : 0;
|
||||
print "$label_in $bool\n";
|
||||
} elsif (defined $value) {
|
||||
print "$label_in $value\n";
|
||||
} else {
|
||||
|
|
|
@ -203,7 +203,11 @@ test_expect_success 'error if encoding garbage is already in Git' '
|
|||
test_i18ngrep "error: BOM is required" err.out
|
||||
'
|
||||
|
||||
test_expect_success 'check roundtrip encoding' '
|
||||
test_lazy_prereq ICONV_SHIFT_JIS '
|
||||
iconv -f UTF-8 -t SHIFT-JIS </dev/null
|
||||
'
|
||||
|
||||
test_expect_success ICONV_SHIFT_JIS 'check roundtrip encoding' '
|
||||
test_when_finished "rm -f roundtrip.shift roundtrip.utf16" &&
|
||||
test_when_finished "git reset --hard HEAD" &&
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ do
|
|||
expect="$TEST_DIRECTORY/t4013/diff.$test"
|
||||
actual="$pfx-diff.$test"
|
||||
|
||||
test_expect_success "git $cmd # magic is ${magic:-"(not used)"}" '
|
||||
test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
|
||||
{
|
||||
echo "$ git $cmd"
|
||||
case "$magic" in
|
||||
|
|
|
@ -335,7 +335,7 @@ test_expect_success 'truncated bitmap fails gracefully' '
|
|||
git rev-list --use-bitmap-index --count --all >expect &&
|
||||
bitmap=$(ls .git/objects/pack/*.bitmap) &&
|
||||
test_when_finished "rm -f $bitmap" &&
|
||||
head -c 512 <$bitmap >$bitmap.tmp &&
|
||||
test_copy_bytes 512 <$bitmap >$bitmap.tmp &&
|
||||
mv -f $bitmap.tmp $bitmap &&
|
||||
git rev-list --use-bitmap-index --count --all >actual 2>stderr &&
|
||||
test_cmp expect actual &&
|
||||
|
|
|
@ -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 -f existing-idx >new-idx
|
||||
'
|
||||
|
||||
# Current graph structure:
|
||||
|
|
|
@ -46,7 +46,7 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
|
|||
test_commit -C server to_fetch &&
|
||||
|
||||
git init client &&
|
||||
for i in $(seq 7)
|
||||
for i in $(test_seq 7)
|
||||
do
|
||||
test_commit -C client c$i
|
||||
done &&
|
||||
|
@ -89,7 +89,7 @@ test_expect_success 'when two skips collide, favor the larger one' '
|
|||
test_commit -C server to_fetch &&
|
||||
|
||||
git init client &&
|
||||
for i in $(seq 11)
|
||||
for i in $(test_seq 11)
|
||||
do
|
||||
test_commit -C client c$i
|
||||
done &&
|
||||
|
@ -168,14 +168,14 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
|
|||
test_commit -C server to_fetch &&
|
||||
|
||||
git init client &&
|
||||
for i in $(seq 8)
|
||||
for i in $(test_seq 8)
|
||||
do
|
||||
git -C client checkout --orphan b$i &&
|
||||
test_commit -C client b$i.c0
|
||||
done &&
|
||||
for j in $(seq 19)
|
||||
for j in $(test_seq 19)
|
||||
do
|
||||
for i in $(seq 8)
|
||||
for i in $(test_seq 8)
|
||||
do
|
||||
git -C client checkout b$i &&
|
||||
test_commit -C client b$i.c$j
|
||||
|
@ -205,7 +205,7 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
|
|||
|
||||
# fetch-pack should thus not send any more commits in the b1 branch, but
|
||||
# should still send the others (in this test, just check b2).
|
||||
for i in $(seq 0 8)
|
||||
for i in $(test_seq 0 8)
|
||||
do
|
||||
have_not_sent b1.c$i
|
||||
done &&
|
||||
|
|
|
@ -176,7 +176,7 @@ test_expect_success 'setup repos for change-while-negotiating test' '
|
|||
git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" &&
|
||||
cd "$LOCAL_PRISTINE" &&
|
||||
git checkout -b side &&
|
||||
for i in $(seq 1 33); do test_commit s$i; done &&
|
||||
for i in $(test_seq 1 33); do test_commit s$i; done &&
|
||||
|
||||
# Add novel commits to upstream
|
||||
git checkout master &&
|
||||
|
@ -289,7 +289,7 @@ test_expect_success 'setup repos for fetching with ref-in-want tests' '
|
|||
git clone "file://$REPO" "$LOCAL_PRISTINE" &&
|
||||
cd "$LOCAL_PRISTINE" &&
|
||||
git checkout -b side &&
|
||||
for i in $(seq 1 33); do test_commit s$i; done &&
|
||||
for i in $(test_seq 1 33); do test_commit s$i; done &&
|
||||
|
||||
# Add novel commits to upstream
|
||||
git checkout master &&
|
||||
|
|
|
@ -867,7 +867,7 @@ then
|
|||
# handle only executables, unless they are shell libraries that
|
||||
# need to be in the exec-path.
|
||||
test -x "$1" ||
|
||||
test "# " = "$(head -c 2 <"$1")" ||
|
||||
test "# " = "$(test_copy_bytes 2 <"$1")" ||
|
||||
return;
|
||||
|
||||
base=$(basename "$1")
|
||||
|
@ -882,7 +882,7 @@ then
|
|||
# do not override scripts
|
||||
if test -x "$symlink_target" &&
|
||||
test ! -d "$symlink_target" &&
|
||||
test "#!" != "$(head -c 2 < "$symlink_target")"
|
||||
test "#!" != "$(test_copy_bytes 2 <"$symlink_target")"
|
||||
then
|
||||
symlink_target=../valgrind.sh
|
||||
fi
|
||||
|
|
Загрузка…
Ссылка в новой задаче