Thread (3 messages) flat view 3 messages, 3 authors, 2016-06-15

Re: Please default to 'commit -a' when no changes were added

From: Goswin von Brederlow <hidden>
Date: 2016-06-15 22:48:41

Jonathan Nieder [off-list ref] writes:
[topic: making ‘git commit’ more helpful when there are no changes
registered in the index]

Hi Goswin,

Goswin von Brederlow wrote:
quoted
in most (all but git?) RCS a plain 'commit' without any arguments
commits all changes (to registered files).
Yes, but they are wrong. :)
quoted
no changes added to commit (use "git add" and/or "git commit -a")
[...]
quoted
Imho in most cases where no changes
were added people do want to commit all modified files. And if not
then exiting the editor to abort is easy enough.
I absent-mindedly type ‘git commit’ having forgotten to update the
index with my changes fairly often.  Then I add the appropriate
changes, which is almost never all of them.  I don’t think this is so
unusual.
Then you would type C-X C-c or :q or whatever exits your editor. No harm
done. Also, as you say below, git can output quite a long list of things
in the message. With my proposed change you would get the list inside
your editor and could scroll through it and check if it can all go as a
single commit or not. Imho doing nothing as it does now is the least
usefull thing to do.
Starting out, I can see how it would be comforting to people if
‘git commit’ would default to -a behavior if they ignore the index.
That is logically a different operation, though, so it would also send
a wrong message and make it harder in the long run to get used to the
interface.

Instead, I think it would be better to focus on making the error
message more helpful.  Right now there is a screen full of status
before the advice, which might make it easy to get scared before
reading it.

Here’s a very rough patch to suppress that screenful.  What do you
think?
I have never ever needed anything but

git commit -a
git commit <file> <file> ...

I do commit often and commit early and I start and finish one thing
before I start another. Also I keep my files small so they do one thing
and do it well. Overall that means I don't end up with multiple changes
in a single file so I never need to cherry pick changes for a commit.

So I don't think people should be forced to utilize the index. Imho that
is a matter of the workflow people use. Some people work better with the
index and some people (or projects) don't need it.



Alternatively an option to take all changes but only if the index is
empty would be helpfull. Then people could define an alias for that or
set the option in the config. Other than setting -a that would allow
using an index when needed and commit everything in the normal case
without having to change the command used to commit.

MfG
        Goswin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help