#!/bin/sh global test_description := ''git rebase --abort tests'' source ./test-lib.sh ### Test that we handle space characters properly global work_dir := ""$[pwd]/test dir"" test_expect_success setup ' mkdir -p "$work_dir" && cd "$work_dir" && git init && echo a > a && git add a && git commit -m a && git branch to-rebase && echo b > a && git commit -a -m b && echo c > a && git commit -a -m c && git checkout to-rebase && echo d > a && git commit -a -m "merge should fail on this" && echo e > a && git commit -a -m "merge should fail on this, too" && git branch pre-rebase ' proc testrebase { global type := $1 global dotest := $2 test_expect_success "rebase$type --abort" ' cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type master && test_path_is_dir "$dotest" && git rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && test ! -d "$dotest" ' test_expect_success "rebase$type --abort after --skip" ' cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type master && test_path_is_dir "$dotest" && test_must_fail git rebase --skip && test $(git rev-parse HEAD) = $(git rev-parse master) && git rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && test ! -d "$dotest" ' test_expect_success "rebase$type --abort after --continue" ' cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type master && test_path_is_dir "$dotest" && echo c > a && echo d >> a && git add a && test_must_fail git rebase --continue && test $(git rev-parse HEAD) != $(git rev-parse master) && git rebase --abort && test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && test ! -d "$dotest" ' test_expect_success "rebase$type --abort does not update reflog" ' cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && git reflog show to-rebase > reflog_before && test_must_fail git rebase$type master && git rebase --abort && git reflog show to-rebase > reflog_after && test_cmp reflog_before reflog_after && rm reflog_before reflog_after ' test_expect_success 'rebase --abort can not be used with other options' ' cd "$work_dir" && # Clean up the state from the previous one git reset --hard pre-rebase && test_must_fail git rebase$type master && test_must_fail git rebase -v --abort && test_must_fail git rebase --abort -v && git rebase --abort ' } testrebase "" .git/rebase-apply testrebase " --merge" .git/rebase-merge test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git rebase --abort tests">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:work_dir) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [20 22] ) ("/test dir") ) } spids: [18] ) ] spids: [18] ) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\tmkdir -p \"$work_dir\" &&\n"> <"\tcd \"$work_dir\" &&\n"> <"\tgit init &&\n"> <"\techo a > a &&\n"> <"\tgit add a &&\n"> <"\tgit commit -m a &&\n"> <"\tgit branch to-rebase &&\n"> <"\n"> <"\techo b > a &&\n"> <"\tgit commit -a -m b &&\n"> <"\techo c > a &&\n"> <"\tgit commit -a -m c &&\n"> <"\n"> <"\tgit checkout to-rebase &&\n"> <"\techo d > a &&\n"> <"\tgit commit -a -m \"merge should fail on this\" &&\n"> <"\techo e > a &&\n"> <"\tgit commit -a -m \"merge should fail on this, too\" &&\n"> <"\tgit branch pre-rebase\n"> ) } ) (FuncDef name: testrebase body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:type) op: Equal rhs: {($ VSub_Number "$1")} spids: [62] ) ] spids: [62] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dotest) op: Equal rhs: {($ VSub_Number "$2")} spids: [66] ) ] spids: [66] ) (C {(test_expect_success)} {(DQ (rebase) ($ VSub_Name "$type") (" --abort"))} { (SQ <"\n"> <"\t\tcd \"$work_dir\" &&\n"> <"\t\t# Clean up the state from the previous one\n"> <"\t\tgit reset --hard pre-rebase &&\n"> <"\t\ttest_must_fail git rebase$type master &&\n"> <"\t\ttest_path_is_dir \"$dotest\" &&\n"> <"\t\tgit rebase --abort &&\n"> <"\t\ttest $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&\n"> <"\t\ttest ! -d \"$dotest\"\n"> <"\t"> ) } ) (C {(test_expect_success)} {(DQ (rebase) ($ VSub_Name "$type") (" --abort after --skip"))} { (SQ <"\n"> <"\t\tcd \"$work_dir\" &&\n"> <"\t\t# Clean up the state from the previous one\n"> <"\t\tgit reset --hard pre-rebase &&\n"> <"\t\ttest_must_fail git rebase$type master &&\n"> <"\t\ttest_path_is_dir \"$dotest\" &&\n"> <"\t\ttest_must_fail git rebase --skip &&\n"> <"\t\ttest $(git rev-parse HEAD) = $(git rev-parse master) &&\n"> <"\t\tgit rebase --abort &&\n"> <"\t\ttest $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&\n"> <"\t\ttest ! -d \"$dotest\"\n"> <"\t"> ) } ) (C {(test_expect_success)} {(DQ (rebase) ($ VSub_Name "$type") (" --abort after --continue"))} { (SQ <"\n"> <"\t\tcd \"$work_dir\" &&\n"> <"\t\t# Clean up the state from the previous one\n"> <"\t\tgit reset --hard pre-rebase &&\n"> <"\t\ttest_must_fail git rebase$type master &&\n"> <"\t\ttest_path_is_dir \"$dotest\" &&\n"> <"\t\techo c > a &&\n"> <"\t\techo d >> a &&\n"> <"\t\tgit add a &&\n"> <"\t\ttest_must_fail git rebase --continue &&\n"> <"\t\ttest $(git rev-parse HEAD) != $(git rev-parse master) &&\n"> <"\t\tgit rebase --abort &&\n"> <"\t\ttest $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) &&\n"> <"\t\ttest ! -d \"$dotest\"\n"> <"\t"> ) } ) (C {(test_expect_success)} {(DQ (rebase) ($ VSub_Name "$type") (" --abort does not update reflog"))} { (SQ <"\n"> <"\t\tcd \"$work_dir\" &&\n"> <"\t\t# Clean up the state from the previous one\n"> <"\t\tgit reset --hard pre-rebase &&\n"> <"\t\tgit reflog show to-rebase > reflog_before &&\n"> <"\t\ttest_must_fail git rebase$type master &&\n"> <"\t\tgit rebase --abort &&\n"> <"\t\tgit reflog show to-rebase > reflog_after &&\n"> <"\t\ttest_cmp reflog_before reflog_after &&\n"> <"\t\trm reflog_before reflog_after\n"> <"\t"> ) } ) (C {(test_expect_success)} {(SQ <"rebase --abort can not be used with other options">)} { (SQ <"\n"> <"\t\tcd \"$work_dir\" &&\n"> <"\t\t# Clean up the state from the previous one\n"> <"\t\tgit reset --hard pre-rebase &&\n"> <"\t\ttest_must_fail git rebase$type master &&\n"> <"\t\ttest_must_fail git rebase -v --abort &&\n"> <"\t\ttest_must_fail git rebase --abort -v &&\n"> <"\t\tgit rebase --abort\n"> <"\t"> ) } ) ] spids: [59] ) spids: [55 58] ) (C {(testrebase)} {(DQ )} {(.git/rebase-apply)}) (C {(testrebase)} {(DQ (" --merge"))} {(.git/rebase-merge)}) (C {(test_done)}) ] )