Merge branch 'bc/object-id' into bw/submodule-config-cleanup
authorJunio C Hamano <gitster@pobox.com>
Wed, 2 Aug 2017 21:34:28 +0000 (14:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Aug 2017 21:34:28 +0000 (14:34 -0700)
* 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

13 files changed:
1  2 
builtin/grep.c
builtin/submodule--helper.c
cache.h
config.c
config.h
refs.c
remote.c
repository.c
revision.c
submodule-config.c
submodule-config.h
submodule.c
submodule.h
diff --cc builtin/grep.c
index cd0e51f3c04b1e6fc297a8806fa663d86ebc7734,9124450163ebf71eec82ee466b155fc2a749d93e..ac06d2d33c19edbe6bd857b7f6b24f0542013c23
@@@ -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;
Simple merge
diff --cc cache.h
Simple merge
diff --cc config.c
Simple merge
diff --cc config.h
Simple merge
diff --cc refs.c
Simple merge
diff --cc remote.c
Simple merge
diff --cc repository.c
Simple merge
diff --cc revision.c
Simple merge
Simple merge
Simple merge
diff --cc submodule.c
index 9d5eacaf9f2ffad4a7f5d17ced4137e0162215d5,f39cb4f6eafc09642ed6a7131d1cbf7a3efc34d8..5139b9256b589a6524e6158dbb1c2ae492ea4f70
@@@ -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);
  }
diff --cc submodule.h
Simple merge