Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 9faa058

Browse files
dschokblees
authored andcommitted
fast-export: do not refer to non-existing marks
When calling `git fast-export a..a b` when a and b refer to the same commit, nothing would be exported, and an incorrect reset line would be printed for b ('from :0'). Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Sverre Rabbelier <[email protected]>
1 parent 20ba112 commit 9faa058

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

builtin/fast-export.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
571571
}
572572
}
573573

574+
static void handle_reset(const char *name, struct object *object)
575+
{
576+
int mark = get_object_mark(object);
577+
578+
if (mark)
579+
printf("reset %s\nfrom :%d\n\n", name,
580+
get_object_mark(object));
581+
else
582+
printf("reset %s\nfrom %s\n\n", name,
583+
sha1_to_hex(object->sha1));
584+
}
585+
574586
static void handle_tags_and_duplicates(void)
575587
{
576-
struct commit *commit;
577588
int i;
578589

579590
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -585,9 +596,7 @@ static void handle_tags_and_duplicates(void)
585596
break;
586597
case OBJ_COMMIT:
587598
/* create refs pointing to already seen commits */
588-
commit = (struct commit *)object;
589-
printf("reset %s\nfrom :%d\n\n", name,
590-
get_object_mark(&commit->object));
599+
handle_reset(name, object);
591600
show_progress();
592601
break;
593602
}

0 commit comments

Comments
 (0)