Re: [Census] So who uses git?
- From
Junio C Hamano <junkio@cox.net>
- Date
- Feb 1, 2006, 20:27 UTC
- Message-ID
- <7vhd7ibza2.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <Pine.LNX.4.64.0602011125370.5397@localhost.localdomain>
Nicolas Pitre <nico@cam.org> writes:
Show 8 quoted lines
> On Tue, 31 Jan 2006, Junio C Hamano wrote: > >> People who do not like this can set in their config file some >> flag, say, 'core.index = understood', to get the current >> behaviour. > > I'd avoid hidden config options that magically change behaviors and > semantics like that as much as possible....
I agree; it was tongue-in-cheek sort of suggestion ;-)
> It is much more intuitive to expect that, if you specify path arguments > to commit, then only those paths are considered, and even if you didn't > do a git add on some of them. If nothing is specified then the current > index (the default, including a-new-file) is considered.
Good thinking. I was not thinking about the case where you explicitly list an untracked file to be added.
Show 15 quoted lines
> - a non-merge commit without any argument would imply -a. > > - a non-merge commit with path arguments implies _only_ those paths, > regardless if they were previously "git add"ed or not. > > - a non-merge commit with, say, --no-auto or --current-index or > whatever would preserve the current behavior, with or without > additional paths. > > - a merge commit ... > - a merge commit ... > > This might look complicated when presented like that, but I think that > the default behavior of each (non-merge vs merge) commit would more > closely fit most people's expectations....
If I may correct what I said earlier, I now realize the "automatic -a is dangerous" argument does not have anything to do with merges. If the user usually works with a dirty working tree, is aware of the index, and takes advantage of the index as the staging area for the next commit, your --no-auto would be needed to help her workflow. I in principle agree with the first three items in the above summary, except that I think it would make more sense to do that for all commits.
How about this:
- "git commit --also fileA..." means: update index at listed paths (add/remove if necessary) and then commit the tree described in index (the current behaviour with explicit paths).
- "git commit fileA..." means: create a temporary index from the current HEAD commit (or empty index if there is none), update it at listed paths (add/remove if necessary) and commit the resulting tree. Also update the real index at the listed paths (add/remove if necessary). In the original index file, the paths listed must be either empty or match exactly the HEAD commit -- otherwise we error out (Linus' suggestion).
- "git commit" means: update index with all local changes and then commit the tree described in index (current "-a" behaviour).
- In all cases, revert the index to the state before the command is run if we end up not making the commit (e.g. index unmerged, empty log message, pre-commit hook refusal).
Experienced git users would end up saying "--also" without explicit paths to defeat the automatic -a behaviour all the time, and while the flag --also makes perfect sense when used with one or more paths, using it like this look awkward:
$ edit some-file
$ git update-index some-file
$ git commit --alsoIt's just a flag name so we could make --no-auto synonym to --also.
A minor twist of the above to make it friendlier to the current git users is to do this:
- "git commit fileA...", "git commit -a", and "git commit" keep the existing semantics.
- "git commit --only fileA..." does the new temporary index thing.
This has an advantage that existing use is not affected, and another advantage is that internally it is more consistent ("git commit" is a natural extension of "git commit fileA..." with zero path). But one possible downside is that you need to explicitly say --only when you want cvs-like "commit".
Since we are discussing that the people find existing interface to be unintuitive, being consistent with the current usage may not count as a big advantage after all..