1#!/bin/sh
   2test_description='help.autocorrect finding a match'
   4. ./test-lib.sh
   5test_expect_success 'setup' '
   7        # An alias
   8        git config alias.lgf "log --format=%s --first-parent" &&
   9        # A random user-defined command
  11        write_script git-distimdistim <<-EOF &&
  12                echo distimdistim was called
  13        EOF
  14        PATH="$PATH:." &&
  16        export PATH &&
  17        git commit --allow-empty -m "a single log entry" &&
  19        # Sanity check
  21        git lgf >actual &&
  22        echo "a single log entry" >expect &&
  23        test_cmp expect actual &&
  24        git distimdistim >actual &&
  26        echo "distimdistim was called" >expect &&
  27        test_cmp expect actual
  28'
  29test_expect_success 'autocorrect showing candidates' '
  31        git config help.autocorrect 0 &&
  32        test_must_fail git lfg 2>actual &&
  34        sed -e "1,/^Did you mean this/d" actual | grep lgf &&
  35        test_must_fail git distimdist 2>actual &&
  37        sed -e "1,/^Did you mean this/d" actual | grep distimdistim
  38'
  39test_expect_success 'autocorrect running commands' '
  41        git config help.autocorrect -1 &&
  42        git lfg >actual &&
  44        echo "a single log entry" >expect &&
  45        test_cmp expect actual &&
  46        git distimdist >actual &&
  48        echo "distimdistim was called" >expect &&
  49        test_cmp expect actual
  50'
  51test_done