(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ (Token id:Id.Lit_Chars val:'checkout into detached HEAD state' span_id:6))} spids: [4] ) ] ) (C {(.)} {(./test-lib.sh)}) (command.ShFunction name: check_detached body: (command.BraceGroup children: [ (command.Simple words: [{(test_must_fail)} {(git)} {(symbolic-ref)} {(-q)} {(HEAD)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:32) fd: -1 arg_word: {(/dev/null)} ) ] ) ] ) ) (command.ShFunction name: check_not_detached body: (command.BraceGroup children: [ (command.Simple words: [{(git)} {(symbolic-ref)} {(-q)} {(HEAD)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:54) fd: -1 arg_word: {(/dev/null)} ) ] ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:PREV_HEAD_DESC) op: assign_op.Equal rhs: {(SQ (Token id:Id.Lit_Chars val:'Previous HEAD position was' span_id:62))} spids: [60] ) ] ) (command.ShFunction name: check_orphan_warning body: (command.BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (C {(test_i18ngrep)} {(DQ ('you are leaving ') ($ Id.VSub_Number '$2') (' behind'))} {(DQ ($ Id.VSub_Number '$1'))} ) (C {(test_i18ngrep)} {(Id.KW_Bang '!')} {(DQ ($ Id.VSub_DollarName '$PREV_HEAD_DESC'))} {(DQ ($ Id.VSub_Number '$1'))} ) ] ) ] ) ) (command.ShFunction name: check_no_orphan_warning body: (command.BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (C {(test_i18ngrep)} {(Id.KW_Bang '!')} {(DQ ('you are leaving .* commit.*behind'))} {(DQ ($ Id.VSub_Number '$1'))} ) (C {(test_i18ngrep)} {(DQ ($ Id.VSub_DollarName '$PREV_HEAD_DESC'))} {(DQ ($ Id.VSub_Number '$1'))} ) ] ) ] ) ) (command.ShFunction name: reset body: (command.BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [(C {(git)} {(checkout)} {(master)}) (C {(check_not_detached)})] ) ] ) ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:setup span_id:161))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:165) (Token id:Id.Lit_Chars val:'\ttest_commit one &&\n' span_id:166) (Token id:Id.Lit_Chars val:'\ttest_commit two &&\n' span_id:167) (Token id: Id.Lit_Chars val: '\ttest_commit three && git tag -d three &&\n' span_id: 168 ) (Token id:Id.Lit_Chars val:'\ttest_commit four && git tag -d four &&\n' span_id:169) (Token id:Id.Lit_Chars val:'\tgit branch branch &&\n' span_id:170) (Token id:Id.Lit_Chars val:'\tgit tag tag\n' span_id:171) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout branch does not detach' span_id:178))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:182) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:183) (Token id:Id.Lit_Chars val:'\tgit checkout branch &&\n' span_id:184) (Token id:Id.Lit_Chars val:'\tcheck_not_detached\n' span_id:185) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout tag detaches' span_id:192))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:196) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:197) (Token id:Id.Lit_Chars val:'\tgit checkout tag &&\n' span_id:198) (Token id:Id.Lit_Chars val:'\tcheck_detached\n' span_id:199) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout branch by full name detaches' span_id:206))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:210) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:211) (Token id:Id.Lit_Chars val:'\tgit checkout refs/heads/branch &&\n' span_id:212) (Token id:Id.Lit_Chars val:'\tcheck_detached\n' span_id:213) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout non-ref detaches' span_id:220))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:224) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:225) (Token id:Id.Lit_Chars val:'\tgit checkout branch^ &&\n' span_id:226) (Token id:Id.Lit_Chars val:'\tcheck_detached\n' span_id:227) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout ref^0 detaches' span_id:234))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:238) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:239) (Token id:Id.Lit_Chars val:'\tgit checkout branch^0 &&\n' span_id:240) (Token id:Id.Lit_Chars val:'\tcheck_detached\n' span_id:241) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout --detach detaches' span_id:248))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:252) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:253) (Token id:Id.Lit_Chars val:'\tgit checkout --detach branch &&\n' span_id:254) (Token id:Id.Lit_Chars val:'\tcheck_detached\n' span_id:255) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout --detach without branch name' span_id:262))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:266) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:267) (Token id:Id.Lit_Chars val:'\tgit checkout --detach &&\n' span_id:268) (Token id:Id.Lit_Chars val:'\tcheck_detached\n' span_id:269) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout --detach errors out for non-commit' span_id:276))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:280) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:281) (Token id:Id.Lit_Chars val:'\ttest_must_fail git checkout --detach one^{tree} &&\n' span_id:282) (Token id:Id.Lit_Chars val:'\tcheck_not_detached\n' span_id:283) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout --detach errors out for extra argument' span_id:290))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:294) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:295) (Token id:Id.Lit_Chars val:'\tgit checkout master &&\n' span_id:296) (Token id: Id.Lit_Chars val: '\ttest_must_fail git checkout --detach tag one.t &&\n' span_id: 297 ) (Token id:Id.Lit_Chars val:'\tcheck_not_detached\n' span_id:298) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout --detached and -b are incompatible' span_id:305))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:309) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:310) (Token id: Id.Lit_Chars val: '\ttest_must_fail git checkout --detach -b newbranch tag &&\n' span_id: 311 ) (Token id:Id.Lit_Chars val:'\tcheck_not_detached\n' span_id:312) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout --detach moves HEAD' span_id:319))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:323) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:324) (Token id:Id.Lit_Chars val:'\tgit checkout one &&\n' span_id:325) (Token id:Id.Lit_Chars val:'\tgit checkout --detach two &&\n' span_id:326) (Token id:Id.Lit_Chars val:'\tgit diff --exit-code HEAD &&\n' span_id:327) (Token id:Id.Lit_Chars val:'\tgit diff --exit-code two\n' span_id:328) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout warns on orphan commits' span_id:335))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:339) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:340) (Token id:Id.Lit_Chars val:'\tgit checkout --detach two &&\n' span_id:341) (Token id:Id.Lit_Chars val:'\techo content >orphan &&\n' span_id:342) (Token id:Id.Lit_Chars val:'\tgit add orphan &&\n' span_id:343) (Token id:Id.Lit_Chars val:'\tgit commit -a -m orphan1 &&\n' span_id:344) (Token id:Id.Lit_Chars val:'\techo new content >orphan &&\n' span_id:345) (Token id:Id.Lit_Chars val:'\tgit commit -a -m orphan2 &&\n' span_id:346) (Token id:Id.Lit_Chars val:'\torphan2=$(git rev-parse HEAD) &&\n' span_id:347) (Token id:Id.Lit_Chars val:'\tgit checkout master 2>stderr\n' span_id:348) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout warns on orphan commits: output' span_id:355))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:359) (Token id: Id.Lit_Chars val: '\tcheck_orphan_warning stderr "2 commits"\n' span_id: 360 ) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout warns orphaning 1 of 2 commits' span_id:367))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:371) (Token id:Id.Lit_Chars val:'\tgit checkout "$orphan2" &&\n' span_id:372) (Token id:Id.Lit_Chars val:'\tgit checkout HEAD^ 2>stderr\n' span_id:373) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout warns orphaning 1 of 2 commits: output' span_id:380))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:384) (Token id: Id.Lit_Chars val: '\tcheck_orphan_warning stderr "1 commit"\n' span_id: 385 ) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout does not warn leaving ref tip' span_id:392))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:396) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:397) (Token id:Id.Lit_Chars val:'\tgit checkout --detach two &&\n' span_id:398) (Token id:Id.Lit_Chars val:'\tgit checkout master 2>stderr\n' span_id:399) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout does not warn leaving ref tip' span_id:406))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:410) (Token id:Id.Lit_Chars val:'\tcheck_no_orphan_warning stderr\n' span_id:411) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout does not warn leaving reachable commit' span_id:418))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:422) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:423) (Token id:Id.Lit_Chars val:'\tgit checkout --detach HEAD^ &&\n' span_id:424) (Token id:Id.Lit_Chars val:'\tgit checkout master 2>stderr\n' span_id:425) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'checkout does not warn leaving reachable commit' span_id:432))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:436) (Token id:Id.Lit_Chars val:'\tcheck_no_orphan_warning stderr\n' span_id:437) ) } ) (command.Simple words: [{(cat)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:443) fd: -1 arg_word: {(expect)} ) (redir.HereDoc op: (Token id:Id.Redir_DLess val:'<<' span_id:446) fd: -1 here_begin: {(SQ (Token id:Id.Lit_Chars val:EOF span_id:448))} here_end_span_id: 453 stdin_parts: [ ("Your branch is behind 'master' by 1 commit, and can be fast-forwarded.\n") (' (use "git pull" to update your local branch)\n') ] ) ] ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'tracking count is accurate after orphan check' span_id:457))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:461) (Token id:Id.Lit_Chars val:'\treset &&\n' span_id:462) (Token id:Id.Lit_Chars val:'\tgit branch child master^ &&\n' span_id:463) (Token id:Id.Lit_Chars val:'\tgit config branch.child.remote . &&\n' span_id:464) (Token id:Id.Lit_Chars val:'\tgit config branch.child.merge refs/heads/master &&\n' span_id:465) (Token id:Id.Lit_Chars val:'\tgit checkout child^ &&\n' span_id:466) (Token id:Id.Lit_Chars val:'\tgit checkout child >stdout &&\n' span_id:467) (Token id:Id.Lit_Chars val:'\ttest_i18ncmp expect stdout\n' span_id:468) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'no advice given for explicit detached head state' span_id: 475 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:479) (Token id:Id.Lit_Chars val:'\t# baseline\n' span_id:480) (Token id:Id.Lit_Chars val:'\ttest_config advice.detachedHead true &&\n' span_id:481) (Token id: Id.Lit_Chars val: '\tgit checkout child && git checkout HEAD^0 >expect.advice 2>&1 &&\n' span_id: 482 ) (Token id:Id.Lit_Chars val:'\ttest_config advice.detachedHead false &&\n' span_id:483) (Token id: Id.Lit_Chars val: '\tgit checkout child && git checkout HEAD^0 >expect.no-advice 2>&1 &&\n' span_id: 484 ) (Token id:Id.Lit_Chars val:'\ttest_unconfig advice.detachedHead &&\n' span_id:485) (Token id: Id.Lit_Chars val: '\t# without configuration, the advice.* variables default to true\n' span_id: 486 ) (Token id: Id.Lit_Chars val: '\tgit checkout child && git checkout HEAD^0 >actual 2>&1 &&\n' span_id: 487 ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect.advice actual &&\n' span_id:488) (Token id:Id.Lit_Chars val:'\n' span_id:489) (Token id:Id.Lit_Chars val:'\t# with explicit --detach\n' span_id:490) (Token id:Id.Lit_Chars val:'\t# no configuration\n' span_id:491) (Token id:Id.Lit_Chars val:'\ttest_unconfig advice.detachedHead &&\n' span_id:492) (Token id: Id.Lit_Chars val: '\tgit checkout child && git checkout --detach HEAD^0 >actual 2>&1 &&\n' span_id: 493 ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect.no-advice actual &&\n' span_id:494) (Token id:Id.Lit_Chars val:'\n' span_id:495) (Token id:Id.Lit_Chars val:'\t# explicitly decline advice\n' span_id:496) (Token id: Id.Lit_Chars val: '\ttest_config advice.detachedHead false &&\n' span_id: 497 ) (Token id: Id.Lit_Chars val: '\tgit checkout child && git checkout --detach HEAD^0 >actual 2>&1 &&\n' span_id: 498 ) (Token id:Id.Lit_Chars val:'\ttest_cmp expect.no-advice actual\n' span_id:499) ) } ) (C {(test_done)}) ] )