squash! mingw: special-case arguments to sh

We need to take care to quote not only whitespace, but also curly
brackets. As aliases frequently going through the MSYS2 Bash, and
as aliases frequently get parameters such as HEAD@{yesterday}, let's
make sure that this does not regress by adding a test case for that.

Helped-by: Kim Gybels <kgybels@infogroep.be>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2018-04-23 12:10:51 +02:00
parent 9dc9c421e1
commit 3a3f8cb043
2 changed files with 12 additions and 2 deletions

View File

@@ -1134,13 +1134,13 @@ static const char *quote_arg_msys2(const char *arg)
for (p = arg; *p; p++) {
int ws = isspace(*p);
if (!ws && *p != '\\' && *p != '"')
if (!ws && *p != '\\' && *p != '"' && *p != '{')
continue;
if (!buf.len)
strbuf_addch(&buf, '"');
if (p != p2)
strbuf_add(&buf, p2, p - p2);
if (!ws)
if (!ws && *p != '{')
strbuf_addch(&buf, '\\');
p2 = p;
}

View File

@@ -182,4 +182,14 @@ test_expect_success 'GIT_TRACE with environment variables' '
)
'
test_expect_success MINGW 'verify curlies are quoted properly' '
: force the rev-parse through the MSYS2 Bash &&
git -c alias.r="!git rev-parse" r -- a{b}c >actual &&
cat >expect <<-\EOF &&
--
a{b}c
EOF
test_cmp expect actual
'
test_done