3 # Copyright (c) 2009, Junio C Hamano
6 test_description
='log family learns --stdin'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 TEST_PASSES_SANITIZE_LEAK
=true
15 for cmd
in rev-list
"log --stat"
21 test_expect_success
"check $cmd $*" '
22 git $cmd $(cat input) >expect &&
23 git $cmd --stdin <input >actual &&
24 sed -e "s/^/input /" input &&
25 sed -e "s/^/output /" expect &&
26 test_cmp expect actual
33 test_expect_success setup
'
39 echo $i.$j >file-$j &&
40 git add file-$j || exit
43 git commit -m $i || exit
47 git checkout -b side-$i main~$i &&
48 echo updated $i >file-$i &&
51 git commit -m side-$i || exit
54 git update-ref refs/heads/-dashed-branch HEAD
60 check side-1 ^side-7
--
61 check side-1 ^side-7
-- file-1
62 check side-1 ^side-7
-- file-2
63 check side-3 ^side-4
-- file-3
65 check side-3 ^side-2
-- file-1
67 check
--all --not --branches
68 check
--glob=refs
/heads
69 check
--glob=refs
/heads
--
70 check
--glob=refs
/heads
-- file-1
71 check
--end-of-options -dashed-branch
72 check
--all --not refs
/heads
/main
74 test_expect_success
'not only --stdin' '
86 git log --pretty=tformat:%s --name-only --stdin main -- file-1 \
88 test_cmp expect actual
91 test_expect_success
'pseudo-opt with missing value' '
98 fatal: Option ${SQ}--glob${SQ} requires a value
101 test_must_fail git rev-list --stdin <input 2>error &&
102 test_cmp expect error
105 test_expect_success
'pseudo-opt with invalid value' '
110 cat >expect <<-EOF &&
111 error: invalid argument to --no-walk
112 fatal: invalid option ${SQ}--no-walk=garbage${SQ} in --stdin mode
115 test_must_fail git rev-list --stdin <input 2>error &&
116 test_cmp expect error
119 test_expect_success
'unknown option without --end-of-options' '
124 cat >expect <<-EOF &&
125 fatal: invalid option ${SQ}-dashed-branch${SQ} in --stdin mode
128 test_must_fail git rev-list --stdin <input 2>error &&
129 test_cmp expect error
132 test_expect_success
'--not on command line does not influence revisions read via --stdin' '
136 git rev-list refs/heads/main >expect &&
138 git rev-list refs/heads/main --not --stdin <input >actual &&
139 test_cmp expect actual
142 test_expect_success
'--not via stdin does not influence revisions from command line' '
146 git rev-list refs/heads/main >expect &&
148 git rev-list refs/heads/main --stdin refs/heads/main <input >actual &&
149 test_cmp expect actual