fsck: detect more in-tree d/f conflicts
[git/raj.git] / t / t7107-reset-pathspec-file.sh
blob6b1a731fffe65f10259a5200e071c4767181d759
1 #!/bin/sh
3 test_description='reset --pathspec-from-file'
5 . ./test-lib.sh
7 test_tick
9 test_expect_success setup '
10 echo A >fileA.t &&
11 echo B >fileB.t &&
12 echo C >fileC.t &&
13 echo D >fileD.t &&
14 git add . &&
15 git commit --include . -m "Commit" &&
16 git tag checkpoint
19 restore_checkpoint () {
20 git reset --hard checkpoint
23 verify_expect () {
24 git status --porcelain -- fileA.t fileB.t fileC.t fileD.t >actual &&
25 test_cmp expect actual
28 test_expect_success '--pathspec-from-file from stdin' '
29 restore_checkpoint &&
31 git rm fileA.t &&
32 echo fileA.t | git reset --pathspec-from-file=- &&
34 cat >expect <<-\EOF &&
35 D fileA.t
36 EOF
37 verify_expect
40 test_expect_success '--pathspec-from-file from file' '
41 restore_checkpoint &&
43 git rm fileA.t &&
44 echo fileA.t >list &&
45 git reset --pathspec-from-file=list &&
47 cat >expect <<-\EOF &&
48 D fileA.t
49 EOF
50 verify_expect
53 test_expect_success 'NUL delimiters' '
54 restore_checkpoint &&
56 git rm fileA.t fileB.t &&
57 printf "fileA.t\0fileB.t\0" | git reset --pathspec-from-file=- --pathspec-file-nul &&
59 cat >expect <<-\EOF &&
60 D fileA.t
61 D fileB.t
62 EOF
63 verify_expect
66 test_expect_success 'LF delimiters' '
67 restore_checkpoint &&
69 git rm fileA.t fileB.t &&
70 printf "fileA.t\nfileB.t\n" | git reset --pathspec-from-file=- &&
72 cat >expect <<-\EOF &&
73 D fileA.t
74 D fileB.t
75 EOF
76 verify_expect
79 test_expect_success 'no trailing delimiter' '
80 restore_checkpoint &&
82 git rm fileA.t fileB.t &&
83 printf "fileA.t\nfileB.t" | git reset --pathspec-from-file=- &&
85 cat >expect <<-\EOF &&
86 D fileA.t
87 D fileB.t
88 EOF
89 verify_expect
92 test_expect_success 'CRLF delimiters' '
93 restore_checkpoint &&
95 git rm fileA.t fileB.t &&
96 printf "fileA.t\r\nfileB.t\r\n" | git reset --pathspec-from-file=- &&
98 cat >expect <<-\EOF &&
99 D fileA.t
100 D fileB.t
102 verify_expect
105 test_expect_success 'quotes' '
106 restore_checkpoint &&
108 git rm fileA.t &&
109 printf "\"file\\101.t\"" | git reset --pathspec-from-file=- &&
111 cat >expect <<-\EOF &&
112 D fileA.t
114 verify_expect
117 test_expect_success 'quotes not compatible with --pathspec-file-nul' '
118 restore_checkpoint &&
120 git rm fileA.t &&
121 printf "\"file\\101.t\"" >list &&
122 # Note: "git reset" has not yet learned to fail on wrong pathspecs
123 git reset --pathspec-from-file=list --pathspec-file-nul &&
125 cat >expect <<-\EOF &&
126 D fileA.t
128 test_must_fail verify_expect
131 test_expect_success '--pathspec-from-file is not compatible with --soft or --hard' '
132 restore_checkpoint &&
134 git rm fileA.t &&
135 echo fileA.t >list &&
136 test_must_fail git reset --soft --pathspec-from-file=list &&
137 test_must_fail git reset --hard --pathspec-from-file=list
140 test_expect_success 'only touches what was listed' '
141 restore_checkpoint &&
143 git rm fileA.t fileB.t fileC.t fileD.t &&
144 printf "fileB.t\nfileC.t\n" | git reset --pathspec-from-file=- &&
146 cat >expect <<-\EOF &&
147 D fileA.t
148 D fileB.t
149 D fileC.t
150 D fileD.t
152 verify_expect
155 test_done