From: Junio C Hamano <gitster@pobox.com>
To: Andrew Ardill <andrew.ardill@gmail.com>
Cc: Christoph Paulik <cpaulik@gmail.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
"git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git merge branch --no-commit does commit fast forward merges
Date: Mon, 18 Apr 2016 09:36:30 -0700 [thread overview]
Message-ID: <xmqqy48a6fht.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CAH5451mDYhavx_OLfXe6cC2WguCsFWEBBBBOCPyX3E6ZJw27+w@mail.gmail.com> (Andrew Ardill's message of "Mon, 18 Apr 2016 17:44:13 +1000")
Andrew Ardill <andrew.ardill@gmail.com> writes:
> Yes, I think the mis-alignment in expectations comes from a
> technicality in the description you quote. The fast forward is in some
> ways not really counted as a true merge, and no new commits are
> created.
Looking at 123ee3ca (Add --no-commit to git-merge/git-pull.,
2005-11-01) and $gmane/10998 [*1*], it is clear that "--no-commit"
was never meant as a "preview of what would happen". The original
documentation update at 37465016 (Documentation: -merge and -pull:
describe merge strategies., 2005-11-04) was not great, but was
clarified at d8ae1d10 (Document the --no-commit flag better,
2005-11-04), and that version of text survives to this day.
The real reason why "--no-commit" was added was because back then
"git commit --amend" did not even exist; it appeared only at
b4019f04 (git-commit --amend, 2006-03-02).
What is (and was back then) the recommended way to see what changes
merging the other branch brings in to your branch, then?
There are at least three ways, all of which are better suited than
"--no-commit".
When you want to study and understand what changes other branch
made since it forked from what you are working on, then
$ git diff ...other_branch
would give you the change as a single ball of wax [*2*].
If you want to see individual changes explained by their authors,
you can also do
$ git log -p ..other_branch
Finally, if you want to see what the merge result would look like,
you just do the merge. Advancing the HEAD by one commit and then
going back once you are done is a cheap operation. If you want to
avoid updating your branch for real, these days you can even do so
on a detached HEAD, unlike old days back when there was not even
"commit --amend".
$ git checkout HEAD^0
$ git merge other_branch
$ git diff ORIG_HEAD ;# what changed overall?
$ git log -p ORIG_HEAD.. ;# inspect individual changes
$ git checkout - ;# come back to the original branch
> I do think that the --no-commit option should imply --no-ff (as this
> would make the behaviour consistent for end-users). I don't know if
> this is something that would break scripts etc, but if so you could
> make it implied only if we detect a terminal or something like is done
> in other places.
If we were living in an ideal world where "git commit --amend" were
already there in November 2005, we wouldn't have "merge --no-commit"
or "pull --no-commit" in our system today, and in such a world, I
would agree that "try to populate the working tree and the index
with result of a hypothetical merge and stop without updating HEAD
nor creating MERGE_HEAD, only to show what would happen if I merged"
option could be a useful addition to these two commands. And we may
choose to call such an option "--no-commit". I agree that such an
option should probably imply "--no-ff".
But we are not living in that world. Making "--no-commit" (which is
not that "try to populate and show" command) imply "--no-ff" will
break existing scripts. And unlike cosmetic things like "do we show
in color", changing the behaviour of a command in a fundamental way
based on term and istty() is a sure way to make commands harder to
understand ("it works this way from the terminal, but it works
differently in my script. what is going on?" is not a question we
are better off not seeing on this list).
Thanks.
[Notes and References]
*1* http://thread.gmane.org/gmane.comp.version-control.git/10998
*2* Notice the three dots; it is a short-hand for
$ git diff ^$(git merge-base HEAD other_branch) other_branch
next prev parent reply other threads:[~2016-04-18 16:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-17 21:10 git merge branch --no-commit does commit fast forward merges Christoph Paulik
2016-04-17 23:52 ` Jacob Keller
2016-04-18 6:26 ` Johannes Schindelin
2016-04-18 7:09 ` Andrew Ardill
2016-04-18 7:23 ` Christoph Paulik
2016-04-18 7:44 ` Andrew Ardill
2016-04-18 16:36 ` Junio C Hamano [this message]
2016-04-18 16:54 ` Junio C Hamano
2016-04-26 21:32 ` [PATCH 1/2] merge: do not contaminate option_commit with --squash Junio C Hamano
2016-04-27 6:46 ` Johannes Schindelin
2016-04-27 15:14 ` Junio C Hamano
2016-04-27 15:19 ` Johannes Schindelin
2016-04-26 21:37 ` [PATCH 2/2] merge: warn --no-commit merge when no new commit is created Junio C Hamano
2016-04-26 21:53 ` Stefan Beller
2016-04-26 22:00 ` Junio C Hamano
2016-04-27 1:39 ` Eric Sunshine
2016-04-27 5:57 ` Johannes Sixt
2016-04-27 6:50 ` Johannes Schindelin
2016-04-27 15:13 ` Junio C Hamano
2016-04-27 15:37 ` Johannes Schindelin
2016-04-27 16:02 ` Junio C Hamano
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=xmqqy48a6fht.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=andrew.ardill@gmail.com \
--cc=cpaulik@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.