]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3601-rm-pathspec-file.sh
The third batch
[thirdparty/git.git] / t / t3601-rm-pathspec-file.sh
CommitLineData
5f393dc3
AM
1#!/bin/sh
2
3test_description='rm --pathspec-from-file'
4
7ff24785 5TEST_PASSES_SANITIZE_LEAK=true
5f393dc3
AM
6. ./test-lib.sh
7
8test_tick
9
10test_expect_success setup '
11 echo A >fileA.t &&
12 echo B >fileB.t &&
13 echo C >fileC.t &&
14 echo D >fileD.t &&
15 git add fileA.t fileB.t fileC.t fileD.t &&
16 git commit -m "files" &&
17
18 git tag checkpoint
19'
20
21restore_checkpoint () {
22 git reset --hard checkpoint
23}
24
25verify_expect () {
26 git status --porcelain --untracked-files=no -- fileA.t fileB.t fileC.t fileD.t >actual &&
27 test_cmp expect actual
28}
29
30test_expect_success 'simplest' '
31 restore_checkpoint &&
32
33 cat >expect <<-\EOF &&
34 D fileA.t
35 EOF
36
37 echo fileA.t | git rm --pathspec-from-file=- &&
38 verify_expect
39'
40
41test_expect_success '--pathspec-file-nul' '
42 restore_checkpoint &&
43
44 cat >expect <<-\EOF &&
45 D fileA.t
46 D fileB.t
47 EOF
48
49 printf "fileA.t\0fileB.t\0" | git rm --pathspec-from-file=- --pathspec-file-nul &&
50 verify_expect
51'
52
53test_expect_success 'only touches what was listed' '
54 restore_checkpoint &&
55
56 cat >expect <<-\EOF &&
57 D fileB.t
58 D fileC.t
59 EOF
60
61 printf "fileB.t\nfileC.t\n" | git rm --pathspec-from-file=- &&
62 verify_expect
63'
64
65test_expect_success 'error conditions' '
66 restore_checkpoint &&
67 echo fileA.t >list &&
68
69 test_must_fail git rm --pathspec-from-file=list -- fileA.t 2>err &&
6789275d 70 test_grep -e ".--pathspec-from-file. and pathspec arguments cannot be used together" err &&
5f393dc3
AM
71
72 test_must_fail git rm --pathspec-file-nul 2>err &&
6789275d 73 test_grep -e "the option .--pathspec-file-nul. requires .--pathspec-from-file." err &&
5f393dc3
AM
74
75 >empty_list &&
76 test_must_fail git rm --pathspec-from-file=empty_list 2>err &&
6789275d 77 test_grep -e "No pathspec was given. Which files should I remove?" err
5f393dc3
AM
78'
79
80test_done