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

Re: Importing from tarballs; add, rm, update-index?

From
Junio C Hamano <junkio@cox.net>
Date
Jan 13, 2007, 18:01 UTC
Message-ID
<7v1wlylsa8.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070113093322.GA4825@xp.machine.xx>
Peter Baumann <waste.manager@gmx.de> writes:
Show 5 quoted lines
> Yes. I am adding content. And not a file. But at least to me, it makes a
> *BIG* difference if I'm adding totally new content (reserving one more
> bucket where to place to content) or just replacing the content *in* one
> of those already reserved buckets. And that has nothing to do with
> files (or at least the silly me can't grok it).

To put this silly naming argument to the rest for now, because I am not going to change add/rm nor introduce refresh, at least during this round, so keeping this thread alive would just waste everybody's time doing mental masturbation.

Physically the index is represented as a list of <blob object name, pathname> tuples. When we say "git tracks contents", however, we look at it as if content of each blob object is just a bytestream labeled with the pathname.

When you say "git-update-index file" (without --add/--remove), what happens is "UPDATE" (in SQL sense). The part of the data recorded in the current index that is labeled with "file" is replaced with what is from the working tree.

The --add option changes the "UPDATE" to "INSERT OR REPLACE". It allows contents that are labelled with a pathname that does not yet exist in the index. What --remove does is to allow it to also "DELETE".

So there _is_ a distinction between adding new pathname and updating the contents at the low level.

However, if you look at the way 'git-update-index' is used in the Porcelain-ish scripts (now you would need to go back and examine a bit older versions of git, since many commands have been rewritten in C to become built-in and we use update-index in much fewer places in today's version), we almost always used update-index with --add when talking about the set of paths the end user talks about ('am' and 'applypatch' uses --index-info; this is also "INSERT OR REPLACE" operation primarily). The places we did not, we knew we were only dealing with known set of paths taken from the current index, so they also could have had --add without any ill effects.

In other words, there was not much need for "UPDATE only, please do not INSERT" in practice.

That's primarily why the higher level interface git-add / git-mv does not expose that distinction; git-add will do "INSERT OR REPLACE". git-rm will do "DELETE", and there will be no higher level to only do "UPDATE".

Previous: Julian PhillipsNext: Carl Worth
Message 12 of 38 in “Importing from tarballs; add, rm, update-index?”
  1. Chris RiddochJan 12, 2007
  2. Morten WelinderJan 12, 2007
  3. Junio C HamanoJan 12, 2007
  4. Peter BaumannJan 12, 2007
  5. Junio C HamanoJan 12, 2007
  6. Peter BaumannJan 12, 2007
  7. Junio C HamanoJan 13, 2007
  8. Peter BaumannJan 13, 2007
  9. Johannes SchindelinJan 13, 2007
  10. Peter BaumannJan 13, 2007
  11. Julian PhillipsJan 13, 2007
  12. Junio C HamanoJan 13, 2007
  13. Carl WorthJan 13, 2007
  14. Brian GernhardtJan 13, 2007
  15. Peter BaumannJan 13, 2007
  16. Nicolas PitreJan 13, 2007
  17. Carl WorthJan 13, 2007
  18. Junio C HamanoJan 13, 2007
  19. Nicolas PitreJan 13, 2007
  20. Brian GernhardtJan 13, 2007
  21. Peter BaumannJan 13, 2007
  22. Brian GernhardtJan 13, 2007
  23. Alan ChandlerJan 13, 2007
  24. Brian GernhardtJan 13, 2007
  25. Shawn O. PearceJan 13, 2007
  26. Johannes SchindelinJan 14, 2007
  27. Shawn O. PearceJan 14, 2007
  28. Junio C HamanoJan 15, 2007
  29. Shawn O. PearceJan 15, 2007
  30. Daniel BarkalowJan 15, 2007
  31. Horst H. von BrandJan 16, 2007
  32. Daniel BarkalowJan 16, 2007
  33. Christian MICHONJan 16, 2007
  34. Jakub NarebskiJan 16, 2007
  35. Carl WorthJan 12, 2007
  36. Johannes SchindelinJan 12, 2007
  37. Junio C HamanoJan 13, 2007
  38. Jakub NarebskiJan 12, 2007

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.