Skip to content

Commit 3417a9f

Browse files
committed
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 8d90955 commit 3417a9f

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
@@ -874,9 +874,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
874874
}
875875
}
876876

877+
static void handle_reset(const char *name, struct object *object)
878+
{
879+
int mark = get_object_mark(object);
880+
881+
if (mark)
882+
printf("reset %s\nfrom :%d\n\n", name,
883+
get_object_mark(object));
884+
else
885+
printf("reset %s\nfrom %s\n\n", name,
886+
oid_to_hex(&object->oid));
887+
}
888+
877889
static void handle_tags_and_duplicates(void)
878890
{
879-
struct commit *commit;
880891
int i;
881892

882893
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -890,9 +901,7 @@ static void handle_tags_and_duplicates(void)
890901
if (anonymize)
891902
name = anonymize_refname(name);
892903
/* create refs pointing to already seen commits */
893-
commit = (struct commit *)object;
894-
printf("reset %s\nfrom :%d\n\n", name,
895-
get_object_mark(&commit->object));
904+
handle_reset(name, object);
896905
show_progress();
897906
break;
898907
}

0 commit comments

Comments
 (0)