(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: 'test git rev-parse diagnosis for invalid argument' span_id: 6 ) ) } spids: [4] ) ] ) (command.Simple words: [{(exec)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Less val:'<' span_id:12) fd: -1 arg_word: {(/dev/null)} ) ] ) (C {(.)} {(./test-lib.sh)}) (command.ShFunction name: test_did_you_mean body: (command.BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp] children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:sq) op: assign_op.Equal rhs: {(DQ ("'"))} spids: [29] ) ] ) (command.Simple words: [{(cat)}] redirects: [ (redir.Redir op: (Token id:Id.Redir_Great val:'>' span_id:39) fd: -1 arg_word: {(expected)} ) (redir.HereDoc op: (Token id:Id.Redir_DLessDash val:'<<-' span_id:42) fd: -1 here_begin: {(EOF)} here_end_span_id: 80 stdin_parts: [ ("fatal: Path '") ($ Id.VSub_Number '$2') ($ Id.VSub_Number '$3') ("' ") ($ Id.VSub_Number '$4') (', but not ') (braced_var_sub token: (Token id:Id.VSub_Number val:5 span_id:54) suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonHyphen arg_word: {($ Id.VSub_DollarName '$sq') ($ Id.VSub_Number '$3') ($ Id.VSub_DollarName '$sq') } ) ) ('.\n') ("Did you mean '") ($ Id.VSub_Number '$1') (':') ($ Id.VSub_Number '$2') ($ Id.VSub_Number '$3') ("'") (braced_var_sub token: (Token id:Id.VSub_Number val:2 span_id:68) suffix_op: (suffix_op.Unary op_id: Id.VTest_ColonPlus arg_word: {(' aka ') ($ Id.VSub_DollarName '$sq') ($ Id.VSub_Number '$1') (':.') (Id.Lit_Slash /) ($ Id.VSub_Number '$3') ($ Id.VSub_DollarName '$sq') } ) ) ('?\n') ] ) ] ) (C {(test_cmp)} {(expected)} {(error)}) ] ) ] ) ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:HASH_file) op: assign_op.Equal rhs: (word.Empty) spids: [91] ) ] ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'set up basic repo' span_id:97))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:101) (Token id:Id.Lit_Chars val:'\techo one > file.txt &&\n' span_id:102) (Token id:Id.Lit_Chars val:'\tmkdir subdir &&\n' span_id:103) (Token id:Id.Lit_Chars val:'\techo two > subdir/file.txt &&\n' span_id:104) (Token id:Id.Lit_Chars val:'\techo three > subdir/file2.txt &&\n' span_id:105) (Token id:Id.Lit_Chars val:'\tgit add . &&\n' span_id:106) (Token id:Id.Lit_Chars val:'\tgit commit -m init &&\n' span_id:107) (Token id:Id.Lit_Chars val:'\techo four > index-only.txt &&\n' span_id:108) (Token id:Id.Lit_Chars val:'\tgit add index-only.txt &&\n' span_id:109) (Token id:Id.Lit_Chars val:'\techo five > disk-only.txt\n' span_id:110) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'correct file objects' span_id:117))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:121) (Token id: Id.Lit_Chars val: '\tHASH_file=$(git rev-parse HEAD:file.txt) &&\n' span_id: 122 ) (Token id:Id.Lit_Chars val:'\tgit rev-parse HEAD:subdir/file.txt &&\n' span_id:123) (Token id:Id.Lit_Chars val:'\tgit rev-parse :index-only.txt &&\n' span_id:124) (Token id:Id.Lit_Chars val:'\t(cd subdir &&\n' span_id:125) (Token id: Id.Lit_Chars val: '\t git rev-parse HEAD:subdir/file2.txt &&\n' span_id: 126 ) (Token id:Id.Lit_Chars val:'\t test $HASH_file = $(git rev-parse HEAD:file.txt) &&\n' span_id:127) (Token id: Id.Lit_Chars val: '\t test $HASH_file = $(git rev-parse :file.txt) &&\n' span_id: 128 ) (Token id:Id.Lit_Chars val:'\t test $HASH_file = $(git rev-parse :0:file.txt) )\n' span_id:129) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'correct relative file objects (0)' span_id:136))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:140) (Token id: Id.Lit_Chars val: '\tgit rev-parse :file.txt >expected &&\n' span_id: 141 ) (Token id:Id.Lit_Chars val:'\tgit rev-parse :./file.txt >result &&\n' span_id:142) (Token id:Id.Lit_Chars val:'\ttest_cmp expected result &&\n' span_id:143) (Token id:Id.Lit_Chars val:'\tgit rev-parse :0:./file.txt >result &&\n' span_id:144) (Token id:Id.Lit_Chars val:'\ttest_cmp expected result\n' span_id:145) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'correct relative file objects (1)' span_id:152))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:156) (Token id: Id.Lit_Chars val: '\tgit rev-parse HEAD:file.txt >expected &&\n' span_id: 157 ) (Token id:Id.Lit_Chars val:'\tgit rev-parse HEAD:./file.txt >result &&\n' span_id:158) (Token id:Id.Lit_Chars val:'\ttest_cmp expected result\n' span_id:159) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'correct relative file objects (2)' span_id:166))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:170) (Token id:Id.Lit_Chars val:'\t(\n' span_id:171) (Token id:Id.Lit_Chars val:'\t\tcd subdir &&\n' span_id:172) (Token id: Id.Lit_Chars val: '\t\tgit rev-parse HEAD:../file.txt >result &&\n' span_id: 173 ) (Token id:Id.Lit_Chars val:'\t\ttest_cmp ../expected result\n' span_id:174) (Token id:Id.Lit_Chars val:'\t)\n' span_id:175) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'correct relative file objects (3)' span_id:182))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:186) (Token id:Id.Lit_Chars val:'\t(\n' span_id:187) (Token id:Id.Lit_Chars val:'\t\tcd subdir &&\n' span_id:188) (Token id: Id.Lit_Chars val: '\t\tgit rev-parse HEAD:../subdir/../file.txt >result &&\n' span_id: 189 ) (Token id:Id.Lit_Chars val:'\t\ttest_cmp ../expected result\n' span_id:190) (Token id:Id.Lit_Chars val:'\t)\n' span_id:191) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'correct relative file objects (4)' span_id:198))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:202) (Token id: Id.Lit_Chars val: '\tgit rev-parse HEAD:subdir/file.txt >expected &&\n' span_id: 203 ) (Token id:Id.Lit_Chars val:'\t(\n' span_id:204) (Token id:Id.Lit_Chars val:'\t\tcd subdir &&\n' span_id:205) (Token id:Id.Lit_Chars val:'\t\tgit rev-parse HEAD:./file.txt >result &&\n' span_id:206) (Token id:Id.Lit_Chars val:'\t\ttest_cmp ../expected result\n' span_id:207) (Token id:Id.Lit_Chars val:'\t)\n' span_id:208) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'correct relative file objects (5)' span_id:215))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:219) (Token id: Id.Lit_Chars val: '\tgit rev-parse :subdir/file.txt >expected &&\n' span_id: 220 ) (Token id:Id.Lit_Chars val:'\t(\n' span_id:221) (Token id:Id.Lit_Chars val:'\t\tcd subdir &&\n' span_id:222) (Token id:Id.Lit_Chars val:'\t\tgit rev-parse :./file.txt >result &&\n' span_id:223) (Token id:Id.Lit_Chars val:'\t\ttest_cmp ../expected result &&\n' span_id:224) (Token id:Id.Lit_Chars val:'\t\tgit rev-parse :0:./file.txt >result &&\n' span_id:225) (Token id:Id.Lit_Chars val:'\t\ttest_cmp ../expected result\n' span_id:226) (Token id:Id.Lit_Chars val:'\t)\n' span_id:227) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'correct relative file objects (6)' span_id:234))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:238) (Token id: Id.Lit_Chars val: '\tgit rev-parse :file.txt >expected &&\n' span_id: 239 ) (Token id:Id.Lit_Chars val:'\t(\n' span_id:240) (Token id:Id.Lit_Chars val:'\t\tcd subdir &&\n' span_id:241) (Token id:Id.Lit_Chars val:'\t\tgit rev-parse :../file.txt >result &&\n' span_id:242) (Token id:Id.Lit_Chars val:'\t\ttest_cmp ../expected result &&\n' span_id:243) (Token id:Id.Lit_Chars val:'\t\tgit rev-parse :0:../file.txt >result &&\n' span_id:244) (Token id:Id.Lit_Chars val:'\t\ttest_cmp ../expected result\n' span_id:245) (Token id:Id.Lit_Chars val:'\t)\n' span_id:246) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'incorrect revision id' span_id:253))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:257) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse foobar:file.txt 2>error &&\n' span_id: 258 ) (Token id:Id.Lit_Chars val:'\tgrep "Invalid object name ' span_id:259) ) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:foobar span_id:265)) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:'." error &&\n' span_id:271) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse foobar 2> error &&\n' span_id: 272 ) (Token id: Id.Lit_Chars val: '\ttest_i18ngrep "unknown revision or path not in the working tree." error\n' span_id: 273 ) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'incorrect file in sha1:path' span_id:280))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:284) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse HEAD:nothing.txt 2> error &&\n' span_id: 285 ) (Token id:Id.Lit_Chars val:'\tgrep "fatal: Path ' span_id:286) ) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:nothing.txt span_id:292)) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:' does not exist in ' span_id:298)) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:HEAD span_id:304)) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:'" error &&\n' span_id:310) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse HEAD:index-only.txt 2> error &&\n' span_id: 311 ) (Token id:Id.Lit_Chars val:'\tgrep "fatal: Path ' span_id:312) ) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:index-only.txt span_id:318)) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:' exists on disk, but not in ' span_id:324)) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:HEAD span_id:330)) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:'." error &&\n' span_id:336) (Token id:Id.Lit_Chars val:'\t(cd subdir &&\n' span_id:337) (Token id: Id.Lit_Chars val: '\t test_must_fail git rev-parse HEAD:file2.txt 2> error &&\n' span_id: 338 ) (Token id:Id.Lit_Chars val:'\t test_did_you_mean HEAD subdir/ file2.txt exists )\n' span_id:339) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'incorrect file in :path and :N:path' span_id:346))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:350) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse :nothing.txt 2> error &&\n' span_id: 351 ) (Token id:Id.Lit_Chars val:'\tgrep "fatal: Path ' span_id:352) ) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:nothing.txt span_id:358)) (DQ ("'")) (SQ (Token id: Id.Lit_Chars val: ' does not exist (neither on disk nor in the index)." error &&\n' span_id: 364 ) (Token id:Id.Lit_Chars val:'\ttest_must_fail git rev-parse :1:nothing.txt 2> error &&\n' span_id:365) (Token id:Id.Lit_Chars val:'\tgrep "Path ' span_id:366) ) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:nothing.txt span_id:372)) (DQ ("'")) (SQ (Token id: Id.Lit_Chars val: ' does not exist (neither on disk nor in the index)." error &&\n' span_id: 378 ) (Token id:Id.Lit_Chars val:'\ttest_must_fail git rev-parse :1:file.txt 2> error &&\n' span_id:379) (Token id: Id.Lit_Chars val: '\ttest_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&\n' span_id: 380 ) (Token id:Id.Lit_Chars val:'\t(cd subdir &&\n' span_id:381) (Token id: Id.Lit_Chars val: '\t test_must_fail git rev-parse :1:file.txt 2> error &&\n' span_id: 382 ) (Token id: Id.Lit_Chars val: '\t test_did_you_mean ":0" "" file.txt "is in the index" "at stage 1" &&\n' span_id: 383 ) (Token id:Id.Lit_Chars val:'\t test_must_fail git rev-parse :file2.txt 2> error &&\n' span_id:384) (Token id: Id.Lit_Chars val: '\t test_did_you_mean ":0" subdir/ file2.txt "is in the index" &&\n' span_id: 385 ) (Token id:Id.Lit_Chars val:'\t test_must_fail git rev-parse :2:file2.txt 2> error &&\n' span_id:386) (Token id: Id.Lit_Chars val: '\t test_did_you_mean :0 subdir/ file2.txt "is in the index") &&\n' span_id: 387 ) (Token id:Id.Lit_Chars val:'\ttest_must_fail git rev-parse :disk-only.txt 2> error &&\n' span_id:388) (Token id:Id.Lit_Chars val:'\tgrep "fatal: Path ' span_id:389) ) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:disk-only.txt span_id:395)) (DQ ("'")) (SQ (Token id:Id.Lit_Chars val:' exists on disk, but not in the index." error\n' span_id:401)) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'invalid @{n} reference' span_id:408))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:412) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse master@{99999} >output 2>error &&\n' span_id: 413 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(cat output)" &&\n' span_id:414) (Token id: Id.Lit_Chars val: '\tgrep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error &&\n' span_id: 415 ) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse --verify master@{99999} >output 2>error &&\n' span_id: 416 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(cat output)" &&\n' span_id:417) (Token id: Id.Lit_Chars val: '\tgrep "fatal: Log for [^ ]* only has [0-9][0-9]* entries." error\n' span_id: 418 ) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'relative path not found' span_id:425))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:429) (Token id:Id.Lit_Chars val:'\t(\n' span_id:430) (Token id:Id.Lit_Chars val:'\t\tcd subdir &&\n' span_id:431) (Token id: Id.Lit_Chars val: '\t\ttest_must_fail git rev-parse HEAD:./nonexistent.txt 2>error &&\n' span_id: 432 ) (Token id:Id.Lit_Chars val:'\t\tgrep subdir/nonexistent.txt error\n' span_id:433) (Token id:Id.Lit_Chars val:'\t)\n' span_id:434) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'relative path outside worktree' span_id:441))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:445) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse HEAD:../file.txt >output 2>error &&\n' span_id: 446 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(cat output)" &&\n' span_id:447) (Token id:Id.Lit_Chars val:'\tgrep "outside repository" error\n' span_id:448) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'relative path when cwd is outside worktree' span_id:455))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:459) (Token id: Id.Lit_Chars val: '\ttest_must_fail git --git-dir=.git --work-tree=subdir rev-parse HEAD:./file.txt >output 2>error &&\n' span_id: 460 ) (Token id:Id.Lit_Chars val:'\ttest -z "$(cat output)" &&\n' span_id:461) (Token id: Id.Lit_Chars val: '\tgrep "relative path syntax can.t be used outside working tree." error\n' span_id: 462 ) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: '<commit>:file correctly diagnosed after a pathname' span_id: 469 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:473) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse file.txt HEAD:file.txt 1>actual 2>error &&\n' span_id: 474 ) (Token id:Id.Lit_Chars val:'\ttest_i18ngrep ! "exists on disk" error &&\n' span_id:475) (Token id: Id.Lit_Chars val: '\ttest_i18ngrep "no such path in the working tree" error &&\n' span_id: 476 ) (Token id:Id.Lit_Chars val:'\tcat >expect <<-\\EOF &&\n' span_id:477) (Token id:Id.Lit_Chars val:'\tfile.txt\n' span_id:478) (Token id:Id.Lit_Chars val:'\tHEAD:file.txt\n' span_id:479) (Token id:Id.Lit_Chars val:'\tEOF\n' span_id:480) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:481) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'dotdot is not an empty set' span_id:488))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:492) (Token id: Id.Lit_Chars val: '\t( H=$(git rev-parse HEAD) && echo $H && echo ^$H ) >expect &&\n' span_id: 493 ) (Token id:Id.Lit_Chars val:'\n' span_id:494) (Token id:Id.Lit_Chars val:'\tgit rev-parse HEAD.. >actual &&\n' span_id:495) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual &&\n' span_id:496) (Token id:Id.Lit_Chars val:'\n' span_id:497) (Token id:Id.Lit_Chars val:'\tgit rev-parse ..HEAD >actual &&\n' span_id:498) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual &&\n' span_id:499) (Token id:Id.Lit_Chars val:'\n' span_id:500) (Token id:Id.Lit_Chars val:'\techo .. >expect &&\n' span_id:501) (Token id:Id.Lit_Chars val:'\tgit rev-parse .. >actual &&\n' span_id:502) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:503) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'arg before dashdash must be a revision (missing)' span_id: 510 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:514) (Token id: Id.Lit_Chars val: '\ttest_must_fail git rev-parse foobar -- 2>stderr &&\n' span_id: 515 ) (Token id:Id.Lit_Chars val:'\ttest_i18ngrep "bad revision" stderr\n' span_id:516) ) } ) (C {(test_expect_success)} {(SQ (Token id:Id.Lit_Chars val:'arg before dashdash must be a revision (file)' span_id:523))} { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:527) (Token id:Id.Lit_Chars val:'\t>foobar &&\n' span_id:528) (Token id:Id.Lit_Chars val:'\ttest_must_fail git rev-parse foobar -- 2>stderr &&\n' span_id:529) (Token id:Id.Lit_Chars val:'\ttest_i18ngrep "bad revision" stderr\n' span_id:530) ) } ) (C {(test_expect_success)} { (SQ (Token id: Id.Lit_Chars val: 'arg before dashdash must be a revision (ambiguous)' span_id: 537 ) ) } { (SQ (Token id:Id.Lit_Chars val:'\n' span_id:541) (Token id:Id.Lit_Chars val:'\t>foobar &&\n' span_id:542) (Token id:Id.Lit_Chars val:'\tgit update-ref refs/heads/foobar HEAD &&\n' span_id:543) (Token id:Id.Lit_Chars val:'\t{\n' span_id:544) (Token id:Id.Lit_Chars val:'\t\t# we do not want to use rev-parse here, because\n' span_id:545) (Token id:Id.Lit_Chars val:'\t\t# we are testing it\n' span_id:546) (Token id:Id.Lit_Chars val:'\t\tcat .git/refs/heads/foobar &&\n' span_id:547) (Token id:Id.Lit_Chars val:'\t\tprintf "%s\\n" --\n' span_id:548) (Token id:Id.Lit_Chars val:'\t} >expect &&\n' span_id:549) (Token id:Id.Lit_Chars val:'\tgit rev-parse foobar -- >actual &&\n' span_id:550) (Token id:Id.Lit_Chars val:'\ttest_cmp expect actual\n' span_id:551) ) } ) (C {(test_done)}) ] )