From: Junio C Hamano <gitster@pobox.com>
To: "Ruslan Yakauleu" <ruslan.yakauleu@gmail.com>
Cc: git@vger.kernel.org,
"Kristoffer Haugsbakk" <code@khaugsbakk.name>,
"Taylor Blau" <me@ttaylorr.com>
Subject: Re: [PATCH] merge: --ff-one-only to apply FF if commit is one
Date: Thu, 02 Nov 2023 08:05:25 +0900 [thread overview]
Message-ID: <xmqqv8aloz0q.fsf@gitster.g> (raw)
In-Reply-To: <a457e24c-3375-49c6-8cf7-d2dd945827fe@app.fastmail.com> (Kristoffer Haugsbakk's message of "Wed, 01 Nov 2023 11:09:34 +0100")
"Kristoffer Haugsbakk" <code@khaugsbakk.name> writes:
> On Wed, Nov 1, 2023, at 02:42, Junio C Hamano wrote:
>> Strictly speaking, the log message on a merge commit serves two
>> purposes, one is to summarize commit(s) on the side branch that gets
>> merged with the merge, and as you said above, it is not needed when
>> merging a topic with just one commit. But the other is to justify
>> why the topic suits the objective of the line of history (which is
>> needed even when merging a single commit topic---imagine a commit
>> that is not incorrect per-se. It may or may not be suitable for the
>> maintenance track, and a merge commit of such a commit into the
>> track can explain if/how the commit being merged is maint-worthy).
>
> Yes. If you have multiple release/maintenance branches which you need to
> apply something to then you can’t use this .
OK. I do not mind a feature to help maintain the first-parent worldview
better to exist, but have a few comments on the patch.
* Nowhere in the name of feature --ff-one-only, the proposed commit
log message, added documentation and in-code comments, it is made
clear to readers that it is to maintain the first-parent view
better. The "first-parent" was only brought up between you and I
as our conjecture on what the feature is for. The should explain
the feature a bit better to our readers and users.
SIDE NOTE: in general, it is not the best way to name and explain
a feature after what it does (e.g., "fast-forward only when it
has one commit"); it is better to include why the user want it to
do what it does. It it especially true because "fast-forward
only when the other branch is ahead by one commit" may later turn
out not to be the best design to ensure "maintain first-parent
worldview", if the latter is what the feature is really about.
* The proposed commit log message needs a bit of proofreading and
polishing, paying attention to the grammar.
* The "allow fast-forward only when the other branch is ahead by
one commit" design misses an important case you would want to,
and you can detect easily, fast-forward.
Imagine that a developer has a rather complex topic with multiple
commits, asks the maintainer (or the auto-merger at their forge)
to pull, but due to modification on the upstream side, there are
heavy conflicts. The maintainer can tell (and Git was designed
to support this mode of operation better---it is called
"distributed development") the developer:
Since you know your topic much better than I do, can you do
the merge into the upstream for me?
The contributor would then help the maintainer, perhaps like so:
$ git checkout origin/main
$ git merge [--no-ff] my-topic
to pretend as if the contributer were the maintainer, merge and
resolve the conflicts, and then summarizes the topic in the log
message of the merge commit. The contributor then updates their
topic locally, perhaps with
$ git push . HEAD:my-topic
which would of course fast-forward, and then ask the maintainer
(or the auto-merger at their forge) to pull again from "my-topic".
Now, the updated "my-topic" is ahead of the origin by many
commits (i.e., the number of commits on the topic, plus the merge
commit the controbutor created to help the maintainer), but if we
want to see the resulting history as if the original pull request
was handled with the "--ff-one-only" option by the maintainer who
did the merge themself, then we should fast-forward this merge.
Even though the tip commit of "my-topic" has more commits behind
it, it is already the binding merge of the side topic that
"--ff-one-only" would have forced to create if the maintainer did
the merge.
So, a better design than "allow fast-forward, only if the branch
being merged is ahead by one commit" is to allow fast-forward
when the branch's first-parent is the current tip of the branch
pull/merge is trying to update. "only by one commit" can be
handled as a natural degenerate case of this more general
criteria, and a good thing is that it is much easier and more
efficient to compute (i.e., in "git merge OTHER", allow ff if
"OTHER^1" and "HEAD" are the same).
As I said, I do not mind a feature to help maintain the first-parent
worldview better to exist; thanks for working on the topic.
next prev parent reply other threads:[~2023-11-01 23:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 8:58 [PATCH] merge: --ff-one-only to apply FF if commit is one Ruslan Yakauleu via GitGitGadget
2023-10-25 16:27 ` Kristoffer Haugsbakk
2023-10-25 18:31 ` Ruslan Yakauleu
2023-10-25 19:04 ` Kristoffer Haugsbakk
[not found] ` <c37ba153-7239-49ff-b40f-370bc695986e@gmail.com>
2023-10-26 13:40 ` Ruslan Yakauleu
2023-10-30 20:01 ` Taylor Blau
2023-10-31 0:19 ` Junio C Hamano
2023-10-31 5:48 ` Ruslan Yakauleu
2023-10-31 6:07 ` Junio C Hamano
2023-10-31 8:32 ` Kristoffer Haugsbakk
2023-11-01 1:42 ` Junio C Hamano
2023-11-01 6:34 ` Ruslan Yakauleu
2023-11-01 10:09 ` Kristoffer Haugsbakk
2023-11-01 23:05 ` Junio C Hamano [this message]
2023-10-31 6:01 ` Ruslan Yakauleu
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=xmqqv8aloz0q.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
--cc=ruslan.yakauleu@gmail.com \
/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).