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

Re: [PATCH 3/3] git-add --intent-to-add (-N)

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Aug 22, 2008, 04:34 UTC
Message-ID
<alpine.LNX.1.00.0808220023170.19665@iabervon.org>
In-Reply-To
<Pine.GSO.4.62.0808212304200.9108@harper.uchicago.edu>
On Thu, 21 Aug 2008, Jonathan Nieder wrote:
Show 34 quoted lines
> Hi,
> 
> Jonathan Nieder wrote:
> 
> > I quite like the idea of this patch series.  When I try to test it with
> > "git merge jc/ita; make test", t0020-crlf setup fails
> [...]
> > This could be me doing something [stupid]
> 
> and it was.  In a sleepy daze, I resolved a conflict
> 
> <<<<<<<
> #define ADD_CACHE_IGNORE_REMOVAL 8
> =======
> #define ADD_CACHE_INTENT 8
> >>>>>>>
> 
> by using the same bit for both.  Sorry for the noise.
> 
> Others can experience that unpleasant error message for themselves
> with next + jc/add-ita merged properly:
> 
> 	$ mkdir test-repo && cd test-repo
> 	$ git init
> 	Initialized empty Git repository in /var/tmp/jrnieder/test-repo/.git/
> 	$ : >a
> 	$ git add -N a
> 	$ git commit
> 	error: invalid object e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
> 	error: Error building trees
> 
> I think the first error comes from update_one, which creates a tree
> object from the index.  It is complaining, because after all, that
> object is not in any sha1 file.

I think [1/3] was supposed to make this not an issue, with that particular object being implicitly in all objects databases.

Show 20 quoted lines
> If the empty blob happened to be in our object database, the user's
> mistake would be hidden:
> 
> 	$ git add a && git commit
> 	error: invalid object e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
> 	error: Error building trees
> 	$ git rm -f --cached a
> 	rm 'a'
> 	$ git add a
> 	$ git commit -m initial
> 	$ echo hi >b
> 	$ git add -N b
> 	$ git commit && echo ok
> 	Created commit 91325db: some commit message
> 	 0 files changed, 0 insertions(+), 0 deletions(-)
> 	 create mode 100644 b
> 	ok
> 
> Maybe it would be better to use some other magic blob (or a bit
> somewhere) to remember that the file has not been added yet.

An actual magic value (maybe the all-zeros hash) would make it an actual error for the file to not have been added; the current code behaves as if you did:

$ touch b $ git add b

right before putting anything in b. Aside, perhaps, from retrieval bugs, it's just like you actually added an empty blob.

Last time I tried something along these lines, using the all-zeros hash actually came pretty close to working, except that diff uses this value for "look at the working tree" in its representation, and stuff gets confused by it; these are actually distinguishable, IIRC, by whether the mode bits are set or not, but current code doesn't check that.

	-Daniel
*This .sig left intentionally blank*
Previous: Jonathan NiederNext: Junio C Hamano
Message 40 of 67 in “Call Me Gitless”
  1. TransAug 18, 2008
  2. Benjamin SergeantAug 18, 2008
  3. Martin LanghoffAug 18, 2008
  4. Pascal ObryAug 18, 2008
  5. Jon LoeligerAug 18, 2008
  6. Daniel BarkalowAug 18, 2008
  7. Marcus GriepAug 18, 2008
  8. Junio C HamanoAug 18, 2008
  9. Daniel BarkalowAug 18, 2008
  10. Junio C HamanoAug 18, 2008
  11. Daniel BarkalowAug 18, 2008
  12. Junio C HamanoAug 19, 2008
  13. Marcus GriepAug 19, 2008
  14. Junio C HamanoAug 19, 2008
  15. Junio C HamanoAug 19, 2008
  16. diff: vary default prefix depending on what are comparedJunio C Hamano, Aug 20, 2008
  17. Jakub NarebskiAug 20, 2008
  18. Stephen R. van den BergAug 19, 2008
  19. Jakub NarebskiAug 19, 2008
  20. Junio C HamanoAug 19, 2008
  21. Jeff KingAug 19, 2008
  22. Daniel BarkalowAug 19, 2008
  23. Jeff KingAug 19, 2008
  24. Daniel BarkalowAug 19, 2008
  25. Jeff KingAug 19, 2008
  26. Daniel BarkalowAug 19, 2008
  27. Petr BaudisAug 19, 2008
  28. Daniel BarkalowAug 19, 2008
  29. Junio C HamanoAug 19, 2008
  30. Junio C HamanoAug 19, 2008
  31. Daniel BarkalowAug 19, 2008
  32. Sverre Hvammen JohansenAug 21, 2008
  33. Junio C HamanoAug 21, 2008
  34. 1/3 sha1_object_info(): pay attention to cached objectsJunio C Hamano, Aug 21, 2008
  35. 2/3 cached_object: learn empty blobJunio C Hamano, Aug 21, 2008
  36. 3/3 git-add --intent-to-add (-N)Junio C Hamano, Aug 21, 2008
  37. Paolo BonziniAug 21, 2008
  38. Jonathan NiederAug 21, 2008
  39. Jonathan NiederAug 22, 2008
  40. Daniel BarkalowAug 22, 2008
  41. Junio C HamanoAug 22, 2008
  42. Jonathan NiederAug 22, 2008
  43. Junio C HamanoAug 22, 2008
  44. Jonathan NiederAug 22, 2008
  45. Jonathan NiederAug 22, 2008
  46. Daniel BarkalowAug 21, 2008
  47. TarmiganAug 18, 2008
  48. Daniel BarkalowAug 19, 2008
  49. TarmiganAug 19, 2008
  50. Peter Valdemar Mørch (Lists)Aug 19, 2008
  51. Junio C HamanoAug 19, 2008
  52. Imran M YousufAug 19, 2008
  53. Peter Valdemar Mørch (Lists)Aug 19, 2008
  54. Imran M YousufAug 19, 2008
  55. Alexander E GenaudAug 19, 2008
  56. Matthieu MoyAug 19, 2008
  57. Mike HommeyAug 19, 2008
  58. Alexander E GenaudAug 19, 2008
  59. Pascal ObryAug 19, 2008
  60. Paolo BonziniAug 21, 2008
  61. Elijah NewrenAug 22, 2008
  62. Peter Valdemar Mørch (Lists)Aug 19, 2008
  63. Mark StrubergAug 19, 2008
  64. Alexander E GenaudAug 19, 2008
  65. Junio C HamanoAug 19, 2008
  66. Teemu LikonenAug 19, 2008
  67. Jakub NarebskiAug 19, 2008

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.