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

Re: [PATCH 2/3] hash-object doc: elaborate on -w and --literally promises

From
Jeff King <peff@peff.net>
Date
May 22, 2019, 05:08 UTC
Message-ID
<20190522050839.GB29933@sigill.intra.peff.net>
In-Reply-To
<20190520215312.10363-3-avarab@gmail.com>
On Mon, May 20, 2019 at 11:53:11PM +0200, Ævar Arnfjörð Bjarmason wrote:
> Clarify the hash-object docs to explicitly note that the --literally
> option guarantees that a loose object will be written, but that a
> normal -w ("write") invocation doesn't.

I had to double-check here: you mean that _when_ we are writing an object, "--literally" would always write loose, right?

> At first I thought talking about "loose object" in the docs was a
> mistake in 83115ac4a8 ("git-hash-object.txt: document --literally
> option", 2015-05-04), but as is clear from 5ba9a93b39 ("hash-object:
> add --literally option", 2014-09-11) this was intended all along.

Hmm. After reading both of those, I do think it's mostly an implementation detail. I would not be at all surprised to find that the test suite relies on this (e.g., cleaning up with rm .git/objects/ab/cd1234). But I suspect we also rely on that for the non-literal case, too. ;)

So I am on the fence. In some sense it doesn't hurt to document the behavior, but I'm not sure I would want to lock us in to any particular behavior, even for --literally. The intent of the option (as I recall) really is just "let us write whatever trash we want as an object, ignoring all quality checks".

Show 8 quoted lines
>  --literally::
> -	Allow `--stdin` to hash any garbage into a loose object which might not
> +	Allow for hashing arbitrary data which might not
>  	otherwise pass standard object parsing or git-fsck checks. Useful for
>  	stress-testing Git itself or reproducing characteristics of corrupt or
> -	bogus objects encountered in the wild.
> +	bogus objects encountered in the wild. When writing objects guarantees
> +	that the written object will be a loose object, for ease of debugging.

I had to read this last sentence a few times to parse it. Maybe a comma before guarantees would help? Or even:

  When writing objects, this option guarantees that the written object
  will be a loose object, for ease of debugging.
-Peff
Previous: Ævar Arnfjörð BjarmasonNext: Jakub Narebski
Message 5 of 12 in “hash-object doc: small fixes”
  1. 0/3 hash-object doc: small fixesÆvar Arnfjörð Bjarmason, May 20, 2019
  2. 1/3 hash-object doc: stop mentioning git-cvsimportÆvar Arnfjörð Bjarmason, May 20, 2019
  3. Jeff KingMay 22, 2019
  4. 2/3 hash-object doc: elaborate on -w and --literally promisesÆvar Arnfjörð Bjarmason, May 20, 2019
  5. Jeff KingMay 22, 2019
  6. Jakub NarebskiMay 24, 2019
  7. Ævar Arnfjörð BjarmasonMay 24, 2019
  8. Jeff KingMay 28, 2019
  9. Junio C HamanoMay 28, 2019
  10. Junio C HamanoMay 28, 2019
  11. 3/3 hash-object doc: point to ls-files and rev-parseÆvar Arnfjörð Bjarmason, May 20, 2019
  12. Jeff KingMay 22, 2019

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.