Skip to content

Commit dbbc93b

Browse files
committed
Merge branch 'fc/fast-export-persistent-marks'
Optimization for fast-export by avoiding unnecessarily resolving arbitrary object name and parsing object when only presence and type information is necessary, etc. * fc/fast-export-persistent-marks: fast-{import,export}: use get_sha1_hex() to read from marks file fast-export: don't parse commits while reading marks file fast-export: do not parse non-commit objects while reading marks file
2 parents 843fb91 + 45c5d4a commit dbbc93b

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

builtin/fast-export.c

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

617619
line_end = strchr(line, '\n');
618620
if (line[0] != ':' || !line_end)
@@ -621,23 +623,29 @@ static void import_marks(char *input_file)
621623

622624
mark = strtoumax(line + 1, &mark_end, 10);
623625
if (!mark || mark_end == line + 1
624-
|| *mark_end != ' ' || get_sha1(mark_end + 1, sha1))
626+
|| *mark_end != ' ' || get_sha1_hex(mark_end + 1, sha1))
625627
die("corrupt mark line: %s", line);
626628

627629
if (last_idnum < mark)
628630
last_idnum = mark;
629631

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

640+
commit = lookup_commit(sha1);
641+
if (!commit)
642+
die("not a commit? can't happen: %s", sha1_to_hex(sha1));
643+
644+
object = &commit->object;
645+
634646
if (object->flags & SHOWN)
635647
error("Object %s already has a mark", sha1_to_hex(sha1));
636648

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

643651
object->flags |= SHOWN;

fast-import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ static void read_marks(void)
18221822
*end = 0;
18231823
mark = strtoumax(line + 1, &end, 10);
18241824
if (!mark || end == line + 1
1825-
|| *end != ' ' || get_sha1(end + 1, sha1))
1825+
|| *end != ' ' || get_sha1_hex(end + 1, sha1))
18261826
die("corrupt mark line: %s", line);
18271827
e = find_object(sha1);
18281828
if (!e) {

0 commit comments

Comments
 (0)