From: Dmitry Ivankov Date: Wed, 27 Jun 2012 17:40:23 GMT Subject: [PATCH v2 1/3] fast-import: do not write null_sha1 as a merge parent Message-ID: <1340818825-13754-2-git-send-email-divanorama@gmail.com> In-Reply-To: <1340818825-13754-1-git-send-email-divanorama@gmail.com> null_sha1 is used in fast-import to indicate "empty" branches and should never be actually written out as a commit parent. 'merge' command lacks is_null_sha1 checks and must be fixed. It looks like using null_sha1 or empty branches in 'from' command is legal and/or an intended option (it has been here from the very beginning and survived). So leave it allowed for 'merge' command too, and just like with 'from' command silently skip null_sha1 parents. Add a simple test for null_sha1 merge parents. Signed-off-by: Dmitry Ivankov --- fast-import.c | 3 ++- t/t9300-fast-import.sh | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletions(-) diff --git a/fast-import.c b/fast-import.c index eed97c8..419e435 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2734,7 +2734,8 @@ static void parse_new_commit(void) strbuf_addf(&new_data, "parent %s\n", sha1_to_hex(b->sha1)); while (merge_list) { struct hash_list *next = merge_list->next; - strbuf_addf(&new_data, "parent %s\n", sha1_to_hex(merge_list->sha1)); + if (!is_null_sha1(merge_list->sha1)) + strbuf_addf(&new_data, "parent %s\n", sha1_to_hex(merge_list->sha1)); free(merge_list); merge_list = next; } diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index c17f52e..5716420 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -850,6 +850,27 @@ INPUT_END test_expect_success \ 'J: tag must fail on empty branch' \ 'test_must_fail git fast-import input < $GIT_COMMITTER_DATE +data <