t / t8007-cat-file-textconv.shon commit Merge branch 'en/merge-fixes' (10b8084)
   1#!/bin/sh
   2
   3test_description='git cat-file textconv support'
   4. ./test-lib.sh
   5
   6cat >helper <<'EOF'
   7#!/bin/sh
   8grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
   9sed 's/^bin: /converted: /' "$1"
  10EOF
  11chmod +x helper
  12
  13test_expect_success 'setup ' '
  14        echo "bin: test" >one.bin &&
  15        test_ln_s_add one.bin symlink.bin &&
  16        git add . &&
  17        GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
  18        echo "bin: test version 2" >one.bin &&
  19        GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
  20'
  21
  22cat >expected <<EOF
  23bin: test version 2
  24EOF
  25
  26test_expect_success 'no filter specified' '
  27        git cat-file --textconv :one.bin >result &&
  28        test_cmp expected result
  29'
  30
  31test_expect_success 'setup textconv filters' '
  32        echo "*.bin diff=test" >.gitattributes &&
  33        git config diff.test.textconv ./helper &&
  34        git config diff.test.cachetextconv false
  35'
  36
  37test_expect_success 'cat-file without --textconv' '
  38        git cat-file blob :one.bin >result &&
  39        test_cmp expected result
  40'
  41
  42cat >expected <<EOF
  43bin: test
  44EOF
  45
  46test_expect_success 'cat-file without --textconv on previous commit' '
  47        git cat-file -p HEAD^:one.bin >result &&
  48        test_cmp expected result
  49'
  50
  51cat >expected <<EOF
  52converted: test version 2
  53EOF
  54
  55test_expect_success 'cat-file --textconv on last commit' '
  56        git cat-file --textconv :one.bin >result &&
  57        test_cmp expected result
  58'
  59
  60cat >expected <<EOF
  61converted: test
  62EOF
  63
  64test_expect_success 'cat-file --textconv on previous commit' '
  65        git cat-file --textconv HEAD^:one.bin >result &&
  66        test_cmp expected result
  67'
  68
  69test_expect_success 'cat-file without --textconv (symlink)' '
  70        printf "%s" "one.bin" >expected &&
  71        git cat-file blob :symlink.bin >result &&
  72        test_cmp expected result
  73'
  74
  75
  76test_expect_success 'cat-file --textconv on index (symlink)' '
  77        git cat-file --textconv :symlink.bin >result &&
  78        test_cmp expected result
  79'
  80
  81test_expect_success 'cat-file --textconv on HEAD (symlink)' '
  82        git cat-file --textconv HEAD:symlink.bin >result &&
  83        test_cmp expected result
  84'
  85
  86test_done