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
14 for cmd
in rev-list
"log --stat"
20 test_expect_success
"check $cmd $*" '
21 git $cmd $(cat input) >expect &&
22 git $cmd --stdin <input >actual &&
23 sed -e "s/^/input /" input &&
24 sed -e "s/^/output /" expect &&
25 test_cmp expect actual
32 test_expect_success setup
'
38 echo $i.$j >file-$j &&
39 git add file-$j || exit
42 git commit -m $i || exit
46 git checkout -b side-$i main~$i &&
47 echo updated $i >file-$i &&
50 git commit -m side-$i || exit
53 git update-ref refs/heads/-dashed-branch HEAD
59 check side-1 ^side-7
--
60 check side-1 ^side-7
-- file-1
61 check side-1 ^side-7
-- file-2
62 check side-3 ^side-4
-- file-3
64 check side-3 ^side-2
-- file-1
66 check
--all --not --branches
67 check
--glob=refs
/heads
68 check
--glob=refs
/heads
--
69 check
--glob=refs
/heads
-- file-1
70 check
--end-of-options -dashed-branch
71 check
--all --not refs
/heads
/main
73 test_expect_success
'not only --stdin' '
85 git log --pretty=tformat:%s --name-only --stdin main -- file-1 \
87 test_cmp expect actual
90 test_expect_success
'pseudo-opt with missing value' '
97 fatal: Option ${SQ}--glob${SQ} requires a value
100 test_must_fail git rev-list --stdin <input 2>error &&
101 test_cmp expect error
104 test_expect_success
'pseudo-opt with invalid value' '
109 cat >expect <<-EOF &&
110 error: invalid argument to --no-walk
111 fatal: invalid option ${SQ}--no-walk=garbage${SQ} in --stdin mode
114 test_must_fail git rev-list --stdin <input 2>error &&
115 test_cmp expect error
118 test_expect_success
'unknown option without --end-of-options' '
123 cat >expect <<-EOF &&
124 fatal: invalid option ${SQ}-dashed-branch${SQ} in --stdin mode
127 test_must_fail git rev-list --stdin <input 2>error &&
128 test_cmp expect error
131 test_expect_success
'--not on command line does not influence revisions read via --stdin' '
135 git rev-list refs/heads/main >expect &&
137 git rev-list refs/heads/main --not --stdin <input >actual &&
138 test_cmp expect actual
141 test_expect_success
'--not via stdin does not influence revisions from command line' '
145 git rev-list refs/heads/main >expect &&
147 git rev-list refs/heads/main --stdin refs/heads/main <input >actual &&
148 test_cmp expect actual