* [PATCH] fast-export: Correctly generate initial commits with no parents
@ 2008-06-13 4:38 Shawn O. Pearce
0 siblings, 0 replies; only message in thread
From: Shawn O. Pearce @ 2008-06-13 4:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Johannes Schindelin
If we are exporting a commit which has no parents we may be doing
it to a branch that already exists, causing fast-import to assume
the branch's current revision should be the sole parent of the
new commit. This can cause `git fast-export | git fast-import`
to produce an incorrect graph for:
A-------M----o------o refs/heads/master
/
B-+
In this graph A and B are initial commits (no parents) but if A was
output first to refs/heads/master and then B is output fast-import
would assume the graph was this instead:
A-------M----o------o refs/heads/master
\ /
+-B-+
Which would cause B, M, and all later commits to have a different
SHA-1, and obviously be quite a different graph.
Sending a reset command prior to B informs fast-import to clear
the implied parent of A, allowing B to remain an initial commit.
Reported-by: Ben Lynn <benlynn@gmail.com>
Deemed-obviously-correct-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
builtin-fast-export.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 1dfc01e..d0a462f 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -188,6 +188,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
mark_object(&commit->object);
if (!is_encoding_utf8(encoding))
reencoded = reencode_string(message, "UTF-8", encoding);
+ if (!commit->parents)
+ printf("reset %s\n", (const char*)commit->util);
printf("commit %s\nmark :%d\n%.*s\n%.*s\ndata %u\n%s",
(const char *)commit->util, last_idnum,
(int)(author_end - author), author,
--
1.5.6.rc2.165.g2a0cc
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-06-13 4:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-13 4:38 [PATCH] fast-export: Correctly generate initial commits with no parents Shawn O. Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).