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