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

Re: [RFC/PATCH] hash-object doc: "git hash-object -w" can write invalid objects

From
Jeff King <peff@peff.net>
Date
Feb 22, 2013, 23:09 UTC
Message-ID
<20130222230910.GD21579@sigill.intra.peff.net>
In-Reply-To
<20130222230132.GB4514@google.com>
On Fri, Feb 22, 2013 at 03:01:32PM -0800, Jonathan Nieder wrote:
Show 7 quoted lines
> > Git doesn't handle the resulting tag objects nicely at all. For example,
> > running `git cat-file -p` on the new object outputs a really odd
> > timestamp "Thu Jun Thu Jan 1 00:16:09 1970 +0016" (I'm guessing it
> > parses the year as Unix time),
> 
> The usual rule is that with invalid objects (e.g. as detected by "git
> fsck"), any non-crash result is acceptable.  Garbage in, garbage out.

Agreed, though I think a more consistent garbage would be good (e.g., time=0, tz=0).

> I notice that git-hash-object(1) doesn't contain any reference to
> git-fsck(1).  How about something like this, to start?

I think it's a good change. Though note that this problem is not discovered by fsck (which I think we should also change).

> Perhaps by default hash-object should automatically fsck the objects
> it is asked to create.

Not unreasonable. In this case, we also have git-mktag. It would be nice if we could simply run the input through a type-specific sanity checker (optional, I hope; I use hash-object often to craft test cases like this :) ). The same need came up a month or two ago in a discussion of how to use "git replace" safely. But I guess fsck after-the-fact is just another form of the same solution.

-Peff
Previous: Junio C Hamano
Message 16 of 16 in “Crashes while trying to show tag objects with bad timestamps”
  1. Mantas MikulėnasFeb 22, 2013
  2. Jeff KingFeb 22, 2013
  3. Junio C HamanoFeb 22, 2013
  4. Jeff KingFeb 22, 2013
  5. Mantas MikulėnasFeb 22, 2013
  6. Jeff KingFeb 25, 2013
  7. Junio C HamanoFeb 22, 2013
  8. Jeff KingFeb 25, 2013
  9. 1/4 handle malformed dates in ident linesJeff King, Feb 25, 2013
  10. 2/4 skip_prefix: return a non-const pointerJeff King, Feb 25, 2013
  11. 3/4 fsck: check "tagger" linesJeff King, Feb 25, 2013
  12. 4/4 cat-file: print tags raw for "cat-file -p"Jeff King, Feb 25, 2013
  13. Mantas MikulėnasFeb 25, 2013
  14. hash-object doc: "git hash-object -w" can write invalid objectsJonathan Nieder, Feb 22, 2013
  15. Junio C HamanoFeb 22, 2013
  16. Jeff KingFeb 22, 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.