t / t4122-apply-symlink-inside.shon commit Merge commit 'b319ef7' into jc/maint-fix-test-perm (00d3278)
   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
  10fi
  11
  12lecho () {
  13        for l_
  14        do
  15                echo "$l_"
  16        done
  17}
  18
  19test_expect_success setup '
  20
  21        mkdir -p arch/i386/boot arch/x86_64 &&
  22        lecho 1 2 3 4 5 >arch/i386/boot/Makefile &&
  23        ln -s ../i386/boot arch/x86_64/boot &&
  24        git add . &&
  25        test_tick &&
  26        git commit -m initial &&
  27        git branch test &&
  28
  29        rm arch/x86_64/boot &&
  30        mkdir arch/x86_64/boot &&
  31        lecho 2 3 4 5 6 >arch/x86_64/boot/Makefile &&
  32        git add . &&
  33        test_tick &&
  34        git commit -a -m second &&
  35
  36        git format-patch --binary -1 --stdout >test.patch
  37
  38'
  39
  40test_expect_success apply '
  41
  42        git checkout test &&
  43        git diff --exit-code test &&
  44        git diff --exit-code --cached test &&
  45        git apply --index test.patch
  46
  47'
  48
  49test_expect_success 'check result' '
  50
  51        git diff --exit-code master &&
  52        git diff --exit-code --cached master &&
  53        test_tick &&
  54        git commit -m replay &&
  55        T1=$(git rev-parse "master^{tree}") &&
  56        T2=$(git rev-parse "HEAD^{tree}") &&
  57        test "z$T1" = "z$T2"
  58
  59'
  60
  61test_done