t / t4122-apply-symlink-inside.shon commit Merge branch 'tr/maint-1.6.1-doc-format-patch--root' (85b7bd5)
   1#!/bin/sh
   2
   3test_description='apply to deeper directory without getting fooled with symlink'
   4. ./test-lib.sh
   5
   6if ! test_have_prereq SYMLINKS
   7then
   8        say 'Symbolic links not supported, skipping tests.'
   9        test_done
  10        exit
  11fi
  12
  13lecho () {
  14        for l_
  15        do
  16                echo "$l_"
  17        done
  18}
  19
  20test_expect_success setup '
  21
  22        mkdir -p arch/i386/boot arch/x86_64 &&
  23        lecho 1 2 3 4 5 >arch/i386/boot/Makefile &&
  24        ln -s ../i386/boot arch/x86_64/boot &&
  25        git add . &&
  26        test_tick &&
  27        git commit -m initial &&
  28        git branch test &&
  29
  30        rm arch/x86_64/boot &&
  31        mkdir arch/x86_64/boot &&
  32        lecho 2 3 4 5 6 >arch/x86_64/boot/Makefile &&
  33        git add . &&
  34        test_tick &&
  35        git commit -a -m second &&
  36
  37        git format-patch --binary -1 --stdout >test.patch
  38
  39'
  40
  41test_expect_success apply '
  42
  43        git checkout test &&
  44        git diff --exit-code test &&
  45        git diff --exit-code --cached test &&
  46        git apply --index test.patch
  47
  48'
  49
  50test_expect_success 'check result' '
  51
  52        git diff --exit-code master &&
  53        git diff --exit-code --cached master &&
  54        test_tick &&
  55        git commit -m replay &&
  56        T1=$(git rev-parse "master^{tree}") &&
  57        T2=$(git rev-parse "HEAD^{tree}") &&
  58        test "z$T1" = "z$T2"
  59
  60'
  61
  62test_done