From: Fabian Ruch <bafain@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Eric Wong <normalperson@yhbt.net>
Subject: Re: [PATCH v1] rebase -m: Use empty tree base for parentless commits
Date: Mon, 13 Oct 2014 20:43:51 +0200 [thread overview]
Message-ID: <543C1D67.80501@gmail.com> (raw)
In-Reply-To: <xmqq1tqh6p3y.fsf@gitster.dls.corp.google.com>
Hi,
Junio C Hamano writes:
> Fabian Ruch <bafain@gmail.com> writes:
>> diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
>> index d3fb67d..3f754ae 100644
>> --- a/git-rebase--merge.sh
>> +++ b/git-rebase--merge.sh
>> @@ -67,7 +67,13 @@ call_merge () {
>> GIT_MERGE_VERBOSITY=1 && export GIT_MERGE_VERBOSITY
>> fi
>> test -z "$strategy" && strategy=recursive
>> - eval 'git-merge-$strategy' $strategy_opts '"$cmt^" -- "$hd" "$cmt"'
>> + base=$(git rev-list --parents -1 $cmt | cut -d ' ' -s -f 2 -)
>> + if test -z "$base"
>> + then
>> + # the empty tree sha1
>> + base=4b825dc642cb6eb9a060e54bf8d69288fbee4904
>> + fi
>> + eval 'git-merge-$strategy' $strategy_opts '"$base" -- "$hd" "$cmt"'
>
> This looks wrong.
>
> The interface to "git-merge-$strategy" is designed in such a way
> that each strategy should be capable of taking _no_ base at all.
Ok, but doesn't this use of the git-merge-$strategy interface (as shown
in the example below) apply only to the case where one wants to merge
two histories by creating a merge commit? When a merge commit is being
created, the documentation states that git-merge abstracts from the
commit history considering the _total change_ since a merge base on each
branch.
In contrast, here (i.e., in the case of git-rebase--merge) we care about
how the changes introduced by the _individual commits_ are applied.
Therefore, don't we want to be explicit about the "base" and tell
git-merge-$strategy exactly which changes it should merge into the
current head?
The codebase has always been doing this both for git-rebase--merge and
git-cherry-pick. What leads to the reported bug is that the latter
covers the case where the commit object has no parents but the former
doesn't. Root commits are handled by git-cherry-pick (and should be by
git-rebase--merge) using an explicit "base" for the same reason why
$cmt^ is given.
> See how unquoted $common is given to git-merge-$strategy in
> contrib/examples/git-merge.sh, i.e.
>
> eval 'git-merge-$strategy '"$xopt"' $common -- "$head_arg" "$@"'
>
> where common comes from
>
> common=$(git merge-base ...)
>
> which would be empty when you are looking at disjoint histories.
If there are still objections to the patch because of the magic number
and the cut, it might be worth considering an implementation of
git-rebase--merge using git-cherry-pick's merge strategy option.
Fabian
next prev parent reply other threads:[~2014-10-13 18:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-07 18:30 Apparent bug in git rebase with a merge commit David M. Lloyd
2014-10-09 18:50 ` [PATCH v1] rebase -m: Use empty tree base for parentless commits Fabian Ruch
2014-10-09 19:05 ` Junio C Hamano
2014-10-09 19:55 ` Fabian Ruch
2014-10-09 20:18 ` Junio C Hamano
2014-10-13 18:43 ` Fabian Ruch [this message]
2014-10-09 19:06 ` Derek Moore
2014-10-09 19:20 ` David M. Lloyd
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=543C1D67.80501@gmail.com \
--to=bafain@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=normalperson@yhbt.net \
/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).