From 3a3f8cb0436c516035adc0ce18f7b4d46cd133fd Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 23 Apr 2018 12:10:51 +0200 Subject: [PATCH] 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 Signed-off-by: Johannes Schindelin --- compat/mingw.c | 4 ++-- t/t0061-run-command.sh | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 0b86861a96..50f3429c85 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -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; } diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index 3063bb76f5..3b6e3af094 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -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