@@ -122,37 +122,49 @@ static void for_each_cached_alternate(struct fetch_negotiator *negotiator,
122
122
cb (negotiator , cache .items [i ]);
123
123
}
124
124
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 )
125
+ static void die_in_commit_graph_only (const struct object_id * oid )
129
126
{
130
- struct object_info info = { .typep = type };
127
+ die (_ ("You are attempting to fetch %s, which is in the commit graph file but not in the object database.\n"
128
+ "This is probably due to repo corruption.\n"
129
+ "If you are attempting to repair this repo corruption by refetching the missing object, use 'git fetch --refetch' with the missing object." ),
130
+ oid_to_hex (oid ));
131
+ }
132
+
133
+ static struct commit * deref_without_lazy_fetch (const struct object_id * oid ,
134
+ int mark_tags_complete_and_check_obj_db )
135
+ {
136
+ enum object_type type ;
137
+ struct object_info info = { .typep = & type };
131
138
struct commit * commit ;
132
139
133
140
commit = lookup_commit_in_graph (the_repository , oid );
134
- if (commit )
141
+ if (commit ) {
142
+ if (mark_tags_complete_and_check_obj_db ) {
143
+ if (!has_object (the_repository , oid , 0 ))
144
+ die_in_commit_graph_only (oid );
145
+ }
135
146
return commit ;
147
+ }
136
148
137
149
while (1 ) {
138
150
if (oid_object_info_extended (the_repository , oid , & info ,
139
- oi_flags ))
151
+ OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK ))
140
152
return NULL ;
141
- if (* type == OBJ_TAG ) {
153
+ if (type == OBJ_TAG ) {
142
154
struct tag * tag = (struct tag * )
143
155
parse_object (the_repository , oid );
144
156
145
157
if (!tag -> tagged )
146
158
return NULL ;
147
- if (mark_tags_complete )
159
+ if (mark_tags_complete_and_check_obj_db )
148
160
tag -> object .flags |= COMPLETE ;
149
161
oid = & tag -> tagged -> oid ;
150
162
} else {
151
163
break ;
152
164
}
153
165
}
154
166
155
- if (* type == OBJ_COMMIT ) {
167
+ if (type == OBJ_COMMIT ) {
156
168
struct commit * commit = lookup_commit (the_repository , oid );
157
169
if (!commit || repo_parse_commit (the_repository , commit ))
158
170
return NULL ;
@@ -162,16 +174,6 @@ static struct commit *deref_without_lazy_fetch_extended(const struct object_id *
162
174
return NULL ;
163
175
}
164
176
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
-
175
177
static int rev_list_insert_ref (struct fetch_negotiator * negotiator ,
176
178
const struct object_id * oid )
177
179
{
0 commit comments