t / t4126-apply-empty.shon commit Add some tests for git update-ref -d (40672a1)
   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        >empty &&
  30        rm -f missing &&
  31        git apply patch0 &&
  32        test_cmp expect empty
  33'
  34
  35test_expect_success 'apply --index empty' '
  36        git reset --hard &&
  37        >empty &&
  38        rm -f missing &&
  39        git apply --index patch0 &&
  40        test_cmp expect empty &&
  41        git diff --exit-code
  42'
  43
  44test_expect_success 'apply create' '
  45        git reset --hard &&
  46        >empty &&
  47        rm -f missing &&
  48        git apply patch1 &&
  49        test_cmp expect missing
  50'
  51
  52test_expect_success 'apply --index create' '
  53        git reset --hard &&
  54        >empty &&
  55        rm -f missing &&
  56        git apply --index patch1 &&
  57        test_cmp expect missing &&
  58        git diff --exit-code
  59'
  60
  61test_done