2007-11-22 10:06:44 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='rewrite diff'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
|
|
|
|
cat ../../COPYING >test &&
|
|
|
|
git add test &&
|
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>
2008-03-13 00:29:57 +03:00
|
|
|
tr \
|
|
|
|
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
|
|
|
"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM" \
|
|
|
|
<../../COPYING >test
|
2007-11-22 10:06:44 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'detect rewrite' '
|
|
|
|
|
|
|
|
actual=$(git diff-files -B --summary test) &&
|
|
|
|
expr "$actual" : " rewrite test ([0-9]*%)$" || {
|
|
|
|
echo "Eh? <<$actual>>"
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|
|
|
|
|