git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Matthieu Moy <Matthieu.Moy@imag.fr>
Cc: git@vger.kernel.org
Subject: Re: [FAQ?] Rationale for git's way to manage the index
Date: Mon, 7 May 2007 01:42:16 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0705070127180.4167@racer.site> (raw)
In-Reply-To: <vpqk5vlamav.fsf@bauges.imag.fr>

Hi Matthieu,

On Sun, 6 May 2007, Matthieu Moy wrote:

> 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.

> >> 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.

> > 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.

> > 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

  parent reply	other threads:[~2007-05-06 23:42 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-06 16:10 [FAQ?] Rationale for git's way to manage the index Matthieu Moy
2007-05-06 16:51 ` Johannes Schindelin
2007-05-06 17:34   ` Matthieu Moy
2007-05-06 17:43     ` Junio C Hamano
2007-05-09 12:52       ` Petr Baudis
2007-05-09 13:57         ` Johannes Schindelin
2007-05-09 14:24           ` [PATCH] git-commit: Reformat log messages provided on commandline Petr Baudis
2007-05-09 14:59             ` Matthieu Moy
2007-05-09 15:11               ` Petr Baudis
2007-05-09 15:32                 ` Matthieu Moy
2007-05-09 15:01             ` Johannes Schindelin
2007-05-10  0:45             ` Junio C Hamano
2007-05-12  0:25               ` Jakub Narebski
2007-05-06 18:22     ` [FAQ?] Rationale for git's way to manage the index Dana How
2007-05-06 23:42     ` Johannes Schindelin [this message]
2007-05-06 17:25 ` Linus Torvalds
2007-05-06 18:23   ` Matthieu Moy
2007-05-06 19:54     ` Linus Torvalds
2007-05-06 22:53     ` Julian Phillips
2007-05-07  6:35       ` Karl Hasselström
2007-05-08  1:41         ` Shawn O. Pearce
2007-05-08  7:15           ` Johannes Sixt
2007-05-08 10:28             ` Karl Hasselström
2007-05-08 12:40               ` J. Bruce Fields
2007-05-08 14:53                 ` Karl Hasselström
2007-05-09  3:45                   ` J. Bruce Fields
2007-05-09  9:40                     ` Johannes Schindelin
2007-05-08  7:37           ` Karl Hasselström
2007-05-08 14:52             ` Shawn O. Pearce
2007-05-06 23:51     ` Johannes Schindelin
2007-05-07  8:02       ` Matthieu Moy
2007-05-07 11:05         ` Johannes Schindelin
2007-05-09 13:07           ` Petr Baudis
2007-05-08  3:16     ` Martin Langhoff
2007-05-08  4:45       ` Linus Torvalds
2007-05-08  5:35         ` Martin Langhoff
2007-05-09 13:41         ` Petr Baudis
2007-05-09 15:52           ` Linus Torvalds
2007-05-09 16:29             ` Carl Worth
2007-05-11  1:28               ` Jakub Narebski
     [not found]                 ` <7vd518gkyo.fsf@assigned-by-dhcp.cox.net>
2007-05-11 11:26                   ` Jakub Narebski
2007-05-11 16:45                     ` Junio C Hamano
2007-05-11 23:06                       ` Jakub Narebski
2007-05-12  0:40                         ` Junio C Hamano
2007-05-12  1:06                           ` Jakub Narebski
2007-05-12  9:35                           ` Jakub Narebski
2007-05-09 16:33             ` Dana How
2007-05-09 17:18               ` J. Bruce Fields
2007-05-09 17:26                 ` Petr Baudis
2007-05-09 17:29                   ` J. Bruce Fields
2007-05-09 17:39             ` Daniel Barkalow
2007-05-09 18:16               ` Linus Torvalds
2007-05-10  0:31             ` Junio C Hamano
2007-05-10  2:27               ` Steven Grimm
2007-05-10  2:39                 ` Linus Torvalds
2007-05-10  8:00                   ` Matthieu Moy
2007-05-10 22:06               ` Shawn O. Pearce
2007-05-10 22:51                 ` Petr Baudis
2007-05-08 11:07       ` Johannes Schindelin
2007-05-15  1:00         ` David Kågedal
2007-05-15 23:27           ` Johannes Schindelin
2007-05-09 17:18     ` Matthieu Moy
2007-05-07 11:40 ` Guilhem Bonnefille
2007-05-07 12:16   ` Karl Hasselström
2007-05-07 12:36     ` David Kastrup
2007-05-07 12:55   ` Johannes Schindelin
2007-05-07 19:31     ` Junio C Hamano
2007-05-09 13:14     ` Petr Baudis
2007-05-07 22:23   ` Daniel Barkalow
2007-05-15  0:57   ` David Kågedal
2007-05-15  8:29     ` Karl Hasselström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0705070127180.4167@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=Matthieu.Moy@imag.fr \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).