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

[RFC] git-add update with all-0 object

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Nov 30, 2006, 22:08 UTC
Message-ID
<Pine.LNX.4.64.0611301634080.20138@iabervon.org>

One thing that I think is non-intuitive to a lot of users (either novice or who just don't do it much) is that it matters where in the process you do "git add <path>" if you're also changing the file. Even if you understand the index, you may not realize (or may not have internalized the fact) that what git-add does is update the index with what's there now.

I think the more obvious behavior is to have it record the fact that you want to have the path tracked, but require one of the usual updating mechanisms to get a particular content into the index.

This should be pretty simple to implement: use --cacheinfo 0 0 $path instead of --add -- $path, and teach programs that look at the objects recorded in the index (rather than just hashes or other info) about all-0 hashes meaning "but no content there". write-tree would probably just skip the entry (and then you could add a file, but still produce commits without it until you actually do either an update-index explicitly or one of the commit option sets that updates it); diff would treat it as empty; checkout would ignore it.

	-Daniel
Next: Johannes Schindelin
Message 1 of 15 in “[RFC] git-add update with all-0 object”
  1. Daniel BarkalowNov 30, 2006
  2. Johannes SchindelinNov 30, 2006
  3. Nicolas PitreNov 30, 2006
  4. Jakub NarebskiNov 30, 2006
  5. Nicolas PitreNov 30, 2006
  6. Linus TorvaldsNov 30, 2006
  7. Daniel BarkalowDec 1, 2006
  8. Theodore TsoDec 1, 2006
  9. Junio C HamanoDec 1, 2006
  10. Jakub NarebskiDec 2, 2006
  11. Linus TorvaldsDec 1, 2006
  12. Daniel BarkalowDec 1, 2006
  13. Andy ParkinsDec 1, 2006
  14. Jakub NarebskiDec 2, 2006
  15. Jakub NarebskiDec 2, 2006

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.