Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t7005-editor.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t7005-editor.sh` 102 lines ยท 2086 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='GIT_EDITOR, core.editor, and stuff' 4 5 . ./test-lib.sh 6 7 unset EDITOR VISUAL GIT_EDITOR 8 9 test_expect_success 'determine default editor' ' 10 vi=$(TERM=vt100 git var GIT_EDITOR) && 11 test -n "$vi" 12 ' 13 14 test_expect_success setup ' 15 if ! expr "$vi" : "[a-z]*$" >/dev/null 16 then 17 vi= 18 fi && 19 20 for i in GIT_EDITOR core_editor EDITOR VISUAL $vi 21 do 22 write_script e-$i.sh <<-EOF || return 1 23 echo "Edited by $i" >"\$1" 24 EOF 25 done && 26 27 if ! test -z "$vi" 28 then 29 mv e-$vi.sh $vi 30 fi && 31 32 msg="Hand-edited" && 33 test_commit "$msg" && 34 test_commit_message HEAD -m "$msg" 35 ' 36 37 test_expect_success 'dumb should error out when falling back on vi' ' 38 test_must_fail env TERM=dumb git commit --amend 39 ' 40 41 test_expect_success 'dumb should prefer EDITOR to VISUAL' ' 42 TERM=dumb EDITOR=./e-EDITOR.sh VISUAL=./e-VISUAL.sh \ 43 git commit --amend && 44 test_commit_message HEAD -m "Edited by EDITOR" 45 ' 46 47 for i in $vi EDITOR VISUAL core_editor GIT_EDITOR 48 do 49 test_expect_success "Using $i" ' 50 if test "$i" = core_editor 51 then 52 test_config core.editor ./e-core_editor.sh 53 fi && 54 ( 55 case "$i" in 56 [A-Z]*) 57 eval "$i=./e-$i.sh" && 58 export $i 59 ;; 60 esac && 61 PATH="$PWD:$PATH" TERM=vt100 git commit --amend 62 ) && 63 test_commit_message HEAD -m "Edited by $i" 64 ' 65 done 66 67 test_expect_success 'Using editors with overrides' ' 68 ( 69 TERM=vt100 && 70 export TERM && 71 for i in $vi EDITOR VISUAL core_editor GIT_EDITOR 72 do 73 echo "Edited by $i" >expect && 74 case "$i" in 75 core_editor) 76 git config core.editor ./e-core_editor.sh 77 ;; 78 [A-Z]*) 79 eval "$i=./e-$i.sh" && 80 export $i 81 ;; 82 esac && 83 PATH="$PWD:$PATH" git commit --amend && 84 test_commit_message HEAD expect || exit 1 85 done 86 ) 87 ' 88 89 test_expect_success 'editor with a space' ' 90 echo "echo space >\"\$1\"" >"e space.sh" && 91 chmod a+x "e space.sh" && 92 GIT_EDITOR="./e\ space.sh" git commit --amend && 93 test_commit_message HEAD -m space 94 ' 95 96 test_expect_success 'core.editor with a space' ' 97 test_config core.editor \"./e\ space.sh\" && 98 git commit --amend && 99 test_commit_message HEAD -m space 100 ' 101 102 test_done