]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Sync with 2.23.1
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 4 Dec 2019 22:09:11 +0000 (23:09 +0100)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 6 Dec 2019 15:31:39 +0000 (16:31 +0100)
* maint-2.23: (44 commits)
  Git 2.23.1
  Git 2.22.2
  Git 2.21.1
  mingw: sh arguments need quoting in more circumstances
  mingw: fix quoting of empty arguments for `sh`
  mingw: use MSYS2 quoting even when spawning shell scripts
  mingw: detect when MSYS2's sh is to be spawned more robustly
  t7415: drop v2.20.x-specific work-around
  Git 2.20.2
  t7415: adjust test for dubiously-nested submodule gitdirs for v2.20.x
  Git 2.19.3
  Git 2.18.2
  Git 2.17.3
  Git 2.16.6
  test-drop-caches: use `has_dos_drive_prefix()`
  Git 2.15.4
  Git 2.14.6
  mingw: handle `subst`-ed "DOS drives"
  mingw: refuse to access paths with trailing spaces or periods
  mingw: refuse to access paths with illegal characters
  ...

23 files changed:
1  2 
Documentation/git-fast-import.txt
Documentation/gitmodules.txt
builtin/clone.c
builtin/submodule--helper.c
compat/mingw.c
compat/mingw.h
compat/win32/path-utils.h
config.mak.uname
connect.c
environment.c
fast-import.c
git-compat-util.h
path.c
read-cache.c
submodule-config.c
t/helper/test-run-command.c
t/t1450-fsck.sh
t/t7406-submodule-update.sh
t/t9300-fast-import.sh
t/t9350-fast-export.sh
transport-helper.c
tree-walk.c
unpack-trees.c

Simple merge
Simple merge
diff --cc builtin/clone.c
Simple merge
Simple merge
diff --cc compat/mingw.c
Simple merge
diff --cc compat/mingw.h
Simple merge
index 8ed062a6b7887eb1d1c0c0e7cdaf8b9f0ca9aef3,3403681458b9db1631a962021cb5ad57845192d4..f2e70872cd20675dd2f84f72e7608799f16941ad
@@@ -1,8 -1,6 +1,9 @@@
- #define has_dos_drive_prefix(path) \
-       (isalpha(*(path)) && (path)[1] == ':' ? 2 : 0)
 +#ifndef WIN32_PATH_UTILS_H
 +#define WIN32_PATH_UTILS_H
 +
+ int win32_has_dos_drive_prefix(const char *path);
+ #define has_dos_drive_prefix win32_has_dos_drive_prefix
  int win32_skip_dos_drive_prefix(char **path);
  #define skip_dos_drive_prefix win32_skip_dos_drive_prefix
  static inline int win32_is_dir_sep(int c)
