Merge branch 'ja/doc-synopsis-markup'
[git/gitster.git] / t / t6017-rev-list-stdin.sh
bloba0a40fe55cd8f78eaf2182c73754088fb38d4388
1 #!/bin/sh
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
12 . ./test-lib.sh
14 check () {
15 for cmd in rev-list "log --stat"
17 for i in "$@"
19 printf "%s\n" $i
20 done >input &&
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
28 done
31 them='1 2 3 4 5 6 7'
33 test_expect_success setup '
35 for i in 0 $them
37 for j in $them
39 echo $i.$j >file-$j &&
40 git add file-$j || exit
41 done &&
42 test_tick &&
43 git commit -m $i || exit
44 done &&
45 for i in $them
47 git checkout -b side-$i main~$i &&
48 echo updated $i >file-$i &&
49 git add file-$i &&
50 test_tick &&
51 git commit -m side-$i || exit
52 done &&
54 git update-ref refs/heads/-dashed-branch HEAD
58 check main
59 check side-1 ^side-4
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
64 check side-3 ^side-2
65 check side-3 ^side-2 -- file-1
66 check --all
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' '
75 cat >expect <<-EOF &&
78 file-1
79 file-2
80 EOF
81 cat >input <<-EOF &&
82 ^main^
84 file-2
85 EOF
86 git log --pretty=tformat:%s --name-only --stdin main -- file-1 \
87 <input >actual &&
88 test_cmp expect actual
91 test_expect_success 'pseudo-opt with missing value' '
92 cat >input <<-EOF &&
93 --glob
94 refs/heads
95 EOF
97 cat >expect <<-EOF &&
98 fatal: Option ${SQ}--glob${SQ} requires a value
99 EOF
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' '
106 cat >input <<-EOF &&
107 --no-walk=garbage
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' '
120 cat >input <<-EOF &&
121 -dashed-branch
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' '
133 cat >input <<-EOF &&
134 refs/heads/main
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' '
143 cat >input <<-EOF &&
144 --not
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
152 test_done