816b5b8fb2388e59d99532f49a5c46f81dfc8125
   1#!/bin/sh
   2#
   3# Copyright (c) 2007 Junio C Hamano
   4#
   5
   6test_description='git-apply --whitespace=strip and configuration file.
   7
   8'
   9
  10. ./test-lib.sh
  11
  12test_expect_success setup '
  13        mkdir sub &&
  14        echo A >sub/file1 &&
  15        cp sub/file1 saved &&
  16        git add sub/file1 &&
  17        echo "B " >sub/file1 &&
  18        git diff >patch.file
  19'
  20
  21test_expect_success 'apply --whitespace=strip' '
  22
  23        rm -f sub/file1 &&
  24        cp saved sub/file1 &&
  25        git update-index --refresh &&
  26
  27        git apply --whitespace=strip patch.file &&
  28        if grep " " sub/file1
  29        then
  30                echo "Eh?"
  31                false
  32        else
  33                echo Happy
  34        fi
  35'
  36
  37test_expect_success 'apply --whitespace=strip from config' '
  38
  39        rm -f sub/file1 &&
  40        cp saved sub/file1 &&
  41        git update-index --refresh &&
  42
  43        git config apply.whitespace strip &&
  44        git apply patch.file &&
  45        if grep " " sub/file1
  46        then
  47                echo "Eh?"
  48                false
  49        else
  50                echo Happy
  51        fi
  52'
  53
  54D=`pwd`
  55
  56test_expect_success 'apply --whitespace=strip in subdir' '
  57
  58        cd "$D" &&
  59        git config --unset-all apply.whitespace
  60        rm -f sub/file1 &&
  61        cp saved sub/file1 &&
  62        git update-index --refresh &&
  63
  64        cd sub &&
  65        git apply --whitespace=strip -p2 ../patch.file &&
  66        if grep " " file1
  67        then
  68                echo "Eh?"
  69                false
  70        else
  71                echo Happy
  72        fi
  73'
  74
  75test_expect_success 'apply --whitespace=strip from config in subdir' '
  76
  77        cd "$D" &&
  78        git config apply.whitespace strip &&
  79        rm -f sub/file1 &&
  80        cp saved sub/file1 &&
  81        git update-index --refresh &&
  82
  83        cd sub &&
  84        git apply -p2 ../patch.file &&
  85        if grep " " file1
  86        then
  87                echo "Eh?"
  88                false
  89        else
  90                echo Happy
  91        fi
  92'
  93
  94test_done