git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/3] fast-import: do not write null_sha1 as a merge parent

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jun 27, 2012, 21:25 UTC
Message-ID
<20120627212531.GN12774@burratino>
In-Reply-To
<1340818825-13754-2-git-send-email-divanorama@gmail.com>
Dmitry Ivankov wrote:
> 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.
Yeah.
> 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.

Ok, fair enough. Are there any tests in the test script for the "create new branch from unborn branch" trick? Is this worth documenting so other backend authors know what they need to do to support frontends that work with git fast-import?

[...]
Show 9 quoted lines
> --- 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));
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Previous: Dmitry IvankovNext: Jonathan Nieder
Message 3 of 12 in “fast-import: disallow empty branches as parents”
  1. 0/3 fast-import: disallow empty branches as parentsDmitry Ivankov, Jun 27, 2012
  2. 1/3 fast-import: do not write null_sha1 as a merge parentDmitry Ivankov, Jun 27, 2012
  3. Jonathan NiederJun 27, 2012
  4. Jonathan NiederJul 24, 2012
  5. 2/3 fast-import: allow "merge $null_sha1" commandDmitry Ivankov, Jun 27, 2012
  6. Jonathan NiederJun 27, 2012
  7. Junio C HamanoJun 27, 2012
  8. Jonathan NiederJun 27, 2012
  9. Jonathan NiederJul 23, 2012
  10. 3/3 fast-import: disallow "merge $itself" commandDmitry Ivankov, Jun 27, 2012
  11. Jonathan NiederJun 27, 2012
  12. Jonathan NiederJul 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.