Skip to content

Commit a89b09f

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 0928df0 commit a89b09f

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
@@ -866,9 +866,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
866866
}
867867
}
868868

869+
static void handle_reset(const char *name, struct object *object)
870+
{
871+
int mark = get_object_mark(object);
872+
873+
if (mark)
874+
printf("reset %s\nfrom :%d\n\n", name,
875+
get_object_mark(object));
876+
else
877+
printf("reset %s\nfrom %s\n\n", name,
878+
oid_to_hex(&object->oid));
879+
}
880+
869881
static void handle_tags_and_duplicates(void)
870882
{
871-
struct commit *commit;
872883
int i;
873884

874885
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -882,9 +893,7 @@ static void handle_tags_and_duplicates(void)
882893
if (anonymize)
883894
name = anonymize_refname(name);
884895
/* create refs pointing to already seen commits */
885-
commit = (struct commit *)object;
886-
printf("reset %s\nfrom :%d\n\n", name,
887-
get_object_mark(&commit->object));
896+
handle_reset(name, object);
888897
show_progress();
889898
break;
890899
}

0 commit comments

Comments
 (0)