git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Mark Wooding <mdw@distorted.org.uk>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-merge: New options `--no-fast-forward' and `--direct'.
Date: Sat, 18 Mar 2006 13:59:21 -0800	[thread overview]
Message-ID: <7vmzfns9c6.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: 20060318101941.8941.52615.stgit@metalzone.distorted.org.uk

Mark Wooding <mdw@distorted.org.uk> writes:

> These options disable some of git-merge's optimizations.  

While there is no question about the part of the proposed change
to bypass "trivial merge", I do not necessarily agree with
"skipping fast forward" part.

It is a problem that "ours" strategy cannot be used as a way to
recover from the "accidentally rewound head" situation, because
it is prevented from running under certain conditions as you
described.  But that does not necessarily mean we should make
"ours" to work in these situations.

You accidentally discarded B while somebody picked it up:

                 o---o
                /     \
    ---o---o---A---o---o---B
               ^your head

Now you would want to recover.  With your patch, it would create
this:

                 o---o
                /     \
    ---o---o---A---o---o---B
                \           \
                 ------------M
                             ^your updated head,
                              having the same tree as A

But recording A as a parent of M is not necessary.  I think what
we want to have as the result is this instead:

                 o---o
                /     \
    ---o---o---A---o---o---B---M
                               ^your updated head,
                                having the same tree as A

This is something you cannot do within the current git-merge
framework; it is set up to either just fast forward or make a
multi-parent commit.  You would want have a "revert to this
state" [*1*], something like this (assuming you have rewound to
A and currently your index matches A):

        $ git reset --soft B
        $ git commit -m 'Discard A..B and revert to A'

I did "ours" primarily as a demonstration of a funky thing
people could do with the consolidated driver "git-merge".  I did
not have a useful use-case in mind back then, but it turned out
to be the ideal way to recover from "accidentally rewound head"
situation, except that making a merge commit between A and B is
not always the way to recover from it.  If we wanted to, we
could have a special purpose command that does "git merge -s
ours" if there will be a new commit, otherwise the above two
commands sequence if it will be a fast forward, but the
"recovering from accidentally rewound head" _is_ really a
special purpose, so I do not know if it is worth it.

In your cover letter, you talked about using --no-fast-forward
to collapse your sole topic branch into your master branch.  I
do not think smudging the development history with extra merge
commits for that is justfied either.  There is no reason for you
to discard your topic branch heads after you merged them into
master.  If they get in the way of your normal workflow, you can
stash them away as tags that you do not usually see in "git
branch" output [*2*].

Also I am already unhappy that git-merge knows about the
specifics of strategies [*3*], e.g. it knows octopus is
currently the only strategy that can do more than two heads.
Your patch gives more strategy specific knowledge to it, but I
do not know how to avoid it.


[Footnotes]

*1* As opposed to "git revert X" which means "revert the effect
of commit X", you would want "revert to the state X".

*2* I keep some of my old topic branch heads under
.git/tags/attic/.

*3* Another thing I am unhappy about is the list of available
strategies.  I initially wanted to allow users to write their
own merge strategies and have them on their PATH (not even
necessarily in GIT_EXEC_PATH directory), so that you can do a
git-merge-mdw secretly, keep it in ~mdw/bin and cook it for a
while using yourself as a guinea pig, and then share that with
the community later, _without_ touching git-merge.

  reply	other threads:[~2006-03-18 21:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-18 10:17 On merging strategies, fast forward and index merge Mark Wooding
2006-03-18 10:19 ` [PATCH] git-merge: New options `--no-fast-forward' and `--direct' Mark Wooding
2006-03-18 21:59   ` Junio C Hamano [this message]
2006-03-18 22:53     ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vmzfns9c6.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=mdw@distorted.org.uk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).