summaryrefslogtreecommitdiff
path: root/submodule.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-09-25 06:24:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-25 06:24:07 (GMT)
commitceb7a01aac907f124ca9bc0d768336e7c0aaa944 (patch)
tree572653023abd76faf00323f0862a6054a6f319e8 /submodule.c
parentc50424a6f07f17ff9b06927606df650cd73a09a3 (diff)
parent006f3f28af2afb8c567ef3ddf4f0a9110c6be437 (diff)
downloadgit-ceb7a01aac907f124ca9bc0d768336e7c0aaa944.zip
git-ceb7a01aac907f124ca9bc0d768336e7c0aaa944.tar.gz
git-ceb7a01aac907f124ca9bc0d768336e7c0aaa944.tar.bz2
Merge branch 'jn/per-repo-object-store-fixes'
Step #0 of a planned & larger series to make the in-core object store per in-core repository object. * jn/per-repo-object-store-fixes: replace-objects: evaluate replacement refs without using the object store push, fetch: error out for submodule entries not pointing to commits pack: make packed_git_mru global a value instead of a pointer
Diffstat (limited to 'submodule.c')
-rw-r--r--submodule.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/submodule.c b/submodule.c
index 075c55f..b12600f 100644
--- a/submodule.c
+++ b/submodule.c
@@ -774,19 +774,36 @@ static int append_oid_to_argv(const struct object_id *oid, void *data)
return 0;
}
+struct has_commit_data {
+ int result;
+ const char *path;
+};
+
static int check_has_commit(const struct object_id *oid, void *data)
{
- int *has_commit = data;
+ struct has_commit_data *cb = data;
- if (!lookup_commit_reference(oid))
- *has_commit = 0;
+ enum object_type type = sha1_object_info(oid->hash, NULL);
- return 0;
+ switch (type) {
+ case OBJ_COMMIT:
+ return 0;
+ case OBJ_BAD:
+ /*
+ * Object is missing or invalid. If invalid, an error message
+ * has already been printed.
+ */
+ cb->result = 0;
+ return 0;
+ default:
+ die(_("submodule entry '%s' (%s) is a %s, not a commit"),
+ cb->path, oid_to_hex(oid), typename(type));
+ }
}
static int submodule_has_commits(const char *path, struct oid_array *commits)
{
- int has_commit = 1;
+ struct has_commit_data has_commit = { 1, path };
/*
* Perform a cheap, but incorrect check for the existence of 'commits'.
@@ -802,7 +819,7 @@ static int submodule_has_commits(const char *path, struct oid_array *commits)
oid_array_for_each_unique(commits, check_has_commit, &has_commit);
- if (has_commit) {
+ if (has_commit.result) {
/*
* Even if the submodule is checked out and the commit is
* present, make sure it exists in the submodule's object store
@@ -821,12 +838,12 @@ static int submodule_has_commits(const char *path, struct oid_array *commits)
cp.dir = path;
if (capture_command(&cp, &out, GIT_MAX_HEXSZ + 1) || out.len)
- has_commit = 0;
+ has_commit.result = 0;
strbuf_release(&out);
}
- return has_commit;
+ return has_commit.result;
}
static int submodule_needs_pushing(const char *path, struct oid_array *commits)