summaryrefslogtreecommitdiff
path: root/builtin/fast-export.c
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2013-05-05 22:38:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-07 14:03:01 (GMT)
commite6812cfa9aba69a8c9d83b0710291b27bff0f7a3 (patch)
treeb2b1906922e5bfe8c1903e28bbc6264e533c564a /builtin/fast-export.c
parent7d3ccdffb5d28970dd7a4d177cfcca690ccd0c22 (diff)
downloadgit-e6812cfa9aba69a8c9d83b0710291b27bff0f7a3.zip
git-e6812cfa9aba69a8c9d83b0710291b27bff0f7a3.tar.gz
git-e6812cfa9aba69a8c9d83b0710291b27bff0f7a3.tar.bz2
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 <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fast-export.c')
-rw-r--r--builtin/fast-export.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index d60d675..dd561e5 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -613,6 +613,7 @@ static void import_marks(char *input_file)
char *line_end, *mark_end;
unsigned char sha1[20];
struct object *object;
+ enum object_type type;
line_end = strchr(line, '\n');
if (line[0] != ':' || !line_end)
@@ -627,17 +628,19 @@ static void import_marks(char *input_file)
if (last_idnum < mark)
last_idnum = mark;
- object = parse_object(sha1);
- if (!object)
+ type = sha1_object_info(sha1, NULL);
+ if (type < 0)
+ die("object not found: %s", sha1_to_hex(sha1));
+
+ if (type != OBJ_COMMIT)
+ /* only commits */
continue;
+ object = parse_object(sha1);
+
if (object->flags & SHOWN)
error("Object %s already has a mark", sha1_to_hex(sha1));
- if (object->type != OBJ_COMMIT)
- /* only commits */
- continue;
-
mark_object(object, mark);
object->flags |= SHOWN;