]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Sync with 2.16.6
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 4 Dec 2019 20:52:10 +0000 (21:52 +0100)
committerJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 6 Dec 2019 15:27:36 +0000 (16:27 +0100)
* maint-2.16: (31 commits)
  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
  unpack-trees: let merged_entry() pass through do_add_entry()'s errors
  quote-stress-test: offer to test quoting arguments for MSYS2 sh
  t6130/t9350: prepare for stringent Win32 path validation
  quote-stress-test: allow skipping some trials
  quote-stress-test: accept arguments to test via the command-line
  tests: add a helper to stress test argument quoting
  mingw: fix quoting of arguments
  Disallow dubiously-nested submodule git directories
  protect_ntfs: turn on NTFS protection by default
  path: also guard `.gitmodules` against NTFS Alternate Data Streams
  is_ntfs_dotgit(): speed it up
  mingw: disallow backslash characters in tree objects' file names
  path: safeguard `.git` against NTFS Alternate Streams Accesses
  ...

18 files changed:
1  2 
builtin/clone.c
builtin/submodule--helper.c
compat/mingw.c
compat/mingw.h
environment.c
fast-import.c
fsck.c
git-compat-util.h
git-submodule.sh
read-cache.c
submodule.c
submodule.h
t/helper/test-run-command.c
t/t7415-submodule-names.sh
t/t7416-submodule-dash-url.sh
t/t7417-submodule-path-url.sh
transport-helper.c
unpack-trees.c

diff --cc builtin/clone.c
Simple merge
Simple merge
diff --cc compat/mingw.c
Simple merge
diff --cc compat/mingw.h
Simple merge
diff --cc environment.c
Simple merge
diff --cc fast-import.c
Simple merge
diff --cc fsck.c
index 5d9b25fac0aebe677dcde3181d7edb3eff820515,0b2b93aabd959d8aaef447c955607905dc84eab7..2fc6bbca163194716a80b0ef6b5995b2cabb6fbd
--- 1/fsck.c
--- 2/fsck.c
+++ b/fsck.c
@@@ -576,18 -561,19 +576,34 @@@ static int fsck_tree(struct tree *item
                has_empty_name |= !*name;
                has_dot |= !strcmp(name, ".");
                has_dotdot |= !strcmp(name, "..");
 -              has_dotgit |= (!strcmp(name, ".git") ||
 -                             is_hfs_dotgit(name) ||
 -                             is_ntfs_dotgit(name));
 +              has_dotgit |= is_hfs_dotgit(name) || is_ntfs_dotgit(name);
                has_zero_pad |= *(char *)desc.buffer == '0';
  
 +              if (is_hfs_dotgitmodules(name) || is_ntfs_dotgitmodules(name)) {
 +                      if (!S_ISLNK(mode))
 +                              oidset_insert(&gitmodules_found, oid);
 +                      else
 +                              retval += report(options, &item->object,
 +                                               FSCK_MSG_GITMODULES_SYMLINK,
 +                                               ".gitmodules is a symbolic link");
 +              }
 +
+               if ((backslash = strchr(name, '\\'))) {
+                       while (backslash) {
+                               backslash++;
+                               has_dotgit |= is_ntfs_dotgit(backslash);
++                              if (is_ntfs_dotgitmodules(backslash)) {
++                                      if (!S_ISLNK(mode))
++                                              oidset_insert(&gitmodules_found, oid);
++                                      else
++                                              retval += report(options, &item->object,
++                                                               FSCK_MSG_GITMODULES_SYMLINK,
++                                                               ".gitmodules is a symbolic link");
++                              }
+                               backslash = strchr(backslash, '\\');
+                       }
+               }
                if (update_tree_entry_gently(&desc)) {
                        retval += report(options, &item->object, FSCK_MSG_BAD_TREE, "cannot be parsed as a tree");
                        break;
Simple merge
Simple merge
diff --cc read-cache.c
Simple merge
diff --cc submodule.c
Simple merge
diff --cc submodule.h
Simple merge
index 153342e44dd11ae357cc299a9214f4c365614a5e,b622334407c1b26fbd96875c97799b4360ae1fdf..a701689bd5cb316afaba3b615c409d8a26cef88f
@@@ -54,15 -182,12 +182,21 @@@ int cmd_main(int argc, const char **arg
        struct child_process proc = CHILD_PROCESS_INIT;
        int jobs;
  
+       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")) {
 +              if (!argv[2])
 +                      die("env specifier without a value");
 +              argv_array_push(&proc.env_array, argv[2]);
 +              argv += 2;
 +              argc -= 2;
 +      }
        if (argc < 3)
                return 1;
        proc.argv = (const char **)argv + 2;
index a770d92a5592e5aab1760d0ff509f5ce3cc8e5d0,0338b5cb1e259a86936f1260a37e0ee0cbef7d22..717d708bcdba1bdd78a3a3f31b33e8b6a8068af3
@@@ -74,81 -73,60 +74,137 @@@ test_expect_success 'clone evil superpr
        ! grep "RUNNING POST CHECKOUT" output
  '
  
 +test_expect_success 'fsck detects evil superproject' '
 +      test_must_fail git fsck
 +'
 +
 +test_expect_success 'transfer.fsckObjects detects evil superproject (unpack)' '
 +      rm -rf dst.git &&
 +      git init --bare dst.git &&
 +      git -C dst.git config transfer.fsckObjects true &&
 +      test_must_fail git push dst.git HEAD
 +'
 +
 +test_expect_success 'transfer.fsckObjects detects evil superproject (index)' '
 +      rm -rf dst.git &&
 +      git init --bare dst.git &&
 +      git -C dst.git config transfer.fsckObjects true &&
 +      git -C dst.git config transfer.unpackLimit 1 &&
 +      test_must_fail git push dst.git HEAD
 +'
 +
 +# Normally our packs contain commits followed by trees followed by blobs. This
 +# reverses the order, which requires backtracking to find the context of a
 +# blob. We'll start with a fresh gitmodules-only tree to make it simpler.
 +test_expect_success 'create oddly ordered pack' '
 +      git checkout --orphan odd &&
 +      git rm -rf --cached . &&
 +      git add .gitmodules &&
 +      git commit -m odd &&
 +      {
 +              pack_header 3 &&
 +              pack_obj $(git rev-parse HEAD:.gitmodules) &&
 +              pack_obj $(git rev-parse HEAD^{tree}) &&
 +              pack_obj $(git rev-parse HEAD)
 +      } >odd.pack &&
 +      pack_trailer odd.pack
 +'
 +
 +test_expect_success 'transfer.fsckObjects handles odd pack (unpack)' '
 +      rm -rf dst.git &&
 +      git init --bare dst.git &&
 +      test_must_fail git -C dst.git unpack-objects --strict <odd.pack
 +'
 +
 +test_expect_success 'transfer.fsckObjects handles odd pack (index)' '
 +      rm -rf dst.git &&
 +      git init --bare dst.git &&
 +      test_must_fail git -C dst.git index-pack --strict --stdin <odd.pack
 +'
 +
 +test_expect_success 'fsck detects symlinked .gitmodules file' '
 +      git init symlink &&
 +      (
 +              cd symlink &&
 +
 +              # Make the tree directly to avoid index restrictions.
 +              #
 +              # Because symlinks store the target as a blob, choose
 +              # a pathname that could be parsed as a .gitmodules file
 +              # to trick naive non-symlink-aware checking.
 +              tricky="[foo]bar=true" &&
 +              content=$(git hash-object -w ../.gitmodules) &&
 +              target=$(printf "$tricky" | git hash-object -w --stdin) &&
 +              tree=$(
 +                      {
 +                              printf "100644 blob $content\t$tricky\n" &&
 +                              printf "120000 blob $target\t.gitmodules\n"
 +                      } | git mktree
 +              ) &&
 +              commit=$(git commit-tree $tree) &&
 +
 +              # Check not only that we fail, but that it is due to the
 +              # symlink detector; this grep string comes from the config
 +              # variable name and will not be translated.
 +              test_must_fail git fsck 2>output &&
 +              grep gitmodulesSymlink output
 +      )
 +'
 +
+ test_expect_success MINGW 'prevent git~1 squatting on Windows' '
+       git init squatting &&
+       (
+               cd squatting &&
+               mkdir a &&
+               touch a/..git &&
+               git add a/..git &&
+               test_tick &&
+               git commit -m initial &&
+               modules="$(test_write_lines \
+                       "[submodule \"b.\"]" "url = ." "path = c" \
+                       "[submodule \"b\"]" "url = ." "path = d\\\\a" |
+                       git hash-object -w --stdin)" &&
+               rev="$(git rev-parse --verify HEAD)" &&
+               hash="$(echo x | git hash-object -w --stdin)" &&
+               git -c core.protectNTFS=false update-index --add \
+                       --cacheinfo 100644,$modules,.gitmodules \
+                       --cacheinfo 160000,$rev,c \
+                       --cacheinfo 160000,$rev,d\\a \
+                       --cacheinfo 100644,$hash,d./a/x \
+                       --cacheinfo 100644,$hash,d./a/..git &&
+               test_tick &&
+               git -c core.protectNTFS=false commit -m "module" &&
+               test_must_fail git show HEAD: 2>err &&
+               test_i18ngrep backslash err
+       ) &&
+       test_must_fail git -c core.protectNTFS=false \
+               clone --recurse-submodules squatting squatting-clone 2>err &&
+       test_i18ngrep -e "directory not empty" -e "not an empty directory" err &&
+       ! grep gitdir squatting-clone/d/a/git~2
+ '
+ test_expect_success 'git dirs of sibling submodules must not be nested' '
+       git init nested &&
+       test_commit -C nested nested &&
+       (
+               cd nested &&
+               cat >.gitmodules <<-EOF &&
+               [submodule "hippo"]
+                       url = .
+                       path = thing1
+               [submodule "hippo/hooks"]
+                       url = .
+                       path = thing2
+               EOF
+               git clone . thing1 &&
+               git clone . thing2 &&
+               git add .gitmodules thing1 thing2 &&
+               test_tick &&
+               git commit -m nested
+       ) &&
+       test_must_fail git clone --recurse-submodules nested clone 2>err &&
+       test_i18ngrep "is inside git dir" err
+ '
  test_done
index 1cd2c1c1ea2d713c0b589df3ae9b34d43e5697a4,2966e9307199beb04c3a61933ad88a1d3e6bcb5b..5ba041f537067dd9d16047a3569bb2b5fb3a4d51
@@@ -38,12 -31,18 +38,26 @@@ test_expect_success 'clone rejects unpr
        test_i18ngrep ignoring err
  '
  
 +test_expect_success 'fsck rejects unprotected dash' '
 +      test_when_finished "rm -rf dst" &&
 +      git init --bare dst &&
 +      git -C dst config transfer.fsckObjects true &&
 +      test_must_fail git push dst HEAD 2>err &&
 +      grep gitmodulesUrl err
 +'
 +
+ test_expect_success 'trailing backslash is handled correctly' '
+       git init testmodule &&
+       test_commit -C testmodule c &&
+       git submodule add ./testmodule &&
+       : ensure that the name ends in a double backslash &&
+       sed -e "s|\\(submodule \"testmodule\\)\"|\\1\\\\\\\\\"|" \
+               -e "s|url = .*|url = \" --should-not-be-an-option\"|" \
+               <.gitmodules >.new &&
+       mv .new .gitmodules &&
+       git commit -am "Add testmodule" &&
+       test_must_fail git clone --verbose --recurse-submodules . dolly 2>err &&
+       test_i18ngrep ! "unknown option" err
+ '
  test_done
index 756af8c4d6fbd1ba9fb2e4d6fd5b8ae9ddfc34e1,fad9e20dc4cb17bfcfc3b514840bba15c0e83f50..f7e7e94d7b6cfec6c625f6830b296b276572df66
@@@ -17,12 -17,21 +17,29 @@@ test_expect_success 'clone rejects unpr
        test_i18ngrep ignoring err
  '
  
 +test_expect_success 'fsck rejects unprotected dash' '
 +      test_when_finished "rm -rf dst" &&
 +      git init --bare dst &&
 +      git -C dst config transfer.fsckObjects true &&
 +      test_must_fail git push dst HEAD 2>err &&
 +      grep gitmodulesPath err
 +'
 +
+ test_expect_success MINGW 'submodule paths disallows trailing spaces' '
+       git init super &&
+       test_must_fail git -C super submodule add ../upstream "sub " &&
+       : add "sub", then rename "sub" to "sub ", the hard way &&
+       git -C super submodule add ../upstream sub &&
+       tree=$(git -C super write-tree) &&
+       git -C super ls-tree $tree >tree &&
+       sed "s/sub/sub /" <tree >tree.new &&
+       tree=$(git -C super mktree <tree.new) &&
+       commit=$(echo with space | git -C super commit-tree $tree) &&
+       git -C super update-ref refs/heads/master $commit &&
+       test_must_fail git clone --recurse-submodules super dst 2>err &&
+       test_i18ngrep "sub " err
+ '
  test_done
Simple merge
diff --cc unpack-trees.c
Simple merge