Skip to content

Commit 425f29e

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 abf3368 commit 425f29e

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
@@ -847,9 +847,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
847847
}
848848
}
849849

850+
static void handle_reset(const char *name, struct object *object)
851+
{
852+
int mark = get_object_mark(object);
853+
854+
if (mark)
855+
printf("reset %s\nfrom :%d\n\n", name,
856+
get_object_mark(object));
857+
else
858+
printf("reset %s\nfrom %s\n\n", name,
859+
sha1_to_hex(object->sha1));
860+
}
861+
850862
static void handle_tags_and_duplicates(void)
851863
{
852-
struct commit *commit;
853864
int i;
854865

855866
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -863,9 +874,7 @@ static void handle_tags_and_duplicates(void)
863874
if (anonymize)
864875
name = anonymize_refname(name);
865876
/* create refs pointing to already seen commits */
866-
commit = (struct commit *)object;
867-
printf("reset %s\nfrom :%d\n\n", name,
868-
get_object_mark(&commit->object));
877+
handle_reset(name, object);
869878
show_progress();
870879
break;
871880
}

0 commit comments

Comments
 (0)