Simple merge
diff --cc connect.c
Simple merge
diff --cc environment.c
Simple merge
diff --cc fast-import.c
index 9503d087b28738eb7797f931e5edb0cd03d4b08f,b4e210533479edb117c5ae352b3f1cdeb84f3c70..b8b65a801cc1f902f7131590816459d2d1e0faa0
@@@ -3248,13 -3195,14 +3262,16 @@@ static int parse_one_feature(const cha
        if (skip_prefix(feature, "date-format=", &arg)) {
                option_date_format(arg);
        } else if (skip_prefix(feature, "import-marks=", &arg)) {
+               check_unsafe_feature("import-marks", from_stream);
                option_import_marks(arg, from_stream, 0);
        } else if (skip_prefix(feature, "import-marks-if-exists=", &arg)) {
+               check_unsafe_feature("import-marks-if-exists", from_stream);
                option_import_marks(arg, from_stream, 1);
        } else if (skip_prefix(feature, "export-marks=", &arg)) {
+               check_unsafe_feature(feature, from_stream);
                option_export_marks(arg);
 +      } else if (!strcmp(feature, "alias")) {
 +              ; /* Don't die - this feature is supported */
        } else if (!strcmp(feature, "get-mark")) {
                ; /* Don't die - this feature is supported */
        } else if (!strcmp(feature, "cat-blob")) {
Simple merge
diff --cc path.c
Simple merge
diff --cc read-cache.c
Simple merge
Simple merge
index ead6dc611ada93daa5e9de2429e62ba7576c74e4,8579b1f7d13394b89dfff161b6f6558d498ac2f3..724328975a38e1c630d019bc49e1c507ff514b1f
  #include "run-command.h"
  #include "argv-array.h"
  #include "strbuf.h"
- #include <string.h>
- #include <errno.h>
 +#include "parse-options.h"
 +#include "string-list.h"
 +#include "thread-utils.h"
 +#include "wildmatch.h"
+ #include "gettext.h"
+ #include "parse-options.h"
  
  static int number_callbacks;
  static int parallel_next(struct child_process *cp,
@@@ -55,159 -50,145 +55,293 @@@ static int task_finished(int result
        return 1;
  }
  
 +struct testsuite {
 +      struct string_list tests, failed;
 +      int next;
 +      int quiet, immediate, verbose, verbose_log, trace, write_junit_xml;
 +};
 +#define TESTSUITE_INIT \
 +      { STRING_LIST_INIT_DUP, STRING_LIST_INIT_DUP, -1, 0, 0, 0, 0, 0, 0 }
 +
 +static int next_test(struct child_process *cp, struct strbuf *err, void *cb,
 +                   void **task_cb)
 +{
 +      struct testsuite *suite = cb;
 +      const char *test;
 +      if (suite->next >= suite->tests.nr)
 +              return 0;
 +
 +      test = suite->tests.items[suite->next++].string;
 +      argv_array_pushl(&cp->args, "sh", test, NULL);
 +      if (suite->quiet)
 +              argv_array_push(&cp->args, "--quiet");
 +      if (suite->immediate)
 +              argv_array_push(&cp->args, "-i");
 +      if (suite->verbose)
 +              argv_array_push(&cp->args, "-v");
 +      if (suite->verbose_log)
 +              argv_array_push(&cp->args, "-V");
 +      if (suite->trace)
 +              argv_array_push(&cp->args, "-x");
 +      if (suite->write_junit_xml)
 +              argv_array_push(&cp->args, "--write-junit-xml");
 +
 +      strbuf_addf(err, "Output of '%s':\n", test);
 +      *task_cb = (void *)test;
 +
 +      return 1;
 +}
 +
 +static int test_finished(int result, struct strbuf *err, void *cb,
 +                       void *task_cb)
 +{
 +      struct testsuite *suite = cb;
 +      const char *name = (const char *)task_cb;
 +
 +      if (result)
 +              string_list_append(&suite->failed, name);
 +
 +      strbuf_addf(err, "%s: '%s'\n", result ? "FAIL" : "SUCCESS", name);
 +
 +      return 0;
 +}
 +
 +static int test_failed(struct strbuf *out, void *cb, void *task_cb)
 +{
 +      struct testsuite *suite = cb;
 +      const char *name = (const char *)task_cb;
 +
 +      string_list_append(&suite->failed, name);
 +      strbuf_addf(out, "FAILED TO START: '%s'\n", name);
 +
 +      return 0;
 +}
 +
 +static const char * const testsuite_usage[] = {
 +      "test-run-command testsuite [<options>] [<pattern>...]",
 +      NULL
 +};
 +
 +static int testsuite(int argc, const char **argv)
 +{
 +      struct testsuite suite = TESTSUITE_INIT;
 +      int max_jobs = 1, i, ret;
 +      DIR *dir;
 +      struct dirent *d;
 +      struct option options[] = {
 +              OPT_BOOL('i', "immediate", &suite.immediate,
 +                       "stop at first failed test case(s)"),
 +              OPT_INTEGER('j', "jobs", &max_jobs, "run <N> jobs in parallel"),
 +              OPT_BOOL('q', "quiet", &suite.quiet, "be terse"),
 +              OPT_BOOL('v', "verbose", &suite.verbose, "be verbose"),
 +              OPT_BOOL('V', "verbose-log", &suite.verbose_log,
 +                       "be verbose, redirected to a file"),
 +              OPT_BOOL('x', "trace", &suite.trace, "trace shell commands"),
 +              OPT_BOOL(0, "write-junit-xml", &suite.write_junit_xml,
 +                       "write JUnit-style XML files"),
 +              OPT_END()
 +      };
 +
 +      memset(&suite, 0, sizeof(suite));
 +      suite.tests.strdup_strings = suite.failed.strdup_strings = 1;
 +
 +      argc = parse_options(argc, argv, NULL, options,
 +                      testsuite_usage, PARSE_OPT_STOP_AT_NON_OPTION);
 +
 +      if (max_jobs <= 0)
 +              max_jobs = online_cpus();
 +
 +      dir = opendir(".");
 +      if (!dir)
 +              die("Could not open the current directory");
 +      while ((d = readdir(dir))) {
 +              const char *p = d->d_name;
 +
 +              if (*p != 't' || !isdigit(p[1]) || !isdigit(p[2]) ||
 +                  !isdigit(p[3]) || !isdigit(p[4]) || p[5] != '-' ||
 +                  !ends_with(p, ".sh"))
 +                      continue;
 +
 +              /* No pattern: match all */
 +              if (!argc) {
 +                      string_list_append(&suite.tests, p);
 +                      continue;
 +              }
 +
 +              for (i = 0; i < argc; i++)
 +                      if (!wildmatch(argv[i], p, 0)) {
 +                              string_list_append(&suite.tests, p);
 +                              break;
 +                      }
 +      }
 +      closedir(dir);
 +
 +      if (!suite.tests.nr)
 +              die("No tests match!");
 +      if (max_jobs > suite.tests.nr)
 +              max_jobs = suite.tests.nr;
 +
 +      fprintf(stderr, "Running %d tests (%d at a time)\n",
 +              suite.tests.nr, max_jobs);
 +
 +      ret = run_processes_parallel(max_jobs, next_test, test_failed,
 +                                   test_finished, &suite);
 +
 +      if (suite.failed.nr > 0) {
 +              ret = 1;
 +              fprintf(stderr, "%d tests failed:\n\n", suite.failed.nr);
 +              for (i = 0; i < suite.failed.nr; i++)
 +                      fprintf(stderr, "\t%s\n", suite.failed.items[i].string);
 +      }
 +
 +      string_list_clear(&suite.tests, 0);
 +      string_list_clear(&suite.failed, 0);
 +
 +      return !!ret;
 +}
 +
+ static uint64_t my_random_next = 1234;
+ static uint64_t my_random(void)
+ {
+       uint64_t res = my_random_next;
+       my_random_next = my_random_next * 1103515245 + 12345;
+       return res;
+ }
+ static int quote_stress_test(int argc, const char **argv)
+ {
+       /*
+        * We are running a quote-stress test.
+        * spawn a subprocess that runs quote-stress with a
+        * special option that echoes back the arguments that
+        * were passed in.
+        */
+       char special[] = ".?*\\^_\"'`{}()[]<>@~&+:;$%"; // \t\r\n\a";
+       int i, j, k, trials = 100, skip = 0, msys2 = 0;
+       struct strbuf out = STRBUF_INIT;
+       struct argv_array args = ARGV_ARRAY_INIT;
+       struct option options[] = {
+               OPT_INTEGER('n', "trials", &trials, "Number of trials"),
+               OPT_INTEGER('s', "skip", &skip, "Skip <n> trials"),
+               OPT_BOOL('m', "msys2", &msys2, "Test quoting for MSYS2's sh"),
+               OPT_END()
+       };
+       const char * const usage[] = {
+               "test-tool run-command quote-stress-test <options>",
+               NULL
+       };
+       argc = parse_options(argc, argv, NULL, options, usage, 0);
+       setenv("MSYS_NO_PATHCONV", "1", 0);
+       for (i = 0; i < trials; i++) {
+               struct child_process cp = CHILD_PROCESS_INIT;
+               size_t arg_count, arg_offset;
+               int ret = 0;
+               argv_array_clear(&args);
+               if (msys2)
+                       argv_array_pushl(&args, "sh", "-c",
+                                        "printf %s\\\\0 \"$@\"", "skip", NULL);
+               else
+                       argv_array_pushl(&args, "test-tool", "run-command",
+                                        "quote-echo", NULL);
+               arg_offset = args.argc;
+               if (argc > 0) {
+                       trials = 1;
+                       arg_count = argc;
+                       for (j = 0; j < arg_count; j++)
+                               argv_array_push(&args, argv[j]);
+               } else {
+                       arg_count = 1 + (my_random() % 5);
+                       for (j = 0; j < arg_count; j++) {
+                               char buf[20];
+                               size_t min_len = 1;
+                               size_t arg_len = min_len +
+                                       (my_random() % (ARRAY_SIZE(buf) - min_len));
+                               for (k = 0; k < arg_len; k++)
+                                       buf[k] = special[my_random() %
+                                               ARRAY_SIZE(special)];
+                               buf[arg_len] = '\0';
+                               argv_array_push(&args, buf);
+                       }
+               }
+               if (i < skip)
+                       continue;
+               cp.argv = args.argv;
+               strbuf_reset(&out);
+               if (pipe_command(&cp, NULL, 0, &out, 0, NULL, 0) < 0)
+                       return error("Failed to spawn child process");
+               for (j = 0, k = 0; j < arg_count; j++) {
+                       const char *arg = args.argv[j + arg_offset];
+                       if (strcmp(arg, out.buf + k))
+                               ret = error("incorrectly quoted arg: '%s', "
+                                           "echoed back as '%s'",
+                                            arg, out.buf + k);
+                       k += strlen(out.buf + k) + 1;
+               }
+               if (k != out.len)
+                       ret = error("got %d bytes, but consumed only %d",
+                                    (int)out.len, (int)k);
+               if (ret) {
+                       fprintf(stderr, "Trial #%d failed. Arguments:\n", i);
+                       for (j = 0; j < arg_count; j++)
+                               fprintf(stderr, "arg #%d: '%s'\n",
+                                       (int)j, args.argv[j + arg_offset]);
+                       strbuf_release(&out);
+                       argv_array_clear(&args);
+                       return ret;
+               }
+               if (i && (i % 100) == 0)
+                       fprintf(stderr, "Trials completed: %d\n", (int)i);
+       }
+       strbuf_release(&out);
+       argv_array_clear(&args);
+       return 0;
+ }
+ static int quote_echo(int argc, const char **argv)
+ {
+       while (argc > 1) {
+               fwrite(argv[1], strlen(argv[1]), 1, stdout);
+               fputc('\0', stdout);
+               argv++;
+               argc--;
+       }
+       return 0;
+ }
  int cmd__run_command(int argc, const char **argv)
  {
        struct child_process proc = CHILD_PROCESS_INIT;
        int jobs;
  
 +      if (argc > 1 && !strcmp(argv[1], "testsuite"))
 +              exit(testsuite(argc - 1, argv + 1));
 +
+       if (argc >= 2 && !strcmp(argv[1], "quote-stress-test"))
+               return !!quote_stress_test(argc - 1, argv + 1);
+       if (argc >= 2 && !strcmp(argv[1], "quote-echo"))
+               return !!quote_echo(argc - 1, argv + 1);
        if (argc < 3)
                return 1;
        while (!strcmp(argv[1], "env")) {
diff --cc t/t1450-fsck.sh
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc tree-walk.c
Simple merge
diff --cc unpack-trees.c
Simple merge