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

Re: [PATCH v4] fast-import: treat filemodify with empty tree as delete

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 28, 2011, 17:13 UTC
Message-ID
<20110128171359.GA26930@burratino>
In-Reply-To
<20110127204649.GB19378@m62s10.vlinux.de>
Peter Baumann wrote:
> On Thu, Jan 27, 2011 at 01:48:45PM -0600, Jonathan Nieder wrote:
>>> On Thu, Jan 27, 2011 at 12:07:49AM -0600, Jonathan Nieder wrote:
>>>> +	 empty_tree=$(git mktree </dev/null) &&
[...]
Show 5 quoted lines
>>                               unless we hardcode the object name
>> (which I prefer not to do).
>
> Wny not? It *is* already hardcoded in the GIT source code (see
> grep -a1 EMPTY cache.h output).

I think it is okay for the git implementation to rely on an implementation detail. ;-) Likewise, t0000 checks that the empty tree has id 4b825dc6. Meanwhile I would like to see people's scripts and other tests using the $(git mktree </dev/null) form, since it is more self-explanatory and avoids hardcoding an implementation detail.

Of course this is not an absolute thing.

Hope that helps, Jonathan

Further reading: t0000-basic.h --help:
	Note that this test *deliberately* hard-codes many expected object
	IDs.  When object ID computation changes, like in the previous case of
	swapping compression and hashing order, the person who is making the
	modification *should* take notice and update the test vectors here.
"Tips for Writing Tests" in t/README:
	However, other tests that simply rely on basic parts of the core
	GIT working properly should not have that level of intimate
	knowledge of the core GIT internals.  If all the test scripts
	hardcoded the object IDs like t0000-basic.sh does, that defeats
	the purpose of t0000-basic.sh, which is to isolate that level of
	validation in one place.  Your test also ends up needing
	updating when such a change to the internal happens, so do _not_
	do it and leave the low level of validation to t0000-basic.sh.
Previous: Peter BaumannNext: Jonathan Nieder
Message 21 of 24 in “fast-import: add 'ls' command”
  1. fast-import: add 'ls' commandDavid Barr, Dec 2, 2010
  2. fast-import: add 'ls' commandDavid Barr, Dec 2, 2010
  3. Sverre RabbelierDec 2, 2010
  4. David Michael BarrDec 2, 2010
  5. Jonathan NiederDec 2, 2010
  6. Junio C HamanoDec 2, 2010
  7. David BarrDec 2, 2010
  8. 0/3 fast-import: add 'ls' commandJonathan Nieder, Jan 3, 2011
  9. 1/3 fast-import: clarify handling of cat-blob featureJonathan Nieder, Jan 3, 2011
  10. 2/3 fast-import: treat filemodify with empty tree as deleteJonathan Nieder, Jan 3, 2011
  11. fast-import: treat filemodify with empty tree as deleteJonathan Nieder, Jan 26, 2011
  12. Sverre RabbelierJan 26, 2011
  13. fast-import: treat filemodify with empty tree as deleteJonathan Nieder, Jan 26, 2011
  14. Junio C HamanoJan 27, 2011
  15. Jonathan NiederJan 27, 2011
  16. fast-import: treat filemodify with empty tree as deleteJonathan Nieder, Jan 27, 2011
  17. Peter BaumannJan 27, 2011
  18. Jonathan NiederJan 27, 2011
  19. Peter BaumannJan 27, 2011
  20. Peter BaumannJan 27, 2011
  21. Jonathan NiederJan 28, 2011
  22. 3/3 fast-import: add 'ls' commandJonathan Nieder, Jan 3, 2011
  23. [RFC] fast-import: 'cat-blob' and 'ls' commandsJonathan Nieder, Jan 26, 2011
  24. Sam VilainJan 26, 2011

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.