git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bergi <a.d.bergi@web.de>
To: git@vger.kernel.org
Subject: [feature request] Warn about or prevent --amend commits that don't change anything
Date: Wed, 13 Jul 2016 20:56:22 +0200	[thread overview]
Message-ID: <d2c3365d-6da9-dd58-ae7d-4a2020c6b513@web.de> (raw)

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

             reply	other threads:[~2016-07-13 18:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13 18:56 Bergi [this message]
2016-07-13 19:16 ` [feature request] Warn about or prevent --amend commits that don't change anything Junio C Hamano
2016-07-13 21:02   ` Bergi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2c3365d-6da9-dd58-ae7d-4a2020c6b513@web.de \
    --to=a.d.bergi@web.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).