(List (= scope=<EAssignScope.GLOBAL 1> flags=0 words=[] bindings=[('test_description', {[SQ <LIT_CHARS "checkout into detached HEAD state">]})]) (Com {[LIT_CHARS .]} {[LIT_CHARS ./test-lib.sh]} ) (FunctionDef check_detached [] (Com {[LIT_CHARS test_must_fail]} {[LIT_CHARS git]} {[LIT_CHARS symbolic-ref]} {[LIT_CHARS -q]} {[LIT_CHARS HEAD]} < (FilenameRedirectNode filename={[LIT_CHARS /dev/null]} <REDIR_GREAT ">"> 1), > ) ) (FunctionDef check_not_detached [] (Com {[LIT_CHARS git]} {[LIT_CHARS symbolic-ref]} {[LIT_CHARS -q]} {[LIT_CHARS HEAD]} < (FilenameRedirectNode filename={[LIT_CHARS /dev/null]} <REDIR_GREAT ">"> 1), > ) ) (= scope=<EAssignScope.GLOBAL 1> flags=0 words=[] bindings=[('PREV_HEAD_DESC', {[SQ <LIT_CHARS "Previous HEAD position was">]})]) (FunctionDef check_orphan_warning [] (AndOr OP_AND_IF (Com {[LIT_CHARS test_i18ngrep]} {[DQ [LIT_CHARS "you are leaving "][VarSub 2][LIT_CHARS " behind"]]} {[DQ [VarSub 1]]} ) (Com {[LIT_CHARS test_i18ngrep]} {[LIT_OTHER "!"]} {[DQ [VarSub PREV_HEAD_DESC]]} {[DQ [VarSub 1]]} ) ) ) (FunctionDef check_no_orphan_warning [] (AndOr OP_AND_IF (Com {[LIT_CHARS test_i18ngrep]} {[LIT_OTHER "!"]} {[DQ [LIT_CHARS "you are leaving .* commit.*behind"]]} {[DQ [VarSub 1]]} ) (Com {[LIT_CHARS test_i18ngrep]} {[DQ [VarSub PREV_HEAD_DESC]]} {[DQ [VarSub 1]]} ) ) ) (FunctionDef reset [] (AndOr OP_AND_IF (Com {[LIT_CHARS git]} {[LIT_CHARS checkout]} {[LIT_CHARS master]} ) (Com {[LIT_CHARS check_not_detached]} ) ) ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS setup>]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\ttest_commit one &&\n"> <LIT_CHARS "\ttest_commit two &&\n"> <LIT_CHARS "\ttest_commit three && git tag -d three &&\n"> <LIT_CHARS "\ttest_commit four && git tag -d four &&\n"> <LIT_CHARS "\tgit branch branch &&\n"> <LIT_CHARS "\tgit tag tag\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout branch does not detach">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout branch &&\n"> <LIT_CHARS "\tcheck_not_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout tag detaches">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout tag &&\n"> <LIT_CHARS "\tcheck_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout branch by full name detaches">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout refs/heads/branch &&\n"> <LIT_CHARS "\tcheck_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout non-ref detaches">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout branch^ &&\n"> <LIT_CHARS "\tcheck_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout ref^0 detaches">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout branch^0 &&\n"> <LIT_CHARS "\tcheck_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout --detach detaches">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout --detach branch &&\n"> <LIT_CHARS "\tcheck_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout --detach without branch name">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout --detach &&\n"> <LIT_CHARS "\tcheck_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout --detach errors out for non-commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\ttest_must_fail git checkout --detach one^{tree} &&\n"> <LIT_CHARS "\tcheck_not_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout --detach errors out for extra argument">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout master &&\n"> <LIT_CHARS "\ttest_must_fail git checkout --detach tag one.t &&\n"> <LIT_CHARS "\tcheck_not_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout --detached and -b are incompatible">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\ttest_must_fail git checkout --detach -b newbranch tag &&\n"> <LIT_CHARS "\tcheck_not_detached\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout --detach moves HEAD">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout one &&\n"> <LIT_CHARS "\tgit checkout --detach two &&\n"> <LIT_CHARS "\tgit diff --exit-code HEAD &&\n"> <LIT_CHARS "\tgit diff --exit-code two\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout warns on orphan commits">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout --detach two &&\n"> <LIT_CHARS "\techo content >orphan &&\n"> <LIT_CHARS "\tgit add orphan &&\n"> <LIT_CHARS "\tgit commit -a -m orphan1 &&\n"> <LIT_CHARS "\techo new content >orphan &&\n"> <LIT_CHARS "\tgit commit -a -m orphan2 &&\n"> <LIT_CHARS "\torphan2=$(git rev-parse HEAD) &&\n"> <LIT_CHARS "\tgit checkout master 2>stderr\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout warns on orphan commits: output">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck_orphan_warning stderr \"2 commits\"\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout warns orphaning 1 of 2 commits">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tgit checkout \"$orphan2\" &&\n"> <LIT_CHARS "\tgit checkout HEAD^ 2>stderr\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout warns orphaning 1 of 2 commits: output">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck_orphan_warning stderr \"1 commit\"\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout does not warn leaving ref tip">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout --detach two &&\n"> <LIT_CHARS "\tgit checkout master 2>stderr\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout does not warn leaving ref tip">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck_no_orphan_warning stderr\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout does not warn leaving reachable commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit checkout --detach HEAD^ &&\n"> <LIT_CHARS "\tgit checkout master 2>stderr\n">]} ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "checkout does not warn leaving reachable commit">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\tcheck_no_orphan_warning stderr\n">]} ) (Com {[LIT_CHARS cat]} < (FilenameRedirectNode filename={[LIT_CHARS expect]} <REDIR_GREAT ">"> 1), (HereDocRedirectNode here_end='EOF' do_expansion=False body_word={[LIT_CHARS "Your branch is behind 'master' by 1 commit, and can be fast-forwarded.\n"]} <REDIR_DLESS "<<"> 0), > ) (Com {[LIT_CHARS test_expect_success]} {[SQ <LIT_CHARS "tracking count is accurate after orphan check">]} {[SQ <LIT_CHARS "\n"> <LIT_CHARS "\treset &&\n"> <LIT_CHARS "\tgit branch child master^ &&\n"> <LIT_CHARS "\tgit config branch.child.remote . &&\n"> <LIT_CHARS "\tgit config branch.child.merge refs/heads/master &&\n"> <LIT_CHARS "\tgit checkout child^ &&\n"> <LIT_CHARS "\tgit checkout child >stdout &&\n"> <LIT_CHARS "\ttest_i18ncmp expect stdout\n">]} ) (Com {[LIT_CHARS test_done]} ) )