The seventh batch
[git/debian.git] / t / t4128-apply-root.sh
blobcb3181e8b71a8e25586467c20086063b33ec36d0
1 #!/bin/sh
3 test_description='apply same filename'
6 TEST_PASSES_SANITIZE_LEAK=true
7 . ./test-lib.sh
9 test_expect_success 'setup' '
11 mkdir -p some/sub/dir &&
12 echo Hello > some/sub/dir/file &&
13 git add some/sub/dir/file &&
14 git commit -m initial &&
15 git tag initial
19 cat > patch << EOF
20 diff a/bla/blub/dir/file b/bla/blub/dir/file
21 --- a/bla/blub/dir/file
22 +++ b/bla/blub/dir/file
23 @@ -1,1 +1,1 @@
24 -Hello
25 +Bello
26 EOF
28 test_expect_success 'apply --directory -p (1)' '
30 git apply --directory=some/sub -p3 --index patch &&
31 test Bello = $(git show :some/sub/dir/file) &&
32 test Bello = $(cat some/sub/dir/file)
36 test_expect_success 'apply --directory -p (2) ' '
38 git reset --hard initial &&
39 git apply --directory=some/sub/ -p3 --index patch &&
40 test Bello = $(git show :some/sub/dir/file) &&
41 test Bello = $(cat some/sub/dir/file)
45 cat > patch << EOF
46 diff --git a/newfile b/newfile
47 new file mode 100644
48 index 0000000..d95f3ad
49 --- /dev/null
50 +++ b/newfile
51 @@ -0,0 +1 @@
52 +content
53 EOF
55 test_expect_success 'apply --directory (new file)' '
56 git reset --hard initial &&
57 git apply --directory=some/sub/dir/ --index patch &&
58 test content = $(git show :some/sub/dir/newfile) &&
59 test content = $(cat some/sub/dir/newfile)
62 cat > patch << EOF
63 diff --git a/c/newfile2 b/c/newfile2
64 new file mode 100644
65 index 0000000..d95f3ad
66 --- /dev/null
67 +++ b/c/newfile2
68 @@ -0,0 +1 @@
69 +content
70 EOF
72 test_expect_success 'apply --directory -p (new file)' '
73 git reset --hard initial &&
74 git apply -p2 --directory=some/sub/dir/ --index patch &&
75 test content = $(git show :some/sub/dir/newfile2) &&
76 test content = $(cat some/sub/dir/newfile2)
79 cat > patch << EOF
80 diff --git a/delfile b/delfile
81 deleted file mode 100644
82 index d95f3ad..0000000
83 --- a/delfile
84 +++ /dev/null
85 @@ -1 +0,0 @@
86 -content
87 EOF
89 test_expect_success 'apply --directory (delete file)' '
90 git reset --hard initial &&
91 echo content >some/sub/dir/delfile &&
92 git add some/sub/dir/delfile &&
93 git apply --directory=some/sub/dir/ --index patch &&
94 ! (git ls-files | grep delfile)
97 cat > patch << 'EOF'
98 diff --git "a/qu\157tefile" "b/qu\157tefile"
99 new file mode 100644
100 index 0000000..d95f3ad
101 --- /dev/null
102 +++ "b/qu\157tefile"
103 @@ -0,0 +1 @@
104 +content
107 test_expect_success 'apply --directory (quoted filename)' '
108 git reset --hard initial &&
109 git apply --directory=some/sub/dir/ --index patch &&
110 test content = $(git show :some/sub/dir/quotefile) &&
111 test content = $(cat some/sub/dir/quotefile)
114 test_done