public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Viresh Kumar <viresh.kumar@st•com>
Cc: "Björn Steinbrink" <B.Steinbrink@gmx•de>,
	"Vijay Lakshminarayanan" <laksvij@gmail•com>,
	"git@vger•kernel.org" <git@vger•kernel.org>,
	"Shiraz HASHIM" <shiraz.hashim@st•com>,
	"Vipin KUMAR" <vipin.kumar@st•com>
Subject: Re: Query on git commit amend
Date: Thu, 08 Dec 2011 09:52:04 -0800	[thread overview]
Message-ID: <7vvcprar3v.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <4EDEFD66.4020404@st.com> (Viresh Kumar's message of "Wed, 7 Dec 2011 11:15:10 +0530")

Viresh Kumar <viresh.kumar@st•com> writes:

> GIT_EDITOR=cat git commit --amend
>
> over
>
> git commit --amend -C HEAD
>
> ?
>
> ...
> But for single commit probably second one looks easier. Isn't it?

I saw "--amend -C HEAD" mentioned in some newbie-guide webpages, and I
think you just copy/learned from one of them, so it is not entirely your
fault, but the combination of --amend and "-C HEAD" is an idiotic thing
that happens to work, if you think about what exactly you are telling to
the command.

The point of --amend is twofold. One is to let you tweak the contents of
what is committed, which is not the topic of this thread, and the other is
to allow the user to reuse the log message from the commit being amended,
instead of typing the message from scratch.

The "-c <commit>" and its cousin "-C <commit>" options are about telling
Git that the user does _not_ want the other usual logic to come up with
the initial commit template (e.g. when committing anew, it may read the
log template file, when committing a merge, it may read the MERGE_MSG
prepared by fmt-merge-msg, and most importantly in this context, when
amending, the one that is prepared by the --amend logic is used) kick in
at all, and instead wants to start from the log message of the named
commit.

So by saying "--amend -C HEAD" you are saying "I want to reuse the log
message of the commit I am amending,... eh, scratch that, I instead want
to use the log message of the HEAD commit", as if the commit you are
amending and HEAD are two different things. That is idiotic.

And you say that only for the side effect that capital "-C" stops the
editor.

Compared to that idiotic statement, "EDITOR=: git commit --amend" is a lot
saner way to say the same thing in a more direct and straightforward
way. "I want to reuse the log message of the commit I am amending, and the
editor to use it while running that commit is the command 'true', i.e. the
one that does not really touch any line in the text file and successfully
exits, because I am not going to change anything".

Of course, if "git commit --amend" honoured "--no-edit", that is even more
direct, straightforward and intuitive way to say so ;-)

  parent reply	other threads:[~2011-12-08 17:52 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06  8:23 Query on git commit amend Viresh Kumar
2011-12-06  9:01 ` Konstantin Khomoutov
2011-12-06 19:09   ` Dirk Süsserott
2011-12-06  9:11 ` Johannes Sixt
2011-12-06  9:20   ` Viresh Kumar
2011-12-06  9:22     ` Viresh Kumar
2011-12-06 15:46 ` Vijay Lakshminarayanan
2011-12-06 19:11   ` Jeff King
2011-12-07  2:18     ` Vijay Lakshminarayanan
2011-12-06 20:03   ` Junio C Hamano
2011-12-06 21:00     ` Junio C Hamano
2011-12-07 14:42       ` [PATCH/RFC 0/4] Re: commit: honor --no-edit Jonathan Nieder
2011-12-07 14:45         ` [PATCH 1/4] test: add missing "&&" after echo command Jonathan Nieder
2011-12-07 23:10           ` Jeff King
2011-12-07 23:11             ` Jeff King
2011-12-07 14:49         ` [PATCH 2/4] test: remove a porcelain test that hard-codes commit names Jonathan Nieder
2011-12-07 14:50         ` [PATCH 3/4] t7501 (commit): modernize style Jonathan Nieder
2011-12-07 14:54         ` [PATCH 4/4] test: commit --amend should honor --no-edit Jonathan Nieder
2011-12-07  2:28     ` Query on git commit amend Vijay Lakshminarayanan
2011-12-07  4:20       ` Viresh Kumar
2011-12-07  4:53         ` Björn Steinbrink
2011-12-07  5:45           ` Viresh Kumar
2011-12-07 15:06             ` Vijay Lakshminarayanan
2011-12-08 17:52             ` Junio C Hamano [this message]
2011-12-09  4:49               ` Viresh Kumar
2011-12-08  5:26   ` Viresh Kumar
2011-12-08  5:30     ` Viresh Kumar

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=7vvcprar3v.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox$(echo .)com \
    --cc=B.Steinbrink@gmx$(echo .)de \
    --cc=git@vger$(echo .)kernel.org \
    --cc=laksvij@gmail$(echo .)com \
    --cc=shiraz.hashim@st$(echo .)com \
    --cc=vipin.kumar@st$(echo .)com \
    --cc=viresh.kumar@st$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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