]>
Commit | Line | Data |
---|---|---|
8a98758a AM |
1 | #!/bin/sh |
2 | ||
3 | test_description='stash --pathspec-from-file' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_tick | |
8 | ||
9 | test_expect_success setup ' | |
10 | >fileA.t && | |
11 | >fileB.t && | |
12 | >fileC.t && | |
13 | >fileD.t && | |
14 | git add fileA.t fileB.t fileC.t fileD.t && | |
15 | git commit -m "Files" && | |
16 | ||
17 | git tag checkpoint | |
18 | ' | |
19 | ||
20 | restore_checkpoint () { | |
21 | git reset --hard checkpoint | |
22 | } | |
23 | ||
24 | verify_expect () { | |
25 | git stash show --name-status >actual && | |
26 | test_cmp expect actual | |
27 | } | |
28 | ||
29 | test_expect_success 'simplest' ' | |
30 | restore_checkpoint && | |
31 | ||
32 | # More files are written to make sure that git didnt ignore | |
33 | # --pathspec-from-file, stashing everything | |
34 | echo A >fileA.t && | |
35 | echo B >fileB.t && | |
36 | echo C >fileC.t && | |
37 | echo D >fileD.t && | |
38 | ||
39 | cat >expect <<-\EOF && | |
40 | M fileA.t | |
41 | EOF | |
42 | ||
43 | echo fileA.t | git stash push --pathspec-from-file=- && | |
44 | verify_expect | |
45 | ' | |
46 | ||
47 | test_expect_success '--pathspec-file-nul' ' | |
48 | restore_checkpoint && | |
49 | ||
50 | # More files are written to make sure that git didnt ignore | |
51 | # --pathspec-from-file, stashing everything | |
52 | echo A >fileA.t && | |
53 | echo B >fileB.t && | |
54 | echo C >fileC.t && | |
55 | echo D >fileD.t && | |
56 | ||
57 | cat >expect <<-\EOF && | |
58 | M fileA.t | |
59 | M fileB.t | |
60 | EOF | |
61 | ||
62 | printf "fileA.t\0fileB.t\0" | git stash push --pathspec-from-file=- --pathspec-file-nul && | |
63 | verify_expect | |
64 | ' | |
65 | ||
66 | test_expect_success 'only touches what was listed' ' | |
67 | restore_checkpoint && | |
68 | ||
69 | # More files are written to make sure that git didnt ignore | |
70 | # --pathspec-from-file, stashing everything | |
71 | echo A >fileA.t && | |
72 | echo B >fileB.t && | |
73 | echo C >fileC.t && | |
74 | echo D >fileD.t && | |
75 | ||
76 | cat >expect <<-\EOF && | |
77 | M fileB.t | |
78 | M fileC.t | |
79 | EOF | |
80 | ||
81 | printf "fileB.t\nfileC.t\n" | git stash push --pathspec-from-file=- && | |
82 | verify_expect | |
83 | ' | |
84 | ||
85 | test_expect_success 'error conditions' ' | |
86 | restore_checkpoint && | |
87 | echo A >fileA.t && | |
88 | echo fileA.t >list && | |
89 | ||
90 | test_must_fail git stash push --pathspec-from-file=list --patch 2>err && | |
91 | test_i18ngrep -e "--pathspec-from-file is incompatible with --patch" err && | |
92 | ||
93 | test_must_fail git stash push --pathspec-from-file=list -- fileA.t 2>err && | |
94 | test_i18ngrep -e "--pathspec-from-file is incompatible with pathspec arguments" err && | |
95 | ||
96 | test_must_fail git stash push --pathspec-file-nul 2>err && | |
97 | test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err | |
98 | ' | |
99 | ||
100 | test_done |