From: Junio C Hamano <gitster@pobox.com>
To: Yaroslav Halchenko <yoh@onerussian.com>
Cc: "git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: -s theirs use-case(s) Was: BUG: merge -s theirs is not in effect
Date: Tue, 26 Sep 2017 12:45:46 +0900 [thread overview]
Message-ID: <xmqqzi9iazrp.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170925144021.vhbd3wb3uqejs5wq@hopa.kiewit.dartmouth.edu> (Yaroslav Halchenko's message of "Mon, 25 Sep 2017 10:40:21 -0400")
Yaroslav Halchenko <yoh@onerussian.com> writes:
> 1. As a workaround for absence of -m theirs I using mtheirs git alias:
> (I believe provided to me awhile back here on the list):
>
> mtheirs = !sh -c 'git merge -s ours --no-commit $1 && git read-tree -m -u $1' -
>
> and it worked fine for my usecases
>
> 2. I think that if there is a reason for -s ours to exist, so there for -s theirs
> since it is just the directionality of merges which changes between the two
Just on this point. They are not exactly symmetric.
Imagine there are some undesirable changes you want to vanquish from
the world, but they have already built on useful changes on top of
the undesirable changes. A hypothetical history might look like
this:
B---C
/
X---X---A
/
---o---o your mainline
where 'X' denotes those unwanted changes.
With a "-s ours" merge, you can declare that changes on the other
branch will never be merged to your branch, i.e.
B---C
/
X---X---A
/ \
---o---o---M your mainline
and then you can safely merge A and C into your branch, without
having to worry about them bringing the unwanted changes to your
tree state.
B---C
/ \
X---X---A \
/ \ \ \
---o---o---M---N---O your mainline
That is the primary reason why "-s ours" exists, i.e. you do not
control the branch where mistakes X were made because that is
somebody else's history.
The symmetiric case where _you_ have wrong changes do not need "-s
theirs". These mistakes X are yours, so are the changes depend on
them:
B---C
/
X---X---A
/
---o---o their mainline
and you can just rebase A, B and C on top of their mainline while
getting rid of Xs yourself before publishing.
B'--C'
/
---o---o---A'
The reason why ours and theirs are not symmetric is because you are
you and not them---the control and ownership of our history and
their history is not symmetric.
There may be valid workflows that benefit from "-s theirs", and I
would not be surprised at all if we found more of them in the past 9
years since we had the "why -s theirs does not exist" discussion in
2008. But "because -s ours can be used in reverse to emulate" is
not a valid excuse to add "-s theirs". It can be used a rationale
against adding it (e.g. "-s theirs generally is discouraged because
it forsters a bad workflow, but in a very rare case where it might
be useful, you can always check out their branch and merge yours
using '-s ours' to emulate it, so we do not lose any functionality
even if we did not add it"), though.
next prev parent reply other threads:[~2017-09-26 3:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-25 0:02 BUG: merge -s theirs is not in effect (does the same as -s ours) Yaroslav Halchenko
2017-09-25 1:08 ` Junio C Hamano
2017-09-25 3:17 ` Yaroslav Halchenko
2017-09-25 5:33 ` Re* " Junio C Hamano
2017-09-25 14:30 ` -X theirs does not resolve symlink conflict Was: BUG: merge -s theirs is not in effect Yaroslav Halchenko
2017-09-26 1:56 ` Junio C Hamano
2017-09-26 2:16 ` Junio C Hamano
2017-09-26 2:39 ` Junio C Hamano
2017-09-26 13:37 ` Yaroslav Halchenko
2017-10-16 5:38 ` [PATCH] merge: teach -Xours/-Xtheirs to symbolic link merge Junio C Hamano
2017-12-29 2:49 ` Elijah Newren
2017-12-29 4:41 ` Yaroslav Halchenko
2018-01-25 4:35 ` external diff driver is not used for diff --stat? Yaroslav Halchenko
2017-09-25 14:40 ` -s theirs use-case(s) Was: BUG: merge -s theirs is not in effect Yaroslav Halchenko
2017-09-26 3:45 ` Junio C Hamano [this message]
2017-09-26 13:32 ` Yaroslav Halchenko
2017-09-27 0:09 ` Junio C Hamano
2017-09-27 5:19 ` Yaroslav Halchenko
2017-09-27 20:21 ` Yaroslav Halchenko
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=xmqqzi9iazrp.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=yoh@onerussian.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).