From: Miles Bader <hidden> Date: 2016-06-15 22:48:42
Jakub Narebski [off-list ref] writes:
I'd like for 'git commit -a' to *fail* if there are staged changes for
tracked files, excluding added, removed and renamed files. If you
have some staged changes you would get an error message:
$ git add tracked-file
$ git commit -a
fatal: There are staged changes to tracked files
hint: To commit staged changes, use 'git commit'
hint: To commit all changes, use 'git commit -f -a'
That's bad because of the dual nature of "git add" -- someone may
normally use "-a" most of the time to commit changes, but has really no
choice other than git add to add a new file, So with this change, their
normal (and reasonable) habits would suddenly result in failure.
I think it's sort of annoying that "git add" has such a dual meaning
(instead of, for instance, having separate "add" and "stage" commands)
-- it's one of the more confusing things about learning about git
-- but oh well, it's unlikely to get changed at this point....
-Miles
--
Defenceless, adj. Unable to attack.
From: Jakub Narebski <hidden> Date: 2016-06-15 22:48:42
On Sat, 24 April 2010, Miles Bader wrote:
Jakub Narebski [off-list ref] writes:
quoted
I'd like for 'git commit -a' to *fail* if there are staged changes for
tracked files, excluding added, removed and renamed files. If you
have some staged changes you would get an error message:
$ git add tracked-file
$ git commit -a
fatal: There are staged changes to tracked files
hint: To commit staged changes, use 'git commit'
hint: To commit all changes, use 'git commit -f -a'
That's bad because of the dual nature of "git add" -- someone may
normally use "-a" most of the time to commit changes, but has really no
choice other than git add to add a new file, So with this change, their
normal (and reasonable) habits would suddenly result in failure.
I think it's sort of annoying that "git add" has such a dual meaning
(instead of, for instance, having separate "add" and "stage" commands)
-- it's one of the more confusing things about learning about git
-- but oh well, it's unlikely to get changed at this point....
First, this is to be optional safety, by default turned off. So if you
do not have problems with situation where you accidentally use
'git commit -a' instead of 'git commit', committing not what you wanted
and prepared, you simply do not turn it on.
Second, to be more exact the safety would be triggered only if staged
change _differs_ from what is in working area. Therefore
$ git add file
$ git commit -a
would not trigger this safety, while
$ git add file
$ edit file
$ git commit -a
fatal: There are staged changes
would trigger it.
Third, there is "git add -N" to mark file as tracked, but not add its
current context.
$ git add -N file
$ edit file
$ git commit -a
should not trigger this safety.
--
Jakub Narebski
Poland
From: Miles Bader <hidden> Date: 2016-06-15 22:48:42
On Sat, Apr 24, 2010 at 7:26 PM, Jakub Narebski [off-list ref] wrote:
Third, there is "git add -N" to mark file as tracked, but not add its
current context.
$ git add -N file
$ edit file
$ git commit -a
Meh. It's going to still require people to change their habits, and
while requiring people to use -N whenever they think they may want to
use "commit -a" later would work, it feels awkward and artificial.
All in all, it just doesn't smell clean, and I suspect that would
prevent many people from enabling such a feature.
-Miles
--
Do not taunt Happy Fun Ball.
From: Nicolas Pitre <nico@fluxnic.net> Date: 2016-06-15 22:48:42
On Sat, 24 Apr 2010, Jakub Narebski wrote:
First, this is to be optional safety, by default turned off. So if you
do not have problems with situation where you accidentally use
'git commit -a' instead of 'git commit', committing not what you wanted
and prepared, you simply do not turn it on.
In which case it is worthless. No one will turn this feature on if they
don't fully understand what it entails, and those who do understand it
are probably not the people who would actually benefit from it.
Second, to be more exact the safety would be triggered only if staged
change _differs_ from what is in working area. Therefore
$ git add file
$ git commit -a
would not trigger this safety, while
$ git add file
$ edit file
$ git commit -a
fatal: There are staged changes
would trigger it.
Much better yet would be a warning at the top of the summary message in
the commit text editor. This way you won't introduce an incompatible
and potentially annoying behavior that no one is likely to opt-in for,
and the warning will give a hint that you might be losing some
intermediate state if you don't abort the commit.
Nicolas
From: Jakub Narebski <hidden> Date: 2016-06-15 22:48:42
On Sat, 24 Apr 2010, Nicolas Pitre wrote:
On Sat, 24 Apr 2010, Jakub Narebski wrote:
quoted
First, this is to be optional safety, by default turned off. So if you
do not have problems with situation where you accidentally use
'git commit -a' instead of 'git commit', committing not what you wanted
and prepared, you simply do not turn it on.
In which case it is worthless. No one will turn this feature on if they
don't fully understand what it entails, and those who do understand it
are probably not the people who would actually benefit from it.
One would turn it after losing carefully prepared index by running
"git commit -a" when one meant "git commit" ;-)
More seriously, it could be made default if it is not too annoying.
quoted
Second, to be more exact the safety would be triggered only if staged
change _differs_ from what is in working area. Therefore
$ git add file
$ git commit -a
would not trigger this safety, while
$ git add file
$ edit file
$ git commit -a
fatal: There are staged changes
would trigger it.
Much better yet would be a warning at the top of the summary message in
the commit text editor. This way you won't introduce an incompatible
and potentially annoying behavior that no one is likely to opt-in for,
and the warning will give a hint that you might be losing some
intermediate state if you don't abort the commit.
As Petr Baudis said, this actually work *if* you use editor to generate
commit message, and you have chance to see commit message template.
Also the information was considered not visible enought, hence patch
at the beginning of the series.
--
Jakub Narebski
Poland