Skip to content

Commit

Permalink
fixup??? grep: follow conventions for printing paths w/ unusual chars
Browse files Browse the repository at this point in the history
It is easy to be fooled by the Bash included in Git for Windows, which
leads you to believe that quotes are valid parts of file names.

On Windows, they are not. But Cygwin (which is the base of MSYS2, which
is the POSIX emulation layer used by that Bash) only _pretends_ that it
is a valid file name character. In reality, it will map the character
into the private Unicode page. Cygwin knows about this. The rest of
Windows applications (including Git for Windows), however, does not.

As a consequence, `>\"with\ quotes\"` will claim to succeed, but the
file on disk will have Unicode characters in place of those quotes that
literally no application but Cygwin ones can handle, and this leads to
those beautiful new tests to fail.

Let's just use the prereq we introduced to guard precisely against this
problem: `FUNNYNAMES`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Apr 18, 2020
1 parent 45fc0db commit 7ca815e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions t/t7810-grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ test_expect_success setup '
# Still a no-op.
function dummy() {}
EOF
echo unusual >"\"unusual\" pathname" &&
echo unusual >"t/nested \"unusual\" pathname" &&
if test_have_prereq FUNNYNAMES
then
echo unusual >"\"unusual\" pathname" &&
echo unusual >"t/nested \"unusual\" pathname"
fi &&
git add . &&
test_tick &&
git commit -m initial
Expand Down Expand Up @@ -484,7 +487,7 @@ do
test_cmp expected actual
'

test_expect_success "grep $L should quote unusual pathnames" '
test_expect_success FUNNYNAMES "grep $L should quote unusual pathnames" '
cat >expected <<-EOF &&
${HC}"\"unusual\" pathname":unusual
${HC}"t/nested \"unusual\" pathname":unusual
Expand All @@ -493,7 +496,7 @@ do
test_cmp expected actual
'

test_expect_success "grep $L in subdir should quote unusual relative pathnames" '
test_expect_success FUNNYNAMES "grep $L in subdir should quote unusual relative pathnames" '
cat >expected <<-EOF &&
${HC}"nested \"unusual\" pathname":unusual
EOF
Expand All @@ -504,7 +507,7 @@ do
test_cmp expected actual
'

test_expect_success "grep -z $L with unusual pathnames" '
test_expect_success FUNNYNAMES "grep -z $L with unusual pathnames" '
cat >expected <<-EOF &&
${HC}"unusual" pathname:unusual
${HC}t/nested "unusual" pathname:unusual
Expand All @@ -514,7 +517,7 @@ do
test_cmp expected actual-replace-null
'

test_expect_success "grep -z $L in subdir with unusual relative pathnames" '
test_expect_success FUNNYNAMES "grep -z $L in subdir with unusual relative pathnames" '
cat >expected <<-EOF &&
${HC}nested "unusual" pathname:unusual
EOF
Expand Down

0 comments on commit 7ca815e

Please sign in to comment.