t / t1051-large-conversion.shon commit test: add test cases for relative_path (203439b)
   1#!/bin/sh
   2
   3test_description='test conversion filters on large files'
   4. ./test-lib.sh
   5
   6set_attr() {
   7        test_when_finished 'rm -f .gitattributes' &&
   8        echo "* $*" >.gitattributes
   9}
  10
  11check_input() {
  12        git read-tree --empty &&
  13        git add small large &&
  14        git cat-file blob :small >small.index &&
  15        git cat-file blob :large | head -n 1 >large.index &&
  16        test_cmp small.index large.index
  17}
  18
  19check_output() {
  20        rm -f small large &&
  21        git checkout small large &&
  22        head -n 1 large >large.head &&
  23        test_cmp small large.head
  24}
  25
  26test_expect_success 'setup input tests' '
  27        printf "\$Id: foo\$\\r\\n" >small &&
  28        cat small small >large &&
  29        git config core.bigfilethreshold 20 &&
  30        git config filter.test.clean "sed s/.*/CLEAN/"
  31'
  32
  33test_expect_success 'autocrlf=true converts on input' '
  34        test_config core.autocrlf true &&
  35        check_input
  36'
  37
  38test_expect_success 'eol=crlf converts on input' '
  39        set_attr eol=crlf &&
  40        check_input
  41'
  42
  43test_expect_success 'ident converts on input' '
  44        set_attr ident &&
  45        check_input
  46'
  47
  48test_expect_success 'user-defined filters convert on input' '
  49        set_attr filter=test &&
  50        check_input
  51'
  52
  53test_expect_success 'setup output tests' '
  54        echo "\$Id\$" >small &&
  55        cat small small >large &&
  56        git add small large &&
  57        git config core.bigfilethreshold 7 &&
  58        git config filter.test.smudge "sed s/.*/SMUDGE/"
  59'
  60
  61test_expect_success 'autocrlf=true converts on output' '
  62        test_config core.autocrlf true &&
  63        check_output
  64'
  65
  66test_expect_success 'eol=crlf converts on output' '
  67        set_attr eol=crlf &&
  68        check_output
  69'
  70
  71test_expect_success 'user-defined filters convert on output' '
  72        set_attr filter=test &&
  73        check_output
  74'
  75
  76test_expect_success 'ident converts on output' '
  77        set_attr ident &&
  78        rm -f small large &&
  79        git checkout small large &&
  80        sed -n "s/Id: .*/Id: SHA/p" <small >small.clean &&
  81        head -n 1 large >large.head &&
  82        sed -n "s/Id: .*/Id: SHA/p" <large.head >large.clean &&
  83        test_cmp small.clean large.clean
  84'
  85
  86test_done