t / t4126-apply-empty.shon commit userdiff: add a builtin pattern for dts files (3c81760)
   1#!/bin/sh
   2
   3test_description='apply empty'
   4
   5. ./test-lib.sh
   6
   7test_expect_success setup '
   8        >empty &&
   9        git add empty &&
  10        test_tick &&
  11        git commit -m initial &&
  12        for i in a b c d e
  13        do
  14                echo $i
  15        done >empty &&
  16        cat empty >expect &&
  17        git diff |
  18        sed -e "/^diff --git/d" \
  19            -e "/^index /d" \
  20            -e "s|a/empty|empty.orig|" \
  21            -e "s|b/empty|empty|" >patch0 &&
  22        sed -e "s|empty|missing|" patch0 >patch1 &&
  23        >empty &&
  24        git update-index --refresh
  25'
  26
  27test_expect_success 'apply empty' '
  28        git reset --hard &&
  29        rm -f missing &&
  30        git apply patch0 &&
  31        test_cmp expect empty
  32'
  33
  34test_expect_success 'apply --index empty' '
  35        git reset --hard &&
  36        rm -f missing &&
  37        git apply --index patch0 &&
  38        test_cmp expect empty &&
  39        git diff --exit-code
  40'
  41
  42test_expect_success 'apply create' '
  43        git reset --hard &&
  44        rm -f missing &&
  45        git apply patch1 &&
  46        test_cmp expect missing
  47'
  48
  49test_expect_success 'apply --index create' '
  50        git reset --hard &&
  51        rm -f missing &&
  52        git apply --index patch1 &&
  53        test_cmp expect missing &&
  54        git diff --exit-code
  55'
  56
  57test_done