git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [feature request] Warn about or prevent --amend commits that don't change anything
@ 2016-07-13 18:56 Bergi
  2016-07-13 19:16 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Bergi @ 2016-07-13 18:56 UTC (permalink / raw)
  To: git

Hello,

when nothing is staged in the index then `git commit` warns about this 
fact with either "nothing to commit, working directory clean" or "no 
changes added to commit".
However, `git commit --amend --no-edit` will happily record a new commit 
that differs in nothing than its commit date from the original.

This is unexpected and can lead to mistakes. Without running `git 
status`, the user will not notice that his unstaged changes were not 
commited, as everything behaves as expected otherwise (the success 
output from `commit`, the new commit id in the log, `push` requiring the 
force option, etc).

I understand that `--amend` is (can be) used for editing commit 
messages, authors, authoring dates etc.
I would however like to see any `--amend` command that results in no 
changes to the tree, the commit message and the authoring metadata 
reject the commit with an appropriate warning similar to the one that a 
plain `git commit` would present. It should be overrideable by the 
`--allow-emtpy` parameter as well.

If this change detection is somehow unfeasible, I would at least like 
the `git commit --amend --no-edit` command (with no other flags) to 
check the tree in the same way as `git commit` does, as the intention of 
`--no-edit` is even more clear and running the command is more obviously 
a mistake/lapse.

Kind regards,
  Bergi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-13 21:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-13 18:56 [feature request] Warn about or prevent --amend commits that don't change anything Bergi
2016-07-13 19:16 ` Junio C Hamano
2016-07-13 21:02   ` Bergi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).