Skip to content

Commit e6812cf

Browse files
felipecgitster
authored andcommitted
fast-export: do not parse non-commit objects while reading marks file
We read from the marks file and keep only marked commits, but in order to find the type of object, we are parsing the whole thing, which is slow, specially in big repositories with lots of big files. There's no need for that, we can query the object information with sha1_object_info(). Before this, loading the objects of a fresh emacs import, with 260598 blobs took 14 minutes, after this patch, it takes 3 seconds. This is the way fast-import does it. Also die if the object is not found (like fast-import). Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7d3ccdf commit e6812cf

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

builtin/fast-export.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ static void import_marks(char *input_file)
613613
char *line_end, *mark_end;
614614
unsigned char sha1[20];
615615
struct object *object;
616+
enum object_type type;
616617

617618
line_end = strchr(line, '\n');
618619
if (line[0] != ':' || !line_end)
@@ -627,17 +628,19 @@ static void import_marks(char *input_file)
627628
if (last_idnum < mark)
628629
last_idnum = mark;
629630

630-
object = parse_object(sha1);
631-
if (!object)
631+
type = sha1_object_info(sha1, NULL);
632+
if (type < 0)
633+
die("object not found: %s", sha1_to_hex(sha1));
634+
635+
if (type != OBJ_COMMIT)
636+
/* only commits */
632637
continue;
633638

639+
object = parse_object(sha1);
640+
634641
if (object->flags & SHOWN)
635642
error("Object %s already has a mark", sha1_to_hex(sha1));
636643

637-
if (object->type != OBJ_COMMIT)
638-
/* only commits */
639-
continue;
640-
641644
mark_object(object, mark);
642645

643646
object->flags |= SHOWN;

0 commit comments

Comments
 (0)