Git 2.32
[git] / t / t3907-stash-show-config.sh
1 #!/bin/sh
2
3 test_description='Test git stash show configuration.'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         test_commit file
9 '
10
11 # takes three parameters:
12 # 1. the stash.showStat value (or "<unset>")
13 # 2. the stash.showPatch value (or "<unset>")
14 # 3. the diff options of the expected output (or nothing for no output)
15 test_stat_and_patch () {
16         if test "<unset>" = "$1"
17         then
18                 test_unconfig stash.showStat
19         else
20                 test_config stash.showStat "$1"
21         fi &&
22
23         if test "<unset>" = "$2"
24         then
25                 test_unconfig stash.showPatch
26         else
27                 test_config stash.showPatch "$2"
28         fi &&
29
30         shift 2 &&
31         echo 2 >file.t &&
32         if test $# != 0
33         then
34                 git diff "$@" >expect
35         fi &&
36         git stash &&
37         git stash show >actual &&
38
39         if test $# = 0
40         then
41                 test_must_be_empty actual
42         else
43                 test_cmp expect actual
44         fi
45 }
46
47 test_expect_success 'showStat unset showPatch unset' '
48         test_stat_and_patch "<unset>" "<unset>" --stat
49 '
50
51 test_expect_success 'showStat unset showPatch false' '
52         test_stat_and_patch "<unset>" false --stat
53 '
54
55 test_expect_success 'showStat unset showPatch true' '
56         test_stat_and_patch "<unset>" true --stat -p
57 '
58
59 test_expect_success 'showStat false showPatch unset' '
60         test_stat_and_patch false "<unset>"
61 '
62
63 test_expect_success 'showStat false showPatch false' '
64         test_stat_and_patch false false
65 '
66
67 test_expect_success 'showStat false showPatch true' '
68         test_stat_and_patch false true -p
69 '
70
71 test_expect_success 'showStat true showPatch unset' '
72         test_stat_and_patch true "<unset>" --stat
73 '
74
75 test_expect_success 'showStat true showPatch false' '
76         test_stat_and_patch true false --stat
77 '
78
79 test_expect_success 'showStat true showPatch true' '
80         test_stat_and_patch true true --stat -p
81 '
82
83 test_done