From: Junio C Hamano Date: Tue, 29 May 2018 08:09:58 +0000 (+0900) Subject: Sync with Git 2.17.1 X-Git-Tag: v2.18.0-rc0~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7913f53b5628997165e075008d6142da1c04271a;p=thirdparty%2Fgit.git Sync with Git 2.17.1 * 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 ... --- 7913f53b5628997165e075008d6142da1c04271a diff --cc builtin/fsck.c index 9d59d7d5a2,028aba52eb..916109ac1c --- a/builtin/fsck.c +++ b/builtin/fsck.c @@@ -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 */ } diff --cc fsck.c index 640422a6c6,9339f31513..4db2277ab8 --- a/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; } + + 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_sha1_file(oid->hash, &type, &size); ++ 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; + } diff --cc sha1-file.c index f66059ed7d,53f0a3693f..e47098eff2 --- a/sha1-file.c +++ b/sha1-file.c @@@ -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); diff --cc submodule-config.h index 6f686184e8,17e2970223..21273f56a3 --- a/submodule-config.h +++ b/submodule-config.h @@@ -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 */ diff --cc t/helper/test-path-utils.c index e115d44ac2,94846550f7..ae091d9b3e --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@@ -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 } }; + static int is_dotgitmodules(const char *path) + { + return is_hfs_dotgitmodules(path) || is_ntfs_dotgitmodules(path); + } + -int cmd_main(int argc, const char **argv) +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/t0060-path-utils.sh index f46e3c4995,3f3357ed9f..21a8b53132 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@@ -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_expect_success 'match .gitmodules' ' - test-path-utils is_dotgitmodules \ ++ 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