[feature request] Warn about or prevent --amend commits that don't change anything
- From
- Bergi <a.d.bergi@web.de>
- Date
- Jul 13, 2016, 18:56 UTC
- Message-ID
- <d2c3365d-6da9-dd58-ae7d-4a2020c6b513@web.de>
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