t / t8006-blame-textconv.shon commit diff: parse separate options like -S foo (dea007f)
   1#!/bin/sh
   2
   3test_description='git blame textconv support'
   4. ./test-lib.sh
   5
   6find_blame() {
   7        sed -e 's/^[^(]*//'
   8}
   9
  10cat >helper <<'EOF'
  11#!/bin/sh
  12sed 's/^/converted: /' "$@"
  13EOF
  14chmod +x helper
  15
  16test_expect_success 'setup ' '
  17        echo test 1 >one.bin &&
  18        echo test number 2 >two.bin &&
  19        git add . &&
  20        GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
  21        echo test 1 version 2 >one.bin &&
  22        echo test number 2 version 2 >>two.bin &&
  23        GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
  24'
  25
  26cat >expected <<EOF
  27(Number2 2010-01-01 20:00:00 +0000 1) test 1 version 2
  28EOF
  29
  30test_expect_success 'no filter specified' '
  31        git blame one.bin >blame &&
  32        find_blame Number2 <blame >result &&
  33        test_cmp expected result
  34'
  35
  36test_expect_success 'setup textconv filters' '
  37        echo "*.bin diff=test" >.gitattributes &&
  38        git config diff.test.textconv ./helper &&
  39        git config diff.test.cachetextconv false
  40'
  41
  42test_expect_success 'blame with --no-textconv' '
  43        git blame --no-textconv one.bin >blame &&
  44        find_blame <blame> result &&
  45        test_cmp expected result
  46'
  47
  48cat >expected <<EOF
  49(Number2 2010-01-01 20:00:00 +0000 1) converted: test 1 version 2
  50EOF
  51
  52test_expect_success 'basic blame on last commit' '
  53        git blame one.bin >blame &&
  54        find_blame  <blame >result &&
  55        test_cmp expected result
  56'
  57
  58cat >expected <<EOF
  59(Number1 2010-01-01 18:00:00 +0000 1) converted: test number 2
  60(Number2 2010-01-01 20:00:00 +0000 2) converted: test number 2 version 2
  61EOF
  62
  63test_expect_success 'blame --textconv going through revisions' '
  64        git blame --textconv two.bin >blame &&
  65        find_blame <blame >result &&
  66        test_cmp expected result
  67'
  68
  69test_expect_success 'make a new commit' '
  70        echo "test number 2 version 3" >>two.bin &&
  71        GIT_AUTHOR_NAME=Number3 git commit -a -m Third --date="2010-01-01 22:00:00"
  72'
  73
  74test_expect_success 'blame from previous revision' '
  75        git blame HEAD^ two.bin >blame &&
  76        find_blame <blame >result &&
  77        test_cmp expected result
  78'
  79
  80test_done