Skip to content

Commit ee47243

Browse files
jonathantanmygitster
authored andcommitted
pack-objects: no fetch when allow-{any,promisor}
The options --missing=allow-{any,promisor} were introduced in caf3827 ("rev-list: add list-objects filtering support", 2017-11-22) with the following note in the commit message: This patch introduces handling of missing objects to help debugging and development of the "partial clone" mechanism, and once the mechanism is implemented, for a power user to perform operations that are missing-object aware without incurring the cost of checking if a missing link is expected. The idea that these options are missing-object aware (and thus do not need to lazily fetch objects, unlike unaware commands that assume that all objects are present) are assumed in later commits such as 07ef3c6 ("fetch test: use more robust test for filtered objects", 2020-01-15). However, the current implementations of these options use has_object_file(), which indeed lazily fetches missing objects. Teach these implementations not to do so. Also, update the documentation of these options to be clearer. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3318238 commit ee47243

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Documentation/git-pack-objects.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,18 @@ So does `git bundle` (see linkgit:git-bundle[1]) when it creates a bundle.
270270
This option specifies how missing objects are handled.
271271
+
272272
The form '--missing=error' requests that pack-objects stop with an error if
273-
a missing object is encountered. This is the default action.
273+
a missing object is encountered. If the repository is a partial clone, an
274+
attempt to fetch missing objects will be made before declaring them missing.
275+
This is the default action.
274276
+
275277
The form '--missing=allow-any' will allow object traversal to continue
276-
if a missing object is encountered. Missing objects will silently be
277-
omitted from the results.
278+
if a missing object is encountered. No fetch of a missing object will occur.
279+
Missing objects will silently be omitted from the results.
278280
+
279281
The form '--missing=allow-promisor' is like 'allow-any', but will only
280282
allow object traversal to continue for EXPECTED promisor missing objects.
281-
Unexpected missing object will raise an error.
283+
No fetch of a missing object will occur. An unexpected missing object will
284+
raise an error.
282285

283286
--exclude-promisor-objects::
284287
Omit objects that are known to be in the promisor remote. (This

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,7 @@ static void show_object__ma_allow_any(struct object *obj, const char *name, void
30483048
* Quietly ignore ALL missing objects. This avoids problems with
30493049
* staging them now and getting an odd error later.
30503050
*/
3051-
if (!has_object_file(&obj->oid))
3051+
if (!has_object(the_repository, &obj->oid, 0))
30523052
return;
30533053

30543054
show_object(obj, name, data);
@@ -3062,7 +3062,7 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,
30623062
* Quietly ignore EXPECTED missing objects. This avoids problems with
30633063
* staging them now and getting an odd error later.
30643064
*/
3065-
if (!has_object_file(&obj->oid) && is_promisor_object(&obj->oid))
3065+
if (!has_object(the_repository, &obj->oid, 0) && is_promisor_object(&obj->oid))
30663066
return;
30673067

30683068
show_object(obj, name, data);

0 commit comments

Comments
 (0)