Start the 2.46 cycle
[git/gitster.git] / t / t3907-stash-show-config.sh
blob10914bba7b3737ea89af320f93371e44b4694a11
1 #!/bin/sh
3 test_description='Test git stash show configuration.'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 test_commit file
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 &&
23 if test "<unset>" = "$2"
24 then
25 test_unconfig stash.showPatch
26 else
27 test_config stash.showPatch "$2"
28 fi &&
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 &&
39 if test $# = 0
40 then
41 test_must_be_empty actual
42 else
43 test_cmp expect actual
47 test_expect_success 'showStat unset showPatch unset' '
48 test_stat_and_patch "<unset>" "<unset>" --stat
51 test_expect_success 'showStat unset showPatch false' '
52 test_stat_and_patch "<unset>" false --stat
55 test_expect_success 'showStat unset showPatch true' '
56 test_stat_and_patch "<unset>" true --stat -p
59 test_expect_success 'showStat false showPatch unset' '
60 test_stat_and_patch false "<unset>"
63 test_expect_success 'showStat false showPatch false' '
64 test_stat_and_patch false false
67 test_expect_success 'showStat false showPatch true' '
68 test_stat_and_patch false true -p
71 test_expect_success 'showStat true showPatch unset' '
72 test_stat_and_patch true "<unset>" --stat
75 test_expect_success 'showStat true showPatch false' '
76 test_stat_and_patch true false --stat
79 test_expect_success 'showStat true showPatch true' '
80 test_stat_and_patch true true --stat -p
83 test_done