38ac05e4a0b62e9105a400b4583d5504b42b3e7d
   1#!/bin/sh
   2
   3test_description='git cat-file textconv support'
   4. ./test-lib.sh
   5
   6cat >helper <<'EOF'
   7#!/bin/sh
   8sed 's/^/converted: /' "$@"
   9EOF
  10chmod +x helper
  11
  12test_expect_success 'setup ' '
  13        echo test >one.bin &&
  14        git add . &&
  15        GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
  16        echo test version 2 >one.bin &&
  17        GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
  18'
  19
  20cat >expected <<EOF
  21fatal: git cat-file --textconv: unable to run textconv on :one.bin
  22EOF
  23
  24test_expect_success 'no filter specified' '
  25        git cat-file --textconv :one.bin 2>result
  26        test_cmp expected result
  27'
  28
  29test_expect_success 'setup textconv filters' '
  30        echo "*.bin diff=test" >.gitattributes &&
  31        git config diff.test.textconv ./helper &&
  32        git config diff.test.cachetextconv false
  33'
  34
  35cat >expected <<EOF
  36test version 2
  37EOF
  38
  39test_expect_success 'cat-file without --textconv' '
  40        git cat-file blob :one.bin >result &&
  41        test_cmp expected result
  42'
  43
  44cat >expected <<EOF
  45test
  46EOF
  47
  48test_expect_success 'cat-file without --textconv on previous commit' '
  49        git cat-file -p HEAD^:one.bin >result &&
  50        test_cmp expected result
  51'
  52
  53cat >expected <<EOF
  54converted: test version 2
  55EOF
  56
  57test_expect_success 'cat-file --textconv on last commit' '
  58        git cat-file --textconv :one.bin >result &&
  59        test_cmp expected result
  60'
  61
  62cat >expected <<EOF
  63converted: test
  64EOF
  65
  66test_expect_success 'cat-file --textconv on previous commit' '
  67        git cat-file --textconv HEAD^:one.bin >result &&
  68        test_cmp expected result
  69'
  70test_done