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

Commit b1a3988

Browse files
dschokasal
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 ec765f6 commit b1a3988

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
@@ -556,9 +556,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
556556
}
557557
}
558558

559+
static void handle_reset(const char *name, struct object *object)
560+
{
561+
int mark = get_object_mark(object);
562+
563+
if (mark)
564+
printf("reset %s\nfrom :%d\n\n", name,
565+
get_object_mark(object));
566+
else
567+
printf("reset %s\nfrom %s\n\n", name,
568+
sha1_to_hex(object->sha1));
569+
}
570+
559571
static void handle_tags_and_duplicates(void)
560572
{
561-
struct commit *commit;
562573
int i;
563574

564575
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -570,9 +581,7 @@ static void handle_tags_and_duplicates(void)
570581
break;
571582
case OBJ_COMMIT:
572583
/* create refs pointing to already seen commits */
573-
commit = (struct commit *)object;
574-
printf("reset %s\nfrom :%d\n\n", name,
575-
get_object_mark(&commit->object));
584+
handle_reset(name, object);
576585
show_progress();
577586
break;
578587
}

0 commit comments

Comments
 (0)