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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

> [topic: making â??git commitâ?? more helpful when there are no changes
> registered in the index]
>
> Hi Goswin,
>
> Goswin von Brederlow wrote:
>
>> in most (all but git?) RCS a plain 'commit' without any arguments
>> commits all changes (to registered files).
>
> Yes, but they are wrong. :)
>
>> no changes added to commit (use "git add" and/or "git commit -a")
> [...]
>> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]