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 <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
This commit is contained in:
Johannes Schindelin
2011-07-23 15:55:26 +02:00
committed by Johannes Schindelin
parent 8d90955be0
commit 3417a9ff29

View File

@@ -874,9 +874,20 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
}
}
static void handle_reset(const char *name, struct object *object)
{
int mark = get_object_mark(object);
if (mark)
printf("reset %s\nfrom :%d\n\n", name,
get_object_mark(object));
else
printf("reset %s\nfrom %s\n\n", name,
oid_to_hex(&object->oid));
}
static void handle_tags_and_duplicates(void)
{
struct commit *commit;
int i;
for (i = extra_refs.nr - 1; i >= 0; i--) {
@@ -890,9 +901,7 @@ static void handle_tags_and_duplicates(void)
if (anonymize)
name = anonymize_refname(name);
/* create refs pointing to already seen commits */
commit = (struct commit *)object;
printf("reset %s\nfrom :%d\n\n", name,
get_object_mark(&commit->object));
handle_reset(name, object);
show_progress();
break;
}