Sync with 'maint'
[alt-git.git] / t / t3907-stash-show-config.sh
blob7a2eb98b86426ea7657fdce73cb8c0cb3a6d2848
1 #!/bin/sh
3 test_description='Test git stash show configuration.'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup' '
9 test_commit file
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 &&
24 if test "<unset>" = "$2"
25 then
26 test_unconfig stash.showPatch
27 else
28 test_config stash.showPatch "$2"
29 fi &&
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 &&
40 if test $# = 0
41 then
42 test_must_be_empty actual
43 else
44 test_cmp expect actual
48 test_expect_success 'showStat unset showPatch unset' '
49 test_stat_and_patch "<unset>" "<unset>" --stat
52 test_expect_success 'showStat unset showPatch false' '
53 test_stat_and_patch "<unset>" false --stat
56 test_expect_success 'showStat unset showPatch true' '
57 test_stat_and_patch "<unset>" true --stat -p
60 test_expect_success 'showStat false showPatch unset' '
61 test_stat_and_patch false "<unset>"
64 test_expect_success 'showStat false showPatch false' '
65 test_stat_and_patch false false
68 test_expect_success 'showStat false showPatch true' '
69 test_stat_and_patch false true -p
72 test_expect_success 'showStat true showPatch unset' '
73 test_stat_and_patch true "<unset>" --stat
76 test_expect_success 'showStat true showPatch false' '
77 test_stat_and_patch true false --stat
80 test_expect_success 'showStat true showPatch true' '
81 test_stat_and_patch true true --stat -p
84 test_done