1#!/bin/sh
   2test_description='apply same filename'
   4. ./test-lib.sh
   6test_expect_success 'setup' '
   8        mkdir -p some/sub/dir &&
  10        echo Hello > some/sub/dir/file &&
  11        git add some/sub/dir/file &&
  12        git commit -m initial &&
  13        git tag initial
  14'
  16cat > patch << EOF
  18diff a/bla/blub/dir/file b/bla/blub/dir/file
  19--- a/bla/blub/dir/file
  20+++ b/bla/blub/dir/file
  21@@ -1,1 +1,1 @@
  22-Hello
  23+Bello
  24EOF
  25test_expect_success 'apply --directory -p (1)' '
  27        git apply --directory=some/sub -p3 --index patch &&
  29        test Bello = $(git show :some/sub/dir/file) &&
  30        test Bello = $(cat some/sub/dir/file)
  31'
  33test_expect_success 'apply --directory -p (2) ' '
  35        git reset --hard initial &&
  37        git apply --directory=some/sub/ -p3 --index patch &&
  38        test Bello = $(git show :some/sub/dir/file) &&
  39        test Bello = $(cat some/sub/dir/file)
  40'
  42test_done