Skip to content

Commit 3a3f8cb

Browse files
committed
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 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 9dc9c42 commit 3a3f8cb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compat/mingw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,13 +1134,13 @@ static const char *quote_arg_msys2(const char *arg)
11341134

11351135
for (p = arg; *p; p++) {
11361136
int ws = isspace(*p);
1137-
if (!ws && *p != '\\' && *p != '"')
1137+
if (!ws && *p != '\\' && *p != '"' && *p != '{')
11381138
continue;
11391139
if (!buf.len)
11401140
strbuf_addch(&buf, '"');
11411141
if (p != p2)
11421142
strbuf_add(&buf, p2, p - p2);
1143-
if (!ws)
1143+
if (!ws && *p != '{')
11441144
strbuf_addch(&buf, '\\');
11451145
p2 = p;
11461146
}

t/t0061-run-command.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,14 @@ test_expect_success 'GIT_TRACE with environment variables' '
182182
)
183183
'
184184

185+
test_expect_success MINGW 'verify curlies are quoted properly' '
186+
: force the rev-parse through the MSYS2 Bash &&
187+
git -c alias.r="!git rev-parse" r -- a{b}c >actual &&
188+
cat >expect <<-\EOF &&
189+
--
190+
a{b}c
191+
EOF
192+
test_cmp expect actual
193+
'
194+
185195
test_done

0 commit comments

Comments
 (0)