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

Re: mktree: multiple same-named objects

From
Jeff King <peff@peff.net>
Date
Aug 27, 2014, 05:13 UTC
Message-ID
<20140827051341.GB32141@peff.net>
In-Reply-To
<1409114517.13351.6.camel@leckie>
On Wed, Aug 27, 2014 at 12:41:57AM -0400, David Turner wrote:
> git mktree seems to allow the creation of a tree object with multiple
> objects of the same name but different SHAs.

Yeah, I don't think we do many quality checks there. Ditto for "git hash-object".

The latter goes through index_mem, which at least checks that the resulting tree is parseable. It does not look like mktree even checks that.

> Summary: git mktree ought to forbid this, and possibly there ought to be
> other checks (for instance, when unpacking) to prevent this.

The checks in git-fsck will notice your problem (and many others). I think we should be running them anytime we create an object based on arbitrary data (including mktree and hash-object). Code paths like "git write-tree" and "git commit-tree" are probably OK, as their code should follow the standard (it would not hurt to double-check their output, though there may be a performance implication).

Dscho (cc'd) has been looking into this approach; I don't know how far he has gotten.

-Peff
Previous: David TurnerNext: Junio C Hamano
Message 4 of 6 in “mktree: multiple same-named objects”
  1. David TurnerAug 27, 2014
  2. Duy NguyenAug 27, 2014
  3. David TurnerAug 27, 2014
  4. Jeff KingAug 27, 2014
  5. Junio C HamanoAug 27, 2014
  6. Jeff KingAug 27, 2014

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.