зеркало из https://github.com/microsoft/git.git
tr portability fixes
Specifying character ranges in tr differs between System V and POSIX. In System V, brackets are required (e.g., '[A-Z]'), whereas in POSIX they are not. We can mostly get around this by just using the bracket form for both sets, as in: tr '[A-Z] '[a-z]' in which case POSIX interpets this as "'[' becomes '['", which is OK. However, this doesn't work with multiple sequences, like: # rot13 tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]' where the POSIX version does not behave the same as the System V version. In this case, we must simply enumerate the sequence. This patch fixes problematic uses of tr in git scripts and test scripts in one of three ways: - if a single sequence, make sure it uses brackets - if multiple sequences, enumerate - if extra brackets (e.g., tr '[A]' 'a'), eliminate brackets Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
a6828f5361
Коммит
40a7ce64e1
|
@ -293,14 +293,14 @@ bisect_next() {
|
||||||
bisect_next_check good
|
bisect_next_check good
|
||||||
|
|
||||||
skip=$(git for-each-ref --format='%(objectname)' \
|
skip=$(git for-each-ref --format='%(objectname)' \
|
||||||
"refs/bisect/skip-*" | tr '[\012]' ' ') || exit
|
"refs/bisect/skip-*" | tr '\012' ' ') || exit
|
||||||
|
|
||||||
BISECT_OPT=''
|
BISECT_OPT=''
|
||||||
test -n "$skip" && BISECT_OPT='--bisect-all'
|
test -n "$skip" && BISECT_OPT='--bisect-all'
|
||||||
|
|
||||||
bad=$(git rev-parse --verify refs/bisect/bad) &&
|
bad=$(git rev-parse --verify refs/bisect/bad) &&
|
||||||
good=$(git for-each-ref --format='^%(objectname)' \
|
good=$(git for-each-ref --format='^%(objectname)' \
|
||||||
"refs/bisect/good-*" | tr '[\012]' ' ') &&
|
"refs/bisect/good-*" | tr '\012' ' ') &&
|
||||||
eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" &&
|
eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" &&
|
||||||
eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
|
eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
|
||||||
eval=$(filter_skipped "$eval" "$skip") &&
|
eval=$(filter_skipped "$eval" "$skip") &&
|
||||||
|
|
|
@ -58,8 +58,8 @@ eval "$functions"
|
||||||
# "author" or "committer
|
# "author" or "committer
|
||||||
|
|
||||||
set_ident () {
|
set_ident () {
|
||||||
lid="$(echo "$1" | tr "A-Z" "a-z")"
|
lid="$(echo "$1" | tr "[A-Z]" "[a-z]")"
|
||||||
uid="$(echo "$1" | tr "a-z" "A-Z")"
|
uid="$(echo "$1" | tr "[a-z]" "[A-Z]")"
|
||||||
pick_id_script='
|
pick_id_script='
|
||||||
/^'$lid' /{
|
/^'$lid' /{
|
||||||
s/'\''/'\''\\'\'\''/g
|
s/'\''/'\''\\'\'\''/g
|
||||||
|
|
|
@ -8,7 +8,10 @@ test_expect_success setup '
|
||||||
|
|
||||||
cat ../../COPYING >test &&
|
cat ../../COPYING >test &&
|
||||||
git add test &&
|
git add test &&
|
||||||
tr 'a-zA-Z' 'n-za-mN-ZA-M' <../../COPYING >test
|
tr \
|
||||||
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
||||||
|
"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
|
||||||
|
<../../COPYING >test
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ test_description='git-filter-branch'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
make_commit () {
|
make_commit () {
|
||||||
lower=$(echo $1 | tr A-Z a-z)
|
lower=$(echo $1 | tr '[A-Z]' '[a-z]')
|
||||||
echo $lower > $lower
|
echo $lower > $lower
|
||||||
git add $lower
|
git add $lower
|
||||||
test_tick
|
test_tick
|
||||||
|
|
Загрузка…
Ссылка в новой задаче