Git 2.34-rc0
[alt-git.git] / t / t3909-stash-pathspec-file.sh
blob55e050cfd4db8ffc2ad0826baa5c50fc2734c726
1 #!/bin/sh
3 test_description='stash --pathspec-from-file'
5 . ./test-lib.sh
7 test_tick
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" &&
17 git tag checkpoint
20 restore_checkpoint () {
21 git reset --hard checkpoint
24 verify_expect () {
25 git stash show --name-status >actual &&
26 test_cmp expect actual
29 test_expect_success 'simplest' '
30 restore_checkpoint &&
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 &&
39 cat >expect <<-\EOF &&
40 M fileA.t
41 EOF
43 echo fileA.t | git stash push --pathspec-from-file=- &&
44 verify_expect
47 test_expect_success '--pathspec-file-nul' '
48 restore_checkpoint &&
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 &&
57 cat >expect <<-\EOF &&
58 M fileA.t
59 M fileB.t
60 EOF
62 printf "fileA.t\0fileB.t\0" | git stash push --pathspec-from-file=- --pathspec-file-nul &&
63 verify_expect
66 test_expect_success 'only touches what was listed' '
67 restore_checkpoint &&
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 &&
76 cat >expect <<-\EOF &&
77 M fileB.t
78 M fileC.t
79 EOF
81 printf "fileB.t\nfileC.t\n" | git stash push --pathspec-from-file=- &&
82 verify_expect
85 test_expect_success 'error conditions' '
86 restore_checkpoint &&
87 echo A >fileA.t &&
88 echo fileA.t >list &&
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 &&
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 &&
96 test_must_fail git stash push --pathspec-file-nul 2>err &&
97 test_i18ngrep -e "--pathspec-file-nul requires --pathspec-from-file" err
100 test_done