Skip to content

Commit c92d069

Browse files
committed
Merge branch 'jt/commit-graph-missing' into seen
* jt/commit-graph-missing: fetch-pack: warn if in commit graph but not obj db Revert "fetch-pack: add a deref_without_lazy_fetch_extended()"
2 parents 084c9e7 + b866533 commit c92d069

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

fetch-pack.c

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static struct string_list uri_protocols = STRING_LIST_INIT_DUP;
5757
#define ALTERNATE (1U << 1)
5858
#define COMMON (1U << 6)
5959
#define REACH_SCRATCH (1U << 7)
60+
#define COMPLETE_FROM_COMMIT_GRAPH (1U << 8)
6061

6162
/*
6263
* After sending this many "have"s if we do not get any new ACK , we
@@ -122,37 +123,39 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,
122123
cb(negotiator, cache.items[i]);
123124
}
124125

125-
static struct commit *deref_without_lazy_fetch_extended(const struct object_id *oid,
126-
int mark_tags_complete,
127-
enum object_type *type,
128-
unsigned int oi_flags)
126+
static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
127+
int mark_additional_complete_information)
129128
{
130-
struct object_info info = { .typep = type };
129+
enum object_type type;
130+
struct object_info info = { .typep = &type };
131131
struct commit *commit;
132132

133133
commit = lookup_commit_in_graph(the_repository, oid);
134-
if (commit)
134+
if (commit) {
135+
if (mark_additional_complete_information)
136+
commit->object.flags |= COMPLETE_FROM_COMMIT_GRAPH;
135137
return commit;
138+
}
136139

137140
while (1) {
138141
if (oid_object_info_extended(the_repository, oid, &info,
139-
oi_flags))
142+
OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK))
140143
return NULL;
141-
if (*type == OBJ_TAG) {
144+
if (type == OBJ_TAG) {
142145
struct tag *tag = (struct tag *)
143146
parse_object(the_repository, oid);
144147

145148
if (!tag->tagged)
146149
return NULL;
147-
if (mark_tags_complete)
150+
if (mark_additional_complete_information)
148151
tag->object.flags |= COMPLETE;
149152
oid = &tag->tagged->oid;
150153
} else {
151154
break;
152155
}
153156
}
154157

155-
if (*type == OBJ_COMMIT) {
158+
if (type == OBJ_COMMIT) {
156159
struct commit *commit = lookup_commit(the_repository, oid);
157160
if (!commit || repo_parse_commit(the_repository, commit))
158161
return NULL;
@@ -162,16 +165,6 @@ static struct commit *deref_without_lazy_fetch_extended(const struct object_id *
162165
return NULL;
163166
}
164167

165-
166-
static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
167-
int mark_tags_complete)
168-
{
169-
enum object_type type;
170-
unsigned flags = OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK;
171-
return deref_without_lazy_fetch_extended(oid, mark_tags_complete,
172-
&type, flags);
173-
}
174-
175168
static int rev_list_insert_ref(struct fetch_negotiator *negotiator,
176169
const struct object_id *oid)
177170
{
@@ -820,6 +813,14 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator,
820813
save_commit_buffer = old_save_commit_buffer;
821814
}
822815

816+
static void warn_in_commit_graph_only(const struct object_id *oid)
817+
{
818+
warning(_("You are attempting to fetch %s, which is in the commit graph file but not in the object database."),
819+
oid_to_hex(oid));
820+
warning(_("This is probably due to repo corruption."));
821+
warning(_("If you are attempting to repair this repo corruption by refetching the missing object, use 'git fetch --refetch' with the missing object."));
822+
}
823+
823824
/*
824825
* Returns 1 if every object pointed to by the given remote refs is available
825826
* locally and reachable from a local ref, and 0 otherwise.
@@ -841,6 +842,10 @@ static int everything_local(struct fetch_pack_args *args,
841842
ref->name);
842843
continue;
843844
}
845+
if (o->flags & COMPLETE_FROM_COMMIT_GRAPH) {
846+
if (!has_object(the_repository, remote, 0))
847+
warn_in_commit_graph_only(remote);
848+
}
844849
print_verbose(args, _("already have %s (%s)"), oid_to_hex(remote),
845850
ref->name);
846851
}

object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void object_array_init(struct object_array *array);
6565
/*
6666
* object flag allocation:
6767
* revision.h: 0---------10 15 23------27
68-
* fetch-pack.c: 01 67
68+
* fetch-pack.c: 01 6-8
6969
* negotiator/default.c: 2--5
7070
* walker.c: 0-2
7171
* upload-pack.c: 4 11-----14 16-----19

0 commit comments

Comments
 (0)