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

Re: The case for two trees in a commit ("How to make rebase less modal")

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 1, 2018, 18:44 UTC
Message-ID
<xmqqh8pzhbz3.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<CAGZ79ka6PXgs+JDicaQYWYSKgEthj0A-2bBaRcdp_0T2H+sREA@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
Show 14 quoted lines
> $ git hash-object --stdin -w -t commit <<EOF
> tree c70b4a33a0089f15eb3b38092832388d75293e86
> parent 105d5b91138ced892765a84e771a061ede8d63b8
> author Stefan Beller <sbeller@google.com> 1519859216 -0800
> committer Stefan Beller <sbeller@google.com> 1519859216 -0800
> tree 5495266479afc9a4bd9560e9feac465ed43fa63a
> test commit
> EOF
> 19abfc3bf1c5d782045acf23abdf7eed81e16669
> $ git fsck |grep 19abfc3bf1c5d782045acf23abdf7eed81e16669
> $
>
> So it is technically possible to create a commit with two tree entries
> and fsck is not complaining.

The second one is merely a random unauthorized header that is not interpreted in any way by Git. It is merely being confusing by starting with "tree " and having 40-hex after it, but the 40-hex does not get interpreted as an object name, and does not participate in reachability computation (i.e. packing, pruning and fsck).

There is not much difference between that and a line of trailer in the commit log message (other than this one is less discoverable).

Previous: Junio C HamanoNext: Jonathan Nieder
Message 7 of 8 in “The case for two trees in a commit ("How to make rebase less modal")”
  1. Stefan BellerFeb 28, 2018
  2. Ramsay JonesMar 1, 2018
  3. Brandon WilliamsMar 1, 2018
  4. Jeff KingMar 1, 2018
  5. Jacob KellerMar 1, 2018
  6. Junio C HamanoMar 1, 2018
  7. Junio C HamanoMar 1, 2018
  8. Jonathan NiederMar 1, 2018

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.