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

Re: [FAQ?] Rationale for git's way to manage the index

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
May 6, 2007, 23:42 UTC
Message-ID
<Pine.LNX.4.64.0705070127180.4167@racer.site>
In-Reply-To
<vpqk5vlamav.fsf@bauges.imag.fr>
Hi Matthieu,
On Sun, 6 May 2007, Matthieu Moy wrote:
Show 20 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > On Sun, 6 May 2007, Matthieu Moy wrote:
> >
> >> [...]
> >>
> >> % git satus -a
> >> % git commit -a -m "..."
> >> 
> >> In the former case, I have more commands to type, and in the second
> >> case, I loose part of the stat-cache benefit: If I run "git status -a"
> >> twice, the second run will actually diff all the files touched since
> >> the last run, since "git status -a" actually updated a temporary
> >> index, and discarded it afterwards, so it doesn't update the stat
> >> information in the index (while "git status" would have).
> >
> > Have you tried "git status" _without_ "-a"?
> 
> Reading my message (including the last 5 words of the sentence you're 
> quoting) would have told you that ;-).
Okay, I rephrase the (badly worded) question:
Why did you use "-a" with "git status" to begin with? It's useless.
Show 7 quoted lines
> >> In both cases, I can't really see the benefit.
> >
> > The benefit is a clear distinguishing between DWIM and low level. The 
> > index contains _exactly_ what you told it to contain.
> 
> In other systems, commit commits _exactly_ the content of files on
> disk. And most people seem happy with that.

Because they do not realize that the file _names_ are actually only a key, not the value.

With Git, it is possible to stage changes, but also to have a dirty stage.

Think, for example, about debugging a program. Many programs have Makefiles, which define CFLAGS without "-g". Now you want to debug. Since gdb acquired the bad habit of not working properly at all without that flag (which is especially apparent when single stepping jumps around wildly in the source code), you _have_ to change the Makefile to include "-g" with the CFLAGS.

But you don't want to commit _that_. It is no useful change for the project. Submitting such a patch makes you look foolish. So, you leave it out of the commit.

And to make you _aware_ that it is a real possibility, and often a desirable one, git-commit makes you specify "-a" when you are _sure_ that you want to commit _all_ of your changes to the tracked files.

With CVS (which has been bashed on a lot on this list, and rightfully so), after a mistaken "cvs commit" _with_ irrelevant changes, like the change to the Makefile I illustrated above), you have two options:

	- leave it as it is (possibly undoing the change in a subsequent 
	  commit), or
	- edit the files, which often leads to an inconsistent repository. 
	  Yeah, sure, you can checkout the newest state, but you cannot 
	  reproduce known older states.
> > By forcing users to use "-a" with "git commit",
> 
> Does this mean that the normal way to use "commit" is to use "-a"?

Well, I use it quite a lot. But 30% of the time, I prefer to commit with specific filenames, so I can be sure _what_ I commit. FWIW, I picked up on that practice when using CVS...

There are even about 20% of the time, when I use "git commit" _without_ any parameters, because I used "git add" to tell Git that I resolved some conflicts, or that I want this file to be committed, while other files should not be committed.

Show 5 quoted lines
> > you make it clear that a separate update steo is involved,
> 
> Well, with those kind of arguments, I could have my web browser not do
> DNS resolution for me, because it would make it clear that a separate
> step from HTTP request is involved.
No. _You_ never need to tell the browser _not_ to resolve via DNS.

But _you_ sometimes _need_ to commit with _different_ parameters than "-a". You might not realize that _now_. But at least specifying "-a" everytime you do your thing gives you a _chance_ to realize it.

Show 9 quoted lines
> > and if you made an error (which you see from the file list), you can
> > abort, and start over with the original index.
> 
> You don't necessarily see your error from the file list:
> 
> % vi foo.c
> % git add foo.c
> % vi foo.c
> % git commit -m foo

As others have commented, "-m" is a _bad_ option. Yes, for ease of use, it is provided.

