rebase: use correct base for --keep-base when a branch is given
[alt-git.git] / t / t4128-apply-root.sh
blobf6db5a79dd9d356c93a935374c4c27520ecf6593
1 #!/bin/sh
3 test_description='apply same filename'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
9 mkdir -p some/sub/dir &&
10 echo Hello > some/sub/dir/file &&
11 git add some/sub/dir/file &&
12 git commit -m initial &&
13 git tag initial
17 cat > patch << EOF
18 diff a/bla/blub/dir/file b/bla/blub/dir/file
19 --- a/bla/blub/dir/file
20 +++ b/bla/blub/dir/file
21 @@ -1,1 +1,1 @@
22 -Hello
23 +Bello
24 EOF
26 test_expect_success 'apply --directory -p (1)' '
27 git apply --directory=some/sub -p3 --index patch &&
28 echo Bello >expect &&
29 git show :some/sub/dir/file >actual &&
30 test_cmp expect actual &&
31 test_cmp expect some/sub/dir/file
35 test_expect_success 'apply --directory -p (2) ' '
37 git reset --hard initial &&
38 git apply --directory=some/sub/ -p3 --index patch &&
39 echo Bello >expect &&
40 git show :some/sub/dir/file >actual &&
41 test_cmp expect actual &&
42 test_cmp expect some/sub/dir/file
46 cat > patch << EOF
47 diff --git a/newfile b/newfile
48 new file mode 100644
49 index 0000000..d95f3ad
50 --- /dev/null
51 +++ b/newfile
52 @@ -0,0 +1 @@
53 +content
54 EOF
56 test_expect_success 'apply --directory (new file)' '
57 git reset --hard initial &&
58 git apply --directory=some/sub/dir/ --index patch &&
59 echo content >expect &&
60 git show :some/sub/dir/newfile >actual &&
61 test_cmp expect actual &&
62 test_cmp expect some/sub/dir/newfile
65 cat > patch << EOF
66 diff --git a/c/newfile2 b/c/newfile2
67 new file mode 100644
68 index 0000000..d95f3ad
69 --- /dev/null
70 +++ b/c/newfile2
71 @@ -0,0 +1 @@
72 +content
73 EOF
75 test_expect_success 'apply --directory -p (new file)' '
76 git reset --hard initial &&
77 git apply -p2 --directory=some/sub/dir/ --index patch &&
78 echo content >expect &&
79 git show :some/sub/dir/newfile2 >actual &&
80 test_cmp expect actual &&
81 test_cmp expect some/sub/dir/newfile2
84 cat > patch << EOF
85 diff --git a/delfile b/delfile
86 deleted file mode 100644
87 index d95f3ad..0000000
88 --- a/delfile
89 +++ /dev/null
90 @@ -1 +0,0 @@
91 -content
92 EOF
94 test_expect_success 'apply --directory (delete file)' '
95 git reset --hard initial &&
96 echo content >some/sub/dir/delfile &&
97 git add some/sub/dir/delfile &&
98 git apply --directory=some/sub/dir/ --index patch &&
99 git ls-files >out &&
100 ! grep delfile out
103 cat > patch << 'EOF'
104 diff --git "a/qu\157tefile" "b/qu\157tefile"
105 new file mode 100644
106 index 0000000..d95f3ad
107 --- /dev/null
108 +++ "b/qu\157tefile"
109 @@ -0,0 +1 @@
110 +content
113 test_expect_success 'apply --directory (quoted filename)' '
114 git reset --hard initial &&
115 git apply --directory=some/sub/dir/ --index patch &&
116 echo content >expect &&
117 git show :some/sub/dir/quotefile >actual &&
118 test_cmp expect actual &&
119 test_cmp expect some/sub/dir/quotefile
122 test_done