Skip to content

Commit

Permalink
Merge branch 'fc/fast-export-persistent-marks'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Jun 2, 2013
2 parents 843fb91 + 45c5d4a commit dbbc93b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ static void import_marks(char *input_file)
char *line_end, *mark_end;
unsigned char sha1[20];
struct object *object;
struct commit *commit;
enum object_type type;

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

mark = strtoumax(line + 1, &mark_end, 10);
if (!mark || mark_end == line + 1
|| *mark_end != ' ' || get_sha1(mark_end + 1, sha1))
|| *mark_end != ' ' || get_sha1_hex(mark_end + 1, sha1))
die("corrupt mark line: %s", line);

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;

commit = lookup_commit(sha1);
if (!commit)
die("not a commit? can't happen: %s", sha1_to_hex(sha1));

object = &commit->object;

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;
Expand Down
2 changes: 1 addition & 1 deletion fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ static void read_marks(void)
*end = 0;
mark = strtoumax(line + 1, &end, 10);
if (!mark || end == line + 1
|| *end != ' ' || get_sha1(end + 1, sha1))
|| *end != ' ' || get_sha1_hex(end + 1, sha1))
die("corrupt mark line: %s", line);
e = find_object(sha1);
if (!e) {
Expand Down

0 comments on commit dbbc93b

Please sign in to comment.