From: Junio C Hamano <gitster@pobox.com>
To: Petr Baudis <pasky@suse.cz>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Documentation/git-merge.txt: Expand the How Merge Works section
Date: Thu, 17 Jul 2008 11:17:22 -0700 [thread overview]
Message-ID: <7v3am8gytp.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20080717162922.12081.96582.stgit@localhost
Petr Baudis <pasky@suse.cz> writes:
> The git-merge documentation's "HOW MERGE WORKS" section is confusingly
> composed and actually omits the most interesting part, the merging of
> the arguments into HEAD itself, surprisingly not actually mentioning
> the fast-forward merge anywhere.
Thanks.
> +Three kinds of merge can happen:
>
> +* The merged commit is already contained in `HEAD`. This is the
> + simplest case and only "Already up-to-date" is printed.
Let's introduce and define terms here, because I think the readers will be
harmed by being given a weak "this _might_ be called" in later paragraph.
I.e.:
... This is the simplest case and called "Already up-to-date".
> +* `HEAD` is already contained in the merged commit. This is the
> + most common case especially when involved through 'git pull':
> + you are tracking an upstream repository, committed no local
> + changes and now you want to update to a newer upstream revision.
> + So-called "fast-forward merge" is performed, simply repointing
> + your `HEAD` (and index) to the merged commit; no extra merge
> + commit is created.
I'd suggest rewording the last three lines:
Your `HEAD` (and the index) is updated to point the merged
commit, without creating an extra merge commit. This is
called "Fast-forward".
> +* Both merged commit and `HEAD` are independent and must be
> + "tied together" by a merge commit, having them both as its parents;
> + this might be called a "true merge" and is described in the rest
> + of this section.
And this becomes:
... both as its parents. The rest of this section describes this
"True merge" case.
> +Pre-flight requirements note
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +In certain special cases, your index is
> +allowed to be different from the tree of the `HEAD` commit.
Now this paragraph is moved far away from the original context that said
"your index must be clean before you start your merge", you would need to
re-introduce that in this sentenece:
... tree of the `HEAD` before you run 'git-merge'.
> +... The most
> +notable case is when your `HEAD` commit is already ahead of what
> +is being merged, in which case your index can have arbitrary
> +differences from your `HEAD` commit.
Thanks to your re-organization, we now have established terminology when
the reader reads this part, so we can just say:
When the merge will be "Already-up-to-date", your index can have
...
> +... Also, your index entries
> +may have differences from your `HEAD` commit that match
> +the result of a trivial merge (e.g. you received the same patch
> +from an external source to produce the same result as what you are
> +merging). For example, if a path did not exist in the common
> +ancestor and your head commit but exists in the tree you are
> +merging into your repository, and if you already happen to have
> +that path exactly in your index, the merge does not have to
> +fail.
I originally wrote the above paragraph purely for completeness, but I
wonder if this happens a lot in practice. This is not something the user
can easily anticipate anyway, so we might want to drop this.
> +Other than that, merge will refuse to do any harm to your repository
My initial reaction to this "Other than that" was "Huh? so the special
case we just saw allows merge to do harm to my repository?". The original
"Otherwise" wasn't any better, either.
In all other cases, your index must match the `HEAD` commit, even
though you can have local changes in your working tree, as
described below. Merge will avoid doing any harm to your working
tree state and your repository by refusing to work if such local
changes conflict with the merged result, though.
> +So in the above two "failed merge" case, you do not have to
> +worry about loss of data --- you simply were not ready to do
> +a merge, so no merge happened at all. You may want to finish
> +whatever you were in the middle of doing, and retry the same
> +pull after you are done and ready.
I am not sure what two cases we were describing. It could be that this
paragraph was taken from a mailing list message responding to a question
(e.g. "I got this merge failure message and my tree is screwed up. Please
help me get back to a good state, I am lost...") without copying the
original sample failure scenario.
next prev parent reply other threads:[~2008-07-17 18:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-17 16:29 [PATCH] Documentation/git-merge.txt: Expand the How Merge Works section Petr Baudis
2008-07-17 16:42 ` Petr Baudis
2008-07-17 18:17 ` Junio C Hamano [this message]
2008-07-17 18:54 ` Petr Baudis
2008-07-17 19:34 ` Junio C Hamano
2008-07-18 13:18 ` Petr Baudis
2008-07-18 13:20 ` [PATCH] Documentation/git-merge.txt: Partial rewrite of How Merge Works Petr Baudis
2008-07-19 0:32 ` [PATCH] Documentation/git-merge.txt: Expand the How Merge Works section Junio C Hamano
2008-07-19 18:17 ` [PATCH] Documentation/git-merge.txt: Partial rewrite of How Merge Works Petr Baudis
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=7v3am8gytp.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pasky@suse.cz \
/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).