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

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

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

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

From: Nicolas Pitre <nico@fluxnic.net>
Date: 2016-06-15 22:48:41

On Thu, 22 Apr 2010, Goswin von Brederlow wrote:
I have never ever needed anything but

git commit -a
git commit <file> <file> ...
When I was using CVS/SVN that's what I thought too.
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.
Good for you.  I'm not that disciplined. Hence I often end up working on 
more than one thing in parallel.  The index is just so incredibly useful 
in that case.  I'm also a big fan of 'git add -e'.
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.
Exact.  It is therefore not progress to impose some inconvenience to one 
work flow in order to make another one easier.  And in this case we're 
talking about the difference between having to type an additional -a vs 
the risk of creating a commit with unexpected content.
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.
But you're proposing to change the semantics for that command.  And I 
also suspect that you're trying to make the index more hidden while what 
we're actually trying to do is to promote it.

What _you_ can do though, is this:

	git config --global alias.ci "commit -a"


Nicolas

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

From: Sverre Rabbelier <hidden>
Date: 2016-06-15 22:48:41

Heya,

On Thu, Apr 22, 2010 at 21:03, Nicolas Pitre [off-list ref] wrote:
Good for you.  I'm not that disciplined. Hence I often end up working on
more than one thing in parallel.  The index is just so incredibly useful
in that case.  I'm also a big fan of 'git add -e'.
Speaking of which... how about having just 'git commit' drop you in
interactive commit mode?

-- 
Cheers,

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