]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Sync with Git 2.17.1
authorJunio C Hamano <gitster@pobox.com>
Tue, 29 May 2018 08:09:58 +0000 (17:09 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 May 2018 08:10:05 +0000 (17:10 +0900)
* maint: (25 commits)
  Git 2.17.1
  Git 2.16.4
  Git 2.15.2
  Git 2.14.4
  Git 2.13.7
  fsck: complain when .gitmodules is a symlink
  index-pack: check .gitmodules files with --strict
  unpack-objects: call fsck_finish() after fscking objects
  fsck: call fsck_finish() after fscking objects
  fsck: check .gitmodules content
  fsck: handle promisor objects in .gitmodules check
  fsck: detect gitmodules files
  fsck: actually fsck blob data
  fsck: simplify ".git" check
  index-pack: make fsck error message more specific
  verify_path: disallow symlinks in .gitmodules
  update-index: stat updated files earlier
  verify_dotfile: mention case-insensitivity in comment
  verify_path: drop clever fallthrough
  skip_prefix: add case-insensitive variant
  ...

20 files changed:
1  2 
apply.c
builtin/fsck.c
builtin/index-pack.c
builtin/submodule--helper.c
builtin/unpack-objects.c
builtin/update-index.c
cache.h
dir.c
fsck.c
git-compat-util.h
path.c
read-cache.c
sha1-file.c
submodule-config.c
submodule-config.h
t/helper/test-path-utils.c
t/lib-pack.sh
t/t0060-path-utils.sh
utf8.c
utf8.h

diff --cc apply.c
Simple merge
diff --cc builtin/fsck.c
index 9d59d7d5a215379b221b02ac34277b542e757df1,028aba52ebaab764d1f4f91c926e54d66dcaa20f..916109ac1c05664da895d832ec10c8b5ee4465fb
@@@ -507,36 -504,31 +507,31 @@@ static void get_default_heads(void
        }
  }
  
- static struct object *parse_loose_object(const struct object_id *oid,
-                                        const char *path)
+ static int fsck_loose(const struct object_id *oid, const char *path, void *data)
  {
        struct object *obj;
-       void *contents;
        enum object_type type;
        unsigned long size;
+       void *contents;
        int eaten;
  
-       if (read_loose_object(path, oid, &type, &size, &contents) < 0)
-               return NULL;
 -      if (read_loose_object(path, oid->hash, &type, &size, &contents) < 0) {
++      if (read_loose_object(path, oid, &type, &size, &contents) < 0) {
+               errors_found |= ERROR_OBJECT;
+               error("%s: object corrupt or missing: %s",
+                     oid_to_hex(oid), path);
+               return 0; /* keep checking other objects */
+       }
  
        if (!contents && type != OBJ_BLOB)
-               die("BUG: read_loose_object streamed a non-blob");
+               BUG("read_loose_object streamed a non-blob");
  
        obj = parse_object_buffer(oid, type, size, contents, &eaten);
-       if (!eaten)
-               free(contents);
-       return obj;
- }
- static int fsck_loose(const struct object_id *oid, const char *path, void *data)
- {
-       struct object *obj = parse_loose_object(oid, path);
        if (!obj) {
                errors_found |= ERROR_OBJECT;
-               error("%s: object corrupt or missing: %s",
+               error("%s: object could not be parsed: %s",
                      oid_to_hex(oid), path);
+               if (!eaten)
+                       free(contents);
                return 0; /* keep checking other objects */
        }
  
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc cache.h
Simple merge
diff --cc dir.c
Simple merge
diff --cc fsck.c
index 640422a6c6b8b8f7439670e27c4eb110ef574525,9339f315131786c50c9fa10dd702fe20562e167e..4db2277ab8606fe08143cdba12b32bde959b2732
--- 1/fsck.c
--- 2/fsck.c
+++ b/fsck.c
@@@ -934,3 -1013,52 +1015,52 @@@ int fsck_error_function(struct fsck_opt
        error("object %s: %s", describe_object(o, obj), message);
        return 1;
  }
 -              buf = read_sha1_file(oid->hash, &type, &size);
+ int fsck_finish(struct fsck_options *options)
+ {
+       int ret = 0;
+       struct oidset_iter iter;
+       const struct object_id *oid;
+       oidset_iter_init(&gitmodules_found, &iter);
+       while ((oid = oidset_iter_next(&iter))) {
+               struct blob *blob;
+               enum object_type type;
+               unsigned long size;
+               char *buf;
+               if (oidset_contains(&gitmodules_done, oid))
+                       continue;
+               blob = lookup_blob(oid);
+               if (!blob) {
+                       ret |= report(options, &blob->object,
+                                     FSCK_MSG_GITMODULES_BLOB,
+                                     "non-blob found at .gitmodules");
+                       continue;
+               }
++              buf = read_object_file(oid, &type, &size);
+               if (!buf) {
+                       if (is_promisor_object(&blob->object.oid))
+                               continue;
+                       ret |= report(options, &blob->object,
+                                     FSCK_MSG_GITMODULES_MISSING,
+                                     "unable to read .gitmodules blob");
+                       continue;
+               }
+               if (type == OBJ_BLOB)
+                       ret |= fsck_blob(blob, buf, size, options);
+               else
+                       ret |= report(options, &blob->object,
+                                     FSCK_MSG_GITMODULES_BLOB,
+                                     "non-blob found at .gitmodules");
+               free(buf);
+       }
+       oidset_clear(&gitmodules_found);
+       oidset_clear(&gitmodules_done);
+       return ret;
+ }
Simple merge
diff --cc path.c
Simple merge
diff --cc read-cache.c
Simple merge
diff --cc sha1-file.c
index f66059ed7dd9aa8040568094a7ad6fa316d18e55,53f0a3693fef1e03659cf3b41d15246ad419911e..e47098eff2828c573a4a2eb3cce3dc7a5520b3e5
@@@ -2232,11 -2209,11 +2232,11 @@@ int read_loose_object(const char *path
                goto out;
        }
  
-       if (*type == OBJ_BLOB) {
+       if (*type == OBJ_BLOB && *size > big_file_threshold) {
 -              if (check_stream_sha1(&stream, hdr, *size, path, expected_sha1) < 0)
 +              if (check_stream_sha1(&stream, hdr, *size, path, expected_oid->hash) < 0)
                        goto out;
        } else {
 -              *contents = unpack_sha1_rest(&stream, hdr, *size, expected_sha1);
 +              *contents = unpack_sha1_rest(&stream, hdr, *size, expected_oid->hash);
                if (!*contents) {
                        error("unable to unpack contents of %s", path);
                        git_inflate_end(&stream);
Simple merge
index 6f686184e86cc0004410aae3b771de4d3b488a13,17e297022396d2b2b837187d6deaf8a42d45a0d6..21273f56a37794ae5116761e85d5264acc9f81d1
@@@ -39,12 -39,20 +39,19 @@@ extern int parse_update_recurse_submodu
  extern int parse_push_recurse_submodules_arg(const char *opt, const char *arg);
  extern void repo_read_gitmodules(struct repository *repo);
  extern void gitmodules_config_oid(const struct object_id *commit_oid);
 -extern const struct submodule *submodule_from_name(
 -              const struct object_id *commit_or_tree, const char *name);
 -extern const struct submodule *submodule_from_path(
 -              const struct object_id *commit_or_tree, const char *path);
 -extern const struct submodule *submodule_from_cache(struct repository *repo,
 -                                                  const struct object_id *treeish_name,
 -                                                  const char *key);
 -extern void submodule_free(void);
 +const struct submodule *submodule_from_name(struct repository *r,
 +                                          const struct object_id *commit_or_tree,
 +                                          const char *name);
 +const struct submodule *submodule_from_path(struct repository *r,
 +                                          const struct object_id *commit_or_tree,
 +                                          const char *path);
 +void submodule_free(struct repository *r);
  
+ /*
+  * Returns 0 if the name is syntactically acceptable as a submodule "name"
+  * (e.g., that may be found in the subsection of a .gitmodules file) and -1
+  * otherwise.
+  */
+ int check_submodule_name(const char *name);
  #endif /* SUBMODULE_CONFIG_H */
index e115d44ac26e1d4fed48a5fd82632e5a93a487e6,94846550f74a843f979de14116ab2df5dd15f6e3..ae091d9b3e63cb506b2530217d40048b301faaa3
@@@ -1,6 -1,6 +1,7 @@@
 +#include "test-tool.h"
  #include "cache.h"
  #include "string-list.h"
+ #include "utf8.h"
  
  /*
   * A "string_list_each_func_t" function that normalizes an entry from
@@@ -171,7 -171,12 +172,12 @@@ static struct test_data dirname_data[] 
        { NULL,              NULL     }
  };
  
 -int cmd_main(int argc, const char **argv)
+ static int is_dotgitmodules(const char *path)
+ {
+       return is_hfs_dotgitmodules(path) || is_ntfs_dotgitmodules(path);
+ }
 +int cmd__path_utils(int argc, const char **argv)
  {
        if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
                char *buf = xmallocz(strlen(argv[2]));
diff --cc t/lib-pack.sh
Simple merge
index f46e3c4995509f62f954231f53321f1d24756eff,3f3357ed9fc23c93d496d2a6e29aadf59932f347..21a8b531322ca75695ca16c6e8ec7e0ba1056f10
@@@ -349,4 -349,90 +349,90 @@@ test_submodule_relative_url "(null)" "s
  test_submodule_relative_url "(null)" "user@host:path/to/repo" "../subrepo" "user@host:path/to/subrepo"
  test_submodule_relative_url "(null)" "user@host:repo" "../subrepo" "user@host:subrepo"
  
 -      test-path-utils is_dotgitmodules \
+ test_expect_success 'match .gitmodules' '
++      test-tool path-utils is_dotgitmodules \
+               .gitmodules \
+               \
+               .git${u200c}modules \
+               \
+               .Gitmodules \
+               .gitmoduleS \
+               \
+               ".gitmodules " \
+               ".gitmodules." \
+               ".gitmodules  " \
+               ".gitmodules. " \
+               ".gitmodules ." \
+               ".gitmodules.." \
+               ".gitmodules   " \
+               ".gitmodules.  " \
+               ".gitmodules . " \
+               ".gitmodules  ." \
+               \
+               ".Gitmodules " \
+               ".Gitmodules." \
+               ".Gitmodules  " \
+               ".Gitmodules. " \
+               ".Gitmodules ." \
+               ".Gitmodules.." \
+               ".Gitmodules   " \
+               ".Gitmodules.  " \
+               ".Gitmodules . " \
+               ".Gitmodules  ." \
+               \
+               GITMOD~1 \
+               gitmod~1 \
+               GITMOD~2 \
+               gitmod~3 \
+               GITMOD~4 \
+               \
+               "GITMOD~1 " \
+               "gitmod~2." \
+               "GITMOD~3  " \
+               "gitmod~4. " \
+               "GITMOD~1 ." \
+               "gitmod~2   " \
+               "GITMOD~3.  " \
+               "gitmod~4 . " \
+               \
+               GI7EBA~1 \
+               gi7eba~9 \
+               \
+               GI7EB~10 \
+               GI7EB~11 \
+               GI7EB~99 \
+               GI7EB~10 \
+               GI7E~100 \
+               GI7E~101 \
+               GI7E~999 \
+               ~1000000 \
+               ~9999999 \
+               \
+               --not \
+               ".gitmodules x"  \
+               ".gitmodules .x" \
+               \
+               " .gitmodules" \
+               \
+               ..gitmodules \
+               \
+               gitmodules \
+               \
+               .gitmodule \
+               \
+               ".gitmodules x " \
+               ".gitmodules .x" \
+               \
+               GI7EBA~ \
+               GI7EBA~0 \
+               GI7EBA~~1 \
+               GI7EBA~X \
+               Gx7EBA~1 \
+               GI7EBX~1 \
+               \
+               GI7EB~1 \
+               GI7EB~01 \
+               GI7EB~1X
+ '
  test_done
diff --cc utf8.c
Simple merge
diff --cc utf8.h
Simple merge