But how useful is a commit message which consists of less than five words?
It does _not_ tell you,
	- what the _conceptual_ change was,
	- _why_ it was done,
	- _how_ it was done, and
	- what the rationale of the committer was, for the case that 
	  people try to come up with a cleverer patch, to prevent 
	  unnecessary rethinking.

Ciao, Dscho

Previous: Dana HowNext: Linus Torvalds
Message 15 of 71 in “[FAQ?] Rationale for git's way to manage the index”
  1. Matthieu MoyMay 6, 2007
  2. Johannes SchindelinMay 6, 2007
  3. Matthieu MoyMay 6, 2007
  4. Junio C HamanoMay 6, 2007
  5. Petr BaudisMay 9, 2007
  6. Johannes SchindelinMay 9, 2007
  7. git-commit: Reformat log messages provided on commandlinePetr Baudis, May 9, 2007
  8. Matthieu MoyMay 9, 2007
  9. Petr BaudisMay 9, 2007
  10. Matthieu MoyMay 9, 2007
  11. Johannes SchindelinMay 9, 2007
  12. Junio C HamanoMay 10, 2007
  13. Jakub NarebskiMay 12, 2007
  14. Dana HowMay 6, 2007
  15. Johannes SchindelinMay 6, 2007
  16. Linus TorvaldsMay 6, 2007
  17. Matthieu MoyMay 6, 2007
  18. Linus TorvaldsMay 6, 2007
  19. Julian PhillipsMay 6, 2007
  20. Karl HasselströmMay 7, 2007
  21. Shawn O. PearceMay 8, 2007
  22. Johannes SixtMay 8, 2007
  23. Karl HasselströmMay 8, 2007
  24. J. Bruce FieldsMay 8, 2007
  25. Karl HasselströmMay 8, 2007
  26. J. Bruce FieldsMay 9, 2007
  27. Johannes SchindelinMay 9, 2007
  28. Karl HasselströmMay 8, 2007
  29. Shawn O. PearceMay 8, 2007
  30. Johannes SchindelinMay 6, 2007
  31. Matthieu MoyMay 7, 2007
  32. Johannes SchindelinMay 7, 2007
  33. Petr BaudisMay 9, 2007
  34. Martin LanghoffMay 8, 2007
  35. Linus TorvaldsMay 8, 2007
  36. Martin LanghoffMay 8, 2007
  37. Petr BaudisMay 9, 2007
  38. Linus TorvaldsMay 9, 2007
  39. Carl WorthMay 9, 2007
  40. Jakub NarebskiMay 11, 2007
  41. Dana HowMay 9, 2007
  42. J. Bruce FieldsMay 9, 2007
  43. Petr BaudisMay 9, 2007
  44. J. Bruce FieldsMay 9, 2007
  45. Daniel BarkalowMay 9, 2007
  46. Linus TorvaldsMay 9, 2007
  47. Junio C HamanoMay 10, 2007
  48. Steven GrimmMay 10, 2007
  49. Linus TorvaldsMay 10, 2007
  50. Matthieu MoyMay 10, 2007
  51. Shawn O. PearceMay 10, 2007
  52. Petr BaudisMay 10, 2007
  53. Johannes SchindelinMay 8, 2007
  54. David KågedalMay 15, 2007
  55. Johannes SchindelinMay 15, 2007
  56. Matthieu MoyMay 9, 2007
  57. Guilhem BonnefilleMay 7, 2007
  58. Karl HasselströmMay 7, 2007
  59. David KastrupMay 7, 2007
  60. Johannes SchindelinMay 7, 2007
  61. Junio C HamanoMay 7, 2007
  62. Petr BaudisMay 9, 2007
  63. Daniel BarkalowMay 7, 2007
  64. David KågedalMay 15, 2007
  65. Karl HasselströmMay 15, 2007
  66. Jakub NarebskiMay 11, 2007
  67. Junio C HamanoMay 11, 2007
  68. Jakub NarebskiMay 11, 2007
  69. Junio C HamanoMay 12, 2007
  70. Jakub NarebskiMay 12, 2007
  71. Jakub NarebskiMay 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.