Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t4115-apply-symlink.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t4115-apply-symlink.sh` 143 lines ยท 3332 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2005 Junio C Hamano 4 # 5 6 test_description='git apply symlinks and partial files 7 8 ' 9 10 . ./test-lib.sh 11 12 test_expect_success setup ' 13 14 test_ln_s_add path1/path2/path3/path4/path5 link1 && 15 git commit -m initial && 16 17 git branch side && 18 19 rm -f link? && 20 21 test_ln_s_add htap6 link1 && 22 git commit -m second && 23 24 git diff-tree -p HEAD^ HEAD >patch && 25 git apply --stat --summary patch 26 27 ' 28 29 test_expect_success SYMLINKS 'apply symlink patch' ' 30 31 git checkout side && 32 git apply patch && 33 git diff-files -p >patched && 34 test_cmp patch patched 35 36 ' 37 38 test_expect_success 'apply --index symlink patch' ' 39 40 git checkout -f side && 41 git apply --index patch && 42 git diff-index --cached -p HEAD >patched && 43 test_cmp patch patched 44 45 ' 46 47 test_expect_success 'symlink setup' ' 48 ln -s .git symlink && 49 git add symlink && 50 git commit -m "add symlink" 51 ' 52 53 test_expect_success SYMLINKS 'symlink escape when creating new files' ' 54 test_when_finished "git reset --hard && git clean -dfx" && 55 56 cat >patch <<-EOF && 57 diff --git a/symlink b/renamed-symlink 58 similarity index 100% 59 rename from symlink 60 rename to renamed-symlink 61 -- 62 diff --git /dev/null b/renamed-symlink/create-me 63 new file mode 100644 64 index `0000000`..`039727e` 65 --- /dev/null 66 +++ b/renamed-symlink/create-me 67 @@ -0,0 +1,1 @@ 68 +busted 69 EOF 70 71 test_must_fail git apply patch 2>stderr && 72 cat >expected_stderr <<-EOF && 73 error: affected file ${SQ}renamed-symlink/create-me${SQ} is beyond a symbolic link 74 EOF 75 test_cmp expected_stderr stderr && 76 test_path_is_missing .git/create-me 77 ' 78 79 test_expect_success SYMLINKS 'symlink escape when modifying file' ' 80 test_when_finished "git reset --hard && git clean -dfx" && 81 touch .git/modify-me && 82 83 cat >patch <<-EOF && 84 diff --git a/symlink b/renamed-symlink 85 similarity index 100% 86 rename from symlink 87 rename to renamed-symlink 88 -- 89 diff --git a/renamed-symlink/modify-me b/renamed-symlink/modify-me 90 index `1111111`..`2222222` 100644 91 --- a/renamed-symlink/modify-me 92 +++ b/renamed-symlink/modify-me 93 @@ -0,0 +1,1 @@ 94 +busted 95 EOF 96 97 test_must_fail git apply patch 2>stderr && 98 cat >expected_stderr <<-EOF && 99 error: renamed-symlink/modify-me: No such file or directory 100 EOF 101 test_cmp expected_stderr stderr && 102 test_must_be_empty .git/modify-me 103 ' 104 105 test_expect_success SYMLINKS 'symlink escape when deleting file' ' 106 test_when_finished "git reset --hard && git clean -dfx && rm .git/delete-me" && 107 touch .git/delete-me && 108 109 cat >patch <<-EOF && 110 diff --git a/symlink b/renamed-symlink 111 similarity index 100% 112 rename from symlink 113 rename to renamed-symlink 114 -- 115 diff --git a/renamed-symlink/delete-me b/renamed-symlink/delete-me 116 deleted file mode 100644 117 index `1111111`..`0000000` 100644 118 EOF 119 120 test_must_fail git apply patch 2>stderr && 121 cat >expected_stderr <<-EOF && 122 error: renamed-symlink/delete-me: No such file or directory 123 EOF 124 test_cmp expected_stderr stderr && 125 test_path_is_file .git/delete-me 126 ' 127 128 test_expect_success SYMLINKS '--reject removes .rej symlink if it exists' ' 129 test_when_finished "git reset --hard && git clean -dfx" && 130 131 test_commit file && 132 echo modified >file.t && 133 git diff -- file.t >patch && 134 echo modified-again >file.t && 135 136 ln -s foo file.t.rej && 137 test_must_fail git apply patch --reject 2>err && 138 test_grep "Rejected hunk" err && 139 test_path_is_missing foo && 140 test_path_is_file file.t.rej 141 ' 142 143 test_done