(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description) op: Equal rhs: {(SQ <'GIT_EDITOR, core.editor, and stuff'>)} ) ] ) (C {(.)} {(./test-lib.sh)}) (C {(unset)} {(EDITOR)} {(VISUAL)} {(GIT_EDITOR)}) (C {(test_expect_success)} {(SQ <'determine default editor'>)} {(SQ <'\n'> <'\n'> <'\tvi=$(TERM=vt100 git var GIT_EDITOR) &&\n'> <'\ttest -n "$vi"\n'> <'\n'>)} ) (command.If arms: [ (if_arm cond: [ (command.Pipeline children: [ (command.SimpleCommand words: [{(expr)} {(DQ ($ VSub_DollarName '$vi'))} {(Lit_Other ':')} {(SQ <'[a-z]*$'>)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})] ) ] negated: T ) ] action: [ (command.Assignment keyword: Assign_None pairs: [(assign_pair lhs:(lhs_expr.LhsName name:vi) op:Equal rhs:(word.EmptyWord))] ) ] ) ] ) (command.ForEach iter_name: i iter_words: [{(GIT_EDITOR)} {(core_editor)} {(EDITOR)} {(VISUAL)} {($ VSub_DollarName '$vi')}] do_arg_iter: F body: (command.DoGroup children: [ (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(e-) ($ VSub_DollarName '$i') (.sh)} ) (redir.HereDoc op: <Redir_DLessDash '<<-'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 110 stdin_parts: [ ('#!') ($ VSub_DollarName '$SHELL_PATH') ('\n') ('echo ') (Right_DoubleQuote '"') ('Edited by ') ($ VSub_DollarName '$i') (Right_DoubleQuote '"') (' >') (Right_DoubleQuote '"') (word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\$'>) (1) (Right_DoubleQuote '"') ('\n') ] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(e-) ($ VSub_DollarName '$i') (.sh)}) ] ) ) (command.If arms: [ (if_arm cond: [ (command.Pipeline children: [(C {(test)} {(-z)} {(DQ ($ VSub_DollarName '$vi'))})] negated: T ) ] action: [(C {(mv)} {(e-) ($ VSub_DollarName '$vi') (.sh)} {($ VSub_DollarName '$vi')})] ) ] ) (C {(test_expect_success)} {(setup)} { (SQ <'\n'> <'\n'> <'\tmsg="Hand-edited" &&\n'> <'\ttest_commit "$msg" &&\n'> <'\techo "$msg" >expect &&\n'> <'\tgit show -s --format=%s > actual &&\n'> <'\ttest_cmp actual expect\n'> <'\n'> ) } ) (command.Assignment keyword: Assign_None pairs: [(assign_pair lhs:(lhs_expr.LhsName name:TERM) op:Equal rhs:{(dumb)})] ) (C {(export)} {(TERM)}) (C {(test_expect_success)} {(SQ <'dumb should error out when falling back on vi'>)} { (SQ <'\n'> <'\n'> <'\tif git commit --amend\n'> <'\tthen\n'> <'\t\techo "Oops?"\n'> <'\t\tfalse\n'> <'\telse\n'> <'\t\t: happy\n'> <'\tfi\n'> ) } ) (C {(test_expect_success)} {(SQ <'dumb should prefer EDITOR to VISUAL'>)} { (SQ <'\n'> <'\n'> <'\tEDITOR=./e-EDITOR.sh &&\n'> <'\tVISUAL=./e-VISUAL.sh &&\n'> <'\texport EDITOR VISUAL &&\n'> <'\tgit commit --amend &&\n'> <'\ttest "$(git show -s --format=%s)" = "Edited by EDITOR"\n'> <'\n'> ) } ) (command.Assignment keyword: Assign_None pairs: [(assign_pair lhs:(lhs_expr.LhsName name:TERM) op:Equal rhs:{(vt100)})] ) (C {(export)} {(TERM)}) (command.ForEach iter_name: i iter_words: [{($ VSub_DollarName '$vi')} {(EDITOR)} {(VISUAL)} {(core_editor)} {(GIT_EDITOR)}] do_arg_iter: F body: (command.DoGroup children: [ (command.SimpleCommand words: [{(echo)} {(DQ ('Edited by ') ($ VSub_DollarName '$i'))}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})] ) (C {(unset)} {(EDITOR)} {(VISUAL)} {(GIT_EDITOR)}) (C {(git)} {(config)} {(--unset-all)} {(core.editor)}) (command.Case to_match: {(DQ ($ VSub_DollarName '$i'))} arms: [ (case_arm pat_list: [{(core_editor)}] action: [(C {(git)} {(config)} {(core.editor)} {(./e-core_editor.sh)})] ) (case_arm pat_list: [{(Lit_Other '[') (A-Z) (Lit_Other ']') (Lit_Other '*')}] action: [ (C {(eval)} {(DQ ($ VSub_DollarName '$i') ('=./e-') ($ VSub_DollarName '$i') (.sh))}) (C {(export)} {($ VSub_DollarName '$i')}) ] ) ] ) (C {(test_expect_success)} {(DQ ('Using ') ($ VSub_DollarName '$i'))} { (SQ <'\n'> <'\t\tgit --exec-path=. commit --amend &&\n'> <'\t\tgit show -s --pretty=oneline |\n'> <'\t\tsed -e "s/^[0-9a-f]* //" >actual &&\n'> <'\t\ttest_cmp actual expect\n'> <'\t'> ) } ) ] ) ) (C {(unset)} {(EDITOR)} {(VISUAL)} {(GIT_EDITOR)}) (C {(git)} {(config)} {(--unset-all)} {(core.editor)}) (command.ForEach iter_name: i iter_words: [{($ VSub_DollarName '$vi')} {(EDITOR)} {(VISUAL)} {(core_editor)} {(GIT_EDITOR)}] do_arg_iter: F body: (command.DoGroup children: [ (command.SimpleCommand words: [{(echo)} {(DQ ('Edited by ') ($ VSub_DollarName '$i'))}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})] ) (command.Case to_match: {(DQ ($ VSub_DollarName '$i'))} arms: [ (case_arm pat_list: [{(core_editor)}] action: [(C {(git)} {(config)} {(core.editor)} {(./e-core_editor.sh)})] ) (case_arm pat_list: [{(Lit_Other '[') (A-Z) (Lit_Other ']') (Lit_Other '*')}] action: [ (C {(eval)} {(DQ ($ VSub_DollarName '$i') ('=./e-') ($ VSub_DollarName '$i') (.sh))}) (C {(export)} {($ VSub_DollarName '$i')}) ] ) ] ) (C {(test_expect_success)} {(DQ ('Using ') ($ VSub_DollarName '$i') (' (override)'))} { (SQ <'\n'> <'\t\tgit --exec-path=. commit --amend &&\n'> <'\t\tgit show -s --pretty=oneline |\n'> <'\t\tsed -e "s/^[0-9a-f]* //" >actual &&\n'> <'\t\ttest_cmp actual expect\n'> <'\t'> ) } ) ] ) ) (command.If arms: [ (if_arm cond: [ (command.SimpleCommand words: [{(echo)} {(SQ <'echo space > "$1"'>)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(DQ ('e space.sh'))})] ) ] action: [(C {(test_set_prereq)} {(SPACES_IN_FILENAMES)})] ) ] ) (C {(test_expect_success)} {(SPACES_IN_FILENAMES)} {(SQ <'editor with a space'>)} { (SQ <'\n'> <'\n'> <'\tchmod a+x "e space.sh" &&\n'> <'\tGIT_EDITOR="./e\\ space.sh" git commit --amend &&\n'> <'\ttest space = "$(git show -s --pretty=format:%s)"\n'> <'\n'> ) } ) (C {(unset)} {(GIT_EDITOR)}) (C {(test_expect_success)} {(SPACES_IN_FILENAMES)} {(SQ <'core.editor with a space'>)} { (SQ <'\n'> <'\n'> <'\tgit config core.editor \\"./e\\ space.sh\\" &&\n'> <'\tgit commit --amend &&\n'> <'\ttest space = "$(git show -s --pretty=format:%s)"\n'> <'\n'> ) } ) (C {(test_done)}) ] )