Re: [PATCH v2 2/7] add tests for rebasing with patch-equivalence present
- From
Martin von Zweigbergk <martinvonz@gmail.com>
- Date
- May 30, 2013, 05:30 UTC
- Message-ID
- <CANiSa6joMXeh7HoGAFXskdXaPZjN+0uHrtN7V85FyQHTGCwZMQ@mail.gmail.com>
- In-Reply-To
- <51A5A992.306@viscovery.net>
On Wed, May 29, 2013 at 12:09 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 23 quoted lines
> Am 5/29/2013 8:39, schrieb Martin von Zweigbergk:
>> +# f
>> +# /
>> +# a---b---c---g---h
>> +# \
>> +# d---G---i
> ...
>> +test_run_rebase () {
>> + result=$1
>> + shift
>> + test_expect_$result "rebase $* --onto drops patches in onto" "
>> + reset_rebase &&
>> + git rebase $* --onto h f i &&
>> + test_cmp_rev h HEAD~2 &&
>> + test_linear_range 'd i' h..
>
> Isn't this expectation wrong? The upstream of the rebased branch is f, and
> it does not contain G. Hence, G should be replayed. Since h is the
> reversal of g, the state at h is the same as at c, and applying G should
> succeed (it is the same change as g). Therefore, I think the correct
> expectation is:
>
> test_linear_range 'd G i' h..Good question! It is really not obvious what the right answer is. Some arguments in favor of dropping 'G':
1. Let's say origin/master points to 'b' when you start the 'd G i' branch. You then send the 'G' patch to Junio who applies it as 'g' (cherry-picking direction is reversed compared to figure, but same effect). You then "git pull --rebase" when master on origin points to 'h'. Because of the cleverness in 'git pull --rebase', it issues 'git rebase --onto h b i'. In this case it's clearly useful to have the patch dropped.
2. In the test a little before the above one, we instead do 'git rebase --onto f h i' and make sure that the 'G' is _not_ lost. In that case it doesn't matter what's in $branch..$upstream. Do we agree that $branch..$upstream should never matter (instead, $upstream is only used to find merge base with $branch)? Do we also agree that 'git rebase a b' should be identical to 'git rebase --onto a a b'? Because 'git rebase h i' should clearly drop 'G', then so should 'git rebase --onto h h i'. Then, if we agreed that $branch..$upstream doesn't matter, 'git rebase --onto h f i' should behave the same, no?
The set of commits to rebase that I was thinking of using was "$upstream..$branch, unless equivalent with patch in $branch..$onto". But I'm not very confident about my conclusions above :-)
Martin