t / t4102-apply-rename.shon commit Merge branch 'ob/imap-send-ssl-verify' into maint (0ee7198)
   1#!/bin/sh
   2#
   3# Copyright (c) 2005 Junio C Hamano
   4#
   5
   6test_description='git apply handling copy/rename patch.
   7
   8'
   9. ./test-lib.sh
  10. "$TEST_DIRECTORY"/lib-prereq-FILEMODE.sh
  11
  12# setup
  13
  14cat >test-patch <<\EOF
  15diff --git a/foo b/bar
  16similarity index 47%
  17rename from foo
  18rename to bar
  19--- a/foo
  20+++ b/bar
  21@@ -1 +1 @@
  22-This is foo
  23+This is bar
  24EOF
  25
  26echo 'This is foo' >foo
  27chmod +x foo
  28
  29test_expect_success setup \
  30    'git update-index --add foo'
  31
  32test_expect_success apply \
  33    'git apply --index --stat --summary --apply test-patch'
  34
  35test_expect_success FILEMODE validate \
  36            'test -f bar && ls -l bar | grep "^-..x......"'
  37
  38test_expect_success 'apply reverse' \
  39    'git apply -R --index --stat --summary --apply test-patch &&
  40     test "$(cat foo)" = "This is foo"'
  41
  42cat >test-patch <<\EOF
  43diff --git a/foo b/bar
  44similarity index 47%
  45copy from foo
  46copy to bar
  47--- a/foo
  48+++ b/bar
  49@@ -1 +1 @@
  50-This is foo
  51+This is bar
  52EOF
  53
  54test_expect_success 'apply copy' \
  55    'git apply --index --stat --summary --apply test-patch &&
  56     test "$(cat bar)" = "This is bar" -a "$(cat foo)" = "This is foo"'
  57
  58test_done