Skip to content

Commit a4544b3

Browse files
derrickstoleegitster
authored andcommitted
pack-objects: ignore ambiguous object warnings
A git push process runs several processes during its run, but one includes git send-pack which calls git pack-objects and passes the known have/wants into stdin using object ids. However, the default setting for core.warnAmbiguousRefs requires git pack-objects to check for ref names matching the ref_rev_parse_rules array in refs.c. This means that every object is triggering at least six "file exists?" queries. When there are a lot of refs, this can add up significantly! I observed a simple push spending three seconds checking these paths. The fix here is similar to 4c30d50 "rev-list: disable object/refname ambiguity check with --stdin". While the get_object_list() method reads the objects from stdin, turn warn_on_object_refname_ambiguity flag (which is usually true) to false. Just for code hygiene, save away the original at the beginning and restore it once we are done. Helped-by: Jeff King <[email protected]> Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cae598d commit a4544b3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

builtin/pack-objects.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,6 +2988,7 @@ static void get_object_list(int ac, const char **av)
29882988
struct rev_info revs;
29892989
char line[1000];
29902990
int flags = 0;
2991+
int save_warning;
29912992

29922993
init_revisions(&revs, NULL);
29932994
save_commit_buffer = 0;
@@ -2996,6 +2997,9 @@ static void get_object_list(int ac, const char **av)
29962997
/* make sure shallows are read */
29972998
is_repository_shallow(the_repository);
29982999

3000+
save_warning = warn_on_object_refname_ambiguity;
3001+
warn_on_object_refname_ambiguity = 0;
3002+
29993003
while (fgets(line, sizeof(line), stdin) != NULL) {
30003004
int len = strlen(line);
30013005
if (len && line[len - 1] == '\n')
@@ -3022,6 +3026,8 @@ static void get_object_list(int ac, const char **av)
30223026
die(_("bad revision '%s'"), line);
30233027
}
30243028

3029+
warn_on_object_refname_ambiguity = save_warning;
3030+
30253031
if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
30263032
return;
30273033

0 commit comments

Comments
 (0)