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

[PATCH 0/2] fix git-archive with empty trees

From
Jeff King <peff@peff.net>
Date
Mar 11, 2013, 01:31 UTC
Message-ID
<20130311013123.GA11692@sigill.intra.peff.net>

I noticed that "git archive" will barf when the root tree is empty. Instead, it should probably return an empty archive. I doubt many people really care about this corner case in practice, but it seems like we should handle it more gracefully (and it's an easy fix).

It came to my attention because we track failed git-archive invocations at GitHub, and a particular repo had a two commits: adding some content, then reverting the original commit. You can also get there with "commit --allow-empty" on a new branch (which is what the tests do).

I didn't bother even looking at empty subtrees. AFAIK, git should never produce them (it omits the tree entirely if there is no content in it). You would have to fake it using hash-object manually. I suspect it would work just fine, as we already exercise the empty-dir code paths in the tests I did add.

  [1/2]: test-lib: factor out $GIT_UNZIP setup
  [2/2]: archive: handle commits with an empty tree
-Peff
Next: Jeff King
Message 1 of 5 in “fix git-archive with empty trees”
  1. 0/2 fix git-archive with empty treesJeff King, Mar 11, 2013
  2. 1/2 test-lib: factor out $GIT_UNZIP setupJeff King, Mar 11, 2013
  3. 2/2 archive: handle commits with an empty treeJeff King, Mar 11, 2013
  4. Jeff KingMar 11, 2013
  5. Junio C HamanoMar 11, 2013

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.