Skip to content

Commit 0c637bb

Browse files
dschonalla
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 c25fa2e commit 0c637bb

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

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

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

0 commit comments

Comments
 (0)