#!/bin/sh global test_description := ''git rebase --onto A...B'' source ./test-lib.sh source "$TEST_DIRECTORY/lib-rebase.sh" # Rebase only the tip commit of "topic" on merge base between "master" # and "topic". Cannot do this for "side" with "master" because there # is no single merge base. # # # F---G topic G' # / / # A---B---C---D---E master --> A---B---C---D---E # \ \ / # \ x # \ / \ # H---I---J---K side test_expect_success setup ' test_commit A && test_commit B && git branch side && test_commit C && git branch topic && git checkout side && test_commit H && git checkout master && test_tick && git merge H && git tag D && test_commit E && git checkout topic && test_commit F && test_commit G && git checkout side && test_tick && git merge C && git tag I && test_commit J && test_commit K ' test_expect_success 'rebase --onto master...topic' ' git reset --hard && git checkout topic && git reset --hard G && git rebase --onto master...topic F && git rev-parse HEAD^1 >actual && git rev-parse C^0 >expect && test_cmp expect actual ' test_expect_success 'rebase --onto master...' ' git reset --hard && git checkout topic && git reset --hard G && git rebase --onto master... F && git rev-parse HEAD^1 >actual && git rev-parse C^0 >expect && test_cmp expect actual ' test_expect_success 'rebase --onto master...side' ' git reset --hard && git checkout side && git reset --hard K && test_must_fail git rebase --onto master...side J ' test_expect_success 'rebase -i --onto master...topic' ' git reset --hard && git checkout topic && git reset --hard G && set_fake_editor && EXPECT_COUNT=1 git rebase -i --onto master...topic F && git rev-parse HEAD^1 >actual && git rev-parse C^0 >expect && test_cmp expect actual ' test_expect_success 'rebase -i --onto master...' ' git reset --hard && git checkout topic && git reset --hard G && set_fake_editor && EXPECT_COUNT=1 git rebase -i --onto master... F && git rev-parse HEAD^1 >actual && git rev-parse C^0 >expect && test_cmp expect actual ' test_expect_success 'rebase -i --onto master...side' ' git reset --hard && git checkout side && git reset --hard K && test_must_fail git rebase -i --onto master...side J ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git rebase --onto A...B">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY") (/lib-rebase.sh))}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\ttest_commit A &&\n"> <"\ttest_commit B &&\n"> <"\tgit branch side &&\n"> <"\ttest_commit C &&\n"> <"\tgit branch topic &&\n"> <"\tgit checkout side &&\n"> <"\ttest_commit H &&\n"> <"\tgit checkout master &&\n"> <"\ttest_tick &&\n"> <"\tgit merge H &&\n"> <"\tgit tag D &&\n"> <"\ttest_commit E &&\n"> <"\tgit checkout topic &&\n"> <"\ttest_commit F &&\n"> <"\ttest_commit G &&\n"> <"\tgit checkout side &&\n"> <"\ttest_tick &&\n"> <"\tgit merge C &&\n"> <"\tgit tag I &&\n"> <"\ttest_commit J &&\n"> <"\ttest_commit K\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase --onto master...topic">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout topic &&\n"> <"\tgit reset --hard G &&\n"> <"\n"> <"\tgit rebase --onto master...topic F &&\n"> <"\tgit rev-parse HEAD^1 >actual &&\n"> <"\tgit rev-parse C^0 >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase --onto master...">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout topic &&\n"> <"\tgit reset --hard G &&\n"> <"\n"> <"\tgit rebase --onto master... F &&\n"> <"\tgit rev-parse HEAD^1 >actual &&\n"> <"\tgit rev-parse C^0 >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase --onto master...side">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout side &&\n"> <"\tgit reset --hard K &&\n"> <"\n"> <"\ttest_must_fail git rebase --onto master...side J\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase -i --onto master...topic">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout topic &&\n"> <"\tgit reset --hard G &&\n"> <"\tset_fake_editor &&\n"> <"\tEXPECT_COUNT=1 git rebase -i --onto master...topic F &&\n"> <"\tgit rev-parse HEAD^1 >actual &&\n"> <"\tgit rev-parse C^0 >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase -i --onto master...">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout topic &&\n"> <"\tgit reset --hard G &&\n"> <"\tset_fake_editor &&\n"> <"\tEXPECT_COUNT=1 git rebase -i --onto master... F &&\n"> <"\tgit rev-parse HEAD^1 >actual &&\n"> <"\tgit rev-parse C^0 >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rebase -i --onto master...side">)} { (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit checkout side &&\n"> <"\tgit reset --hard K &&\n"> <"\n"> <"\ttest_must_fail git rebase -i --onto master...side J\n"> ) } ) (C {(test_done)}) ] )