From: Junio C Hamano Date: Wed, 2 Aug 2017 21:34:28 +0000 (-0700) Subject: Merge branch 'bc/object-id' into bw/submodule-config-cleanup X-Git-Tag: v2.15.0-rc0~120^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a46ddc992bbac524fb325875c5555dbae0c6355b;p=thirdparty%2Fgit.git Merge branch 'bc/object-id' into bw/submodule-config-cleanup * bc/object-id: sha1_name: convert uses of 40 to GIT_SHA1_HEXSZ sha1_name: convert GET_SHA1* flags to GET_OID* sha1_name: convert get_sha1* to get_oid* Convert remaining callers of get_sha1 to get_oid. builtin/unpack-file: convert to struct object_id bisect: convert bisect_checkout to struct object_id builtin/update_ref: convert to struct object_id sequencer: convert to struct object_id remote: convert struct push_cas to struct object_id submodule: convert submodule config lookup to use object_id builtin/merge-tree: convert remaining caller of get_sha1 to object_id builtin/fsck: convert remaining caller of get_sha1 to object_id tag: convert gpg_verify_tag to use struct object_id commit: convert lookup_commit_graft to struct object_id --- a46ddc992bbac524fb325875c5555dbae0c6355b diff --cc builtin/grep.c index cd0e51f3c0,9124450163..ac06d2d33c --- a/builtin/grep.c +++ b/builtin/grep.c @@@ -643,10 -862,9 +643,10 @@@ static int grep_objects(struct grep_op /* load the gitmodules file for this rev */ if (recurse_submodules) { submodule_free(); - gitmodules_config_sha1(real_obj->oid.hash); + gitmodules_config_oid(&real_obj->oid); } - if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].path)) { + if (grep_object(opt, pathspec, real_obj, list->objects[i].name, list->objects[i].path, + repo)) { hit = 1; if (opt->status_only) break; diff --cc submodule.c index 9d5eacaf9f,f39cb4f6ea..5139b9256b --- a/submodule.c +++ b/submodule.c @@@ -79,13 -63,13 +79,13 @@@ int update_path_in_gitmodules(const cha struct strbuf entry = STRBUF_INIT; const struct submodule *submodule; - if (!file_exists(".gitmodules")) /* Do nothing without .gitmodules */ + if (!file_exists(GITMODULES_FILE)) /* Do nothing without .gitmodules */ return -1; - if (gitmodules_is_unmerged) + if (is_gitmodules_unmerged(&the_index)) die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first")); - submodule = submodule_from_path(null_sha1, oldpath); + submodule = submodule_from_path(&null_oid, oldpath); if (!submodule || !submodule->name) { warning(_("Could not find section in .gitmodules where path=%s"), oldpath); return -1; @@@ -113,13 -97,13 +113,13 @@@ int remove_path_from_gitmodules(const c struct strbuf sect = STRBUF_INIT; const struct submodule *submodule; - if (!file_exists(".gitmodules")) /* Do nothing without .gitmodules */ + if (!file_exists(GITMODULES_FILE)) /* Do nothing without .gitmodules */ return -1; - if (gitmodules_is_unmerged) + if (is_gitmodules_unmerged(&the_index)) die(_("Cannot change unmerged .gitmodules, resolve merge conflicts first")); - submodule = submodule_from_path(null_sha1, path); + submodule = submodule_from_path(&null_oid, path); if (!submodule || !submodule->name) { warning(_("Could not find section in .gitmodules where path=%s"), path); return -1; @@@ -238,34 -264,20 +238,34 @@@ static int gitmodules_cb(const char *va void repo_read_gitmodules(struct repository *repo) { - char *gitmodules_path = repo_worktree_path(repo, ".gitmodules"); + if (repo->worktree) { + char *gitmodules; + + if (repo_read_index(repo) < 0) + return; + + gitmodules = repo_worktree_path(repo, GITMODULES_FILE); + + if (!is_gitmodules_unmerged(repo->index)) + git_config_from_file(gitmodules_cb, gitmodules, repo); - git_config_from_file(gitmodules_cb, gitmodules_path, repo); - free(gitmodules_path); + free(gitmodules); + } +} + +void gitmodules_config(void) +{ + repo_read_gitmodules(the_repository); } - void gitmodules_config_sha1(const unsigned char *commit_sha1) + void gitmodules_config_oid(const struct object_id *commit_oid) { struct strbuf rev = STRBUF_INIT; - unsigned char sha1[20]; + struct object_id oid; - if (gitmodule_sha1_from_commit(commit_sha1, sha1, &rev)) { - git_config_from_blob_sha1(git_modules_config, rev.buf, - sha1, NULL); + if (gitmodule_oid_from_commit(commit_oid, &oid, &rev)) { + git_config_from_blob_oid(submodule_config, rev.buf, + &oid, NULL); } strbuf_release(&rev); }