debian: apply security fixes from 2.24.1
[git/debian.git] / debian / patches / 0022-quote-stress-test-offer-to-test-quoting-arguments-for.diff
bloba625fec87d0d45e3c5f365350e59b22bb49a4e01
1 From 5f2e225d5b655d84c24d46fdc54a19a427289acc Mon Sep 17 00:00:00 2001
2 From: Johannes Schindelin <johannes.schindelin@gmx.de>
3 Date: Fri, 20 Sep 2019 00:12:37 +0200
4 Subject: quote-stress-test: offer to test quoting arguments for MSYS2 sh
6 It is unfortunate that we need to quote arguments differently on
7 Windows, depending whether we build a command-line for MSYS2's `sh` or
8 for other Windows executables.
10 We already have a test helper to verify the latter, with this patch we
11 can also verify the former.
13 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
14 (cherry picked from commit 379e51d1ae668a1f26d50eb59b3f8befc1eb8883)
15 Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
16 ---
17 t/helper/test-run-command.c | 13 ++++++++++---
18 1 file changed, 10 insertions(+), 3 deletions(-)
20 diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
21 index b5227087bf..724328975a 100644
22 --- a/t/helper/test-run-command.c
23 +++ b/t/helper/test-run-command.c
24 @@ -218,12 +218,13 @@ static int quote_stress_test(int argc, const char **argv)
25 * were passed in.
27 char special[] = ".?*\\^_\"'`{}()[]<>@~&+:;$%"; // \t\r\n\a";
28 - int i, j, k, trials = 100, skip = 0;
29 + int i, j, k, trials = 100, skip = 0, msys2 = 0;
30 struct strbuf out = STRBUF_INIT;
31 struct argv_array args = ARGV_ARRAY_INIT;
32 struct option options[] = {
33 OPT_INTEGER('n', "trials", &trials, "Number of trials"),
34 OPT_INTEGER('s', "skip", &skip, "Skip <n> trials"),
35 + OPT_BOOL('m', "msys2", &msys2, "Test quoting for MSYS2's sh"),
36 OPT_END()
38 const char * const usage[] = {
39 @@ -233,14 +234,20 @@ static int quote_stress_test(int argc, const char **argv)
41 argc = parse_options(argc, argv, NULL, options, usage, 0);
43 + setenv("MSYS_NO_PATHCONV", "1", 0);
45 for (i = 0; i < trials; i++) {
46 struct child_process cp = CHILD_PROCESS_INIT;
47 size_t arg_count, arg_offset;
48 int ret = 0;
50 argv_array_clear(&args);
51 - argv_array_pushl(&args, "test-tool", "run-command",
52 - "quote-echo", NULL);
53 + if (msys2)
54 + argv_array_pushl(&args, "sh", "-c",
55 + "printf %s\\\\0 \"$@\"", "skip", NULL);
56 + else
57 + argv_array_pushl(&args, "test-tool", "run-command",
58 + "quote-echo", NULL);
59 arg_offset = args.argc;
61 if (argc > 0) {
62 --
63 2.24.0.393.g34dc348eaf