summaryrefslogtreecommitdiffstats
path: root/fetch-pack.c
diff options
context:
space:
mode:
Diffstat (limited to 'fetch-pack.c')
-rw-r--r--fetch-pack.c69
1 files changed, 41 insertions, 28 deletions
diff --git a/fetch-pack.c b/fetch-pack.c
index f752da93a8..3a227721ed 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1,4 +1,5 @@
#define USE_THE_REPOSITORY_VARIABLE
+#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "repository.h"
@@ -122,29 +123,41 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,
cb(negotiator, cache.items[i]);
}
-static struct commit *deref_without_lazy_fetch_extended(const struct object_id *oid,
- int mark_tags_complete,
- enum object_type *type,
- unsigned int oi_flags)
+static void die_in_commit_graph_only(const struct object_id *oid)
{
- struct object_info info = { .typep = type };
+ die(_("You are attempting to fetch %s, which is in the commit graph file but not in the object database.\n"
+ "This is probably due to repo corruption.\n"
+ "If you are attempting to repair this repo corruption by refetching the missing object, use 'git fetch --refetch' with the missing object."),
+ oid_to_hex(oid));
+}
+
+static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
+ int mark_tags_complete_and_check_obj_db)
+{
+ enum object_type type;
+ struct object_info info = { .typep = &type };
struct commit *commit;
commit = lookup_commit_in_graph(the_repository, oid);
- if (commit)
+ if (commit) {
+ if (mark_tags_complete_and_check_obj_db) {
+ if (!has_object(the_repository, oid, 0))
+ die_in_commit_graph_only(oid);
+ }
return commit;
+ }
while (1) {
if (oid_object_info_extended(the_repository, oid, &info,
- oi_flags))
+ OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
return NULL;
- if (*type == OBJ_TAG) {
+ if (type == OBJ_TAG) {
struct tag *tag = (struct tag *)
parse_object(the_repository, oid);
if (!tag->tagged)
return NULL;
- if (mark_tags_complete)
+ if (mark_tags_complete_and_check_obj_db)
tag->object.flags |= COMPLETE;
oid = &tag->tagged->oid;
} else {
@@ -152,7 +165,7 @@ static struct commit *deref_without_lazy_fetch_extended(const struct object_id *
}
}
- if (*type == OBJ_COMMIT) {
+ if (type == OBJ_COMMIT) {
struct commit *commit = lookup_commit(the_repository, oid);
if (!commit || repo_parse_commit(the_repository, commit))
return NULL;
@@ -162,16 +175,6 @@ static struct commit *deref_without_lazy_fetch_extended(const struct object_id *
return NULL;
}
-
-static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
- int mark_tags_complete)
-{
- enum object_type type;
- unsigned flags = OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK;
- return deref_without_lazy_fetch_extended(oid, mark_tags_complete,
- &type, flags);
-}
-
static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
const struct object_id *oid)
{
@@ -1855,8 +1858,8 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
return ref;
}
-static int fetch_pack_config_cb(const char *var, const char *value,
- const struct config_context *ctx, void *cb)
+int fetch_pack_fsck_config(const char *var, const char *value,
+ struct strbuf *msg_types)
{
const char *msg_id;
@@ -1864,9 +1867,9 @@ static int fetch_pack_config_cb(const char *var, const char *value,
char *path ;
if (git_config_pathname(&path, var, value))
- return 1;
- strbuf_addf(&fsck_msg_types, "%cskiplist=%s",
- fsck_msg_types.len ? ',' : '=', path);
+ return 0;
+ strbuf_addf(msg_types, "%cskiplist=%s",
+ msg_types->len ? ',' : '=', path);
free(path);
return 0;
}
@@ -1875,14 +1878,24 @@ static int fetch_pack_config_cb(const char *var, const char *value,
if (!value)
return config_error_nonbool(var);
if (is_valid_msg_type(msg_id, value))
- strbuf_addf(&fsck_msg_types, "%c%s=%s",
- fsck_msg_types.len ? ',' : '=', msg_id, value);
+ strbuf_addf(msg_types, "%c%s=%s",
+ msg_types->len ? ',' : '=', msg_id, value);
else
warning("Skipping unknown msg id '%s'", msg_id);
return 0;
}
- return git_default_config(var, value, ctx, cb);
+ return 1;
+}
+
+static int fetch_pack_config_cb(const char *var, const char *value,
+ const struct config_context *ctx, void *cb)
+{
+ int ret = fetch_pack_fsck_config(var, value, &fsck_msg_types);
+ if (ret > 0)
+ return git_default_config(var, value, ctx, cb);
+
+ return ret;
}
static void fetch_pack_config(void)