t / t7005-editor.shon commit xdl_merge(): introduce XDL_MERGE_ZEALOUS_ALNUM (ee95ec5)
   1#!/bin/sh
   2
   3test_description='GIT_EDITOR, core.editor, and stuff'
   4
   5. ./test-lib.sh
   6
   7OLD_TERM="$TERM"
   8
   9for i in GIT_EDITOR core_editor EDITOR VISUAL vi
  10do
  11        cat >e-$i.sh <<-EOF
  12        echo "Edited by $i" >"\$1"
  13        EOF
  14        chmod +x e-$i.sh
  15done
  16unset vi
  17mv e-vi.sh vi
  18unset EDITOR VISUAL GIT_EDITOR
  19
  20test_expect_success setup '
  21
  22        msg="Hand edited" &&
  23        echo "$msg" >expect &&
  24        git add vi &&
  25        test_tick &&
  26        git commit -m "$msg" &&
  27        git show -s --pretty=oneline |
  28        sed -e "s/^[0-9a-f]* //" >actual &&
  29        diff actual expect
  30
  31'
  32
  33TERM=dumb
  34export TERM
  35test_expect_success 'dumb should error out when falling back on vi' '
  36
  37        if git commit --amend
  38        then
  39                echo "Oops?"
  40                false
  41        else
  42                : happy
  43        fi
  44'
  45
  46TERM=vt100
  47export TERM
  48for i in vi EDITOR VISUAL core_editor GIT_EDITOR
  49do
  50        echo "Edited by $i" >expect
  51        unset EDITOR VISUAL GIT_EDITOR
  52        git config --unset-all core.editor
  53        case "$i" in
  54        core_editor)
  55                git config core.editor ./e-core_editor.sh
  56                ;;
  57        [A-Z]*)
  58                eval "$i=./e-$i.sh"
  59                export $i
  60                ;;
  61        esac
  62        test_expect_success "Using $i" '
  63                git --exec-path=. commit --amend &&
  64                git show -s --pretty=oneline |
  65                sed -e "s/^[0-9a-f]* //" >actual &&
  66                diff actual expect
  67        '
  68done
  69
  70unset EDITOR VISUAL GIT_EDITOR
  71git config --unset-all core.editor
  72for i in vi EDITOR VISUAL core_editor GIT_EDITOR
  73do
  74        echo "Edited by $i" >expect
  75        case "$i" in
  76        core_editor)
  77                git config core.editor ./e-core_editor.sh
  78                ;;
  79        [A-Z]*)
  80                eval "$i=./e-$i.sh"
  81                export $i
  82                ;;
  83        esac
  84        test_expect_success "Using $i (override)" '
  85                git --exec-path=. commit --amend &&
  86                git show -s --pretty=oneline |
  87                sed -e "s/^[0-9a-f]* //" >actual &&
  88                diff actual expect
  89        '
  90done
  91
  92TERM="$OLD_TERM"
  93
  94test_done