Thread (1 message) 1 message, 1 author, 2016-06-15

Re: git-commit --amend -m "..." complains?!?

From: David Kastrup <hidden>
Date: 2016-06-15 22:43:25

Junio C Hamano [off-list ref] writes:
David Kastrup [off-list ref] writes:
quoted
I get

Option -m cannot be combined with -c/-C/-F/--amend.

but that makes no sense: of course there is ample reason for providing
an amended commit message on the command line.  -c, -C and -F indeed
all provide an alternative commit message, but --amend doesn't.
The option --amend is about "reusing the original commit message
and make amending edit on top".
Uh no.  From the man page:

	--amend
	   Used to amend the tip of the current branch. Prepare the
	   tree object you would want to replace the latest commit
	   as usual (this includes the usual -i/-o and explicit
	   paths), and the commit log editor is seeded with the
	   commit message from the tip of the current branch. The
	   commit you create replaces the current tip -- if it was a
	   merge, it will have the parents of the current tip as
	   parents -- so the current top commit is discarded.

	   It is a rough equivalent for:

			    $ git reset --soft HEAD^
			    $ ... do something else to come up with the right tree ...
			    $ git commit -c ORIG_HEAD

	   but can be used to amend a merge commit.


The --amend is not, according to the manual page, there to amend the
commit message, but primarily to amend the commit.

If one does not want to amend the message, this is easily done with -C
HEAD.  If one wants to amend the message but not by editing, one is
plain out of luck.

-C, -F and -m are all logically exclusive (and -C -e is the same as
-c).  But --amend seems completely orthogonal to me with regard to the
commit message: it just has a different seed from the normal commit
message edit.  You can override the seed with a normal commit using -c
-C -F and -m.  Why not with --amend?
If you are restarting the message from scratch, --amend does not
make much sense.
It amends the _commit_.  You can edit files, add them, and commit
additional changes.  If you are using a dumb terminal (or a system
with nonworking VISUAL over the link in question), you don't _want_ an
editor called up.
You can do:

	$ git reset HEAD^
        $ git commit -m "blah"

if you do not want to reuse the commit message.
You can pretty much _always_ avoid --amend in a similar manner, but
why would you?  It is convenient.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help