]>
Commit | Line | Data |
---|---|---|
d21fc934 JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2009, Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='log family learns --stdin' | |
7 | ||
1550bb6e | 8 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
9 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
10 | ||
d21fc934 JH |
11 | . ./test-lib.sh |
12 | ||
13 | check () { | |
14 | for cmd in rev-list "log --stat" | |
15 | do | |
16 | for i in "$@" | |
17 | do | |
18 | printf "%s\n" $i | |
19 | done >input && | |
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 | |
26 | ' | |
27 | done | |
28 | } | |
29 | ||
30 | them='1 2 3 4 5 6 7' | |
31 | ||
32 | test_expect_success setup ' | |
33 | ( | |
34 | for i in 0 $them | |
35 | do | |
36 | for j in $them | |
37 | do | |
38 | echo $i.$j >file-$j && | |
39 | git add file-$j || exit | |
40 | done && | |
41 | test_tick && | |
42 | git commit -m $i || exit | |
43 | done && | |
44 | for i in $them | |
45 | do | |
1550bb6e | 46 | git checkout -b side-$i main~$i && |
d21fc934 JH |
47 | echo updated $i >file-$i && |
48 | git add file-$i && | |
49 | test_tick && | |
50 | git commit -m side-$i || exit | |
c40f0b78 PS |
51 | done && |
52 | ||
53 | git update-ref refs/heads/-dashed-branch HEAD | |
d21fc934 JH |
54 | ) |
55 | ' | |
56 | ||
1550bb6e | 57 | check main |
d21fc934 JH |
58 | check side-1 ^side-4 |
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 | |
63 | check side-3 ^side-2 | |
64 | check side-3 ^side-2 -- file-1 | |
c40f0b78 PS |
65 | check --all |
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 | |
d21fc934 | 71 | |
4da5af31 JH |
72 | test_expect_success 'not only --stdin' ' |
73 | cat >expect <<-EOF && | |
74 | 7 | |
75 | ||
76 | file-1 | |
77 | file-2 | |
78 | EOF | |
79 | cat >input <<-EOF && | |
1550bb6e | 80 | ^main^ |
4da5af31 JH |
81 | -- |
82 | file-2 | |
83 | EOF | |
1550bb6e | 84 | git log --pretty=tformat:%s --name-only --stdin main -- file-1 \ |
4da5af31 JH |
85 | <input >actual && |
86 | test_cmp expect actual | |
87 | ' | |
88 | ||
c40f0b78 PS |
89 | test_expect_success 'pseudo-opt with missing value' ' |
90 | cat >input <<-EOF && | |
91 | --glob | |
92 | refs/heads | |
93 | EOF | |
94 | ||
95 | cat >expect <<-EOF && | |
96 | fatal: Option ${SQ}--glob${SQ} requires a value | |
97 | EOF | |
98 | ||
99 | test_must_fail git rev-list --stdin <input 2>error && | |
100 | test_cmp expect error | |
101 | ' | |
102 | ||
103 | test_expect_success 'pseudo-opt with invalid value' ' | |
104 | cat >input <<-EOF && | |
105 | --no-walk=garbage | |
106 | EOF | |
107 | ||
108 | cat >expect <<-EOF && | |
109 | error: invalid argument to --no-walk | |
110 | fatal: invalid option ${SQ}--no-walk=garbage${SQ} in --stdin mode | |
111 | EOF | |
112 | ||
113 | test_must_fail git rev-list --stdin <input 2>error && | |
114 | test_cmp expect error | |
115 | ' | |
116 | ||
117 | test_expect_success 'unknown option without --end-of-options' ' | |
118 | cat >input <<-EOF && | |
119 | -dashed-branch | |
120 | EOF | |
121 | ||
122 | cat >expect <<-EOF && | |
123 | fatal: invalid option ${SQ}-dashed-branch${SQ} in --stdin mode | |
124 | EOF | |
125 | ||
126 | test_must_fail git rev-list --stdin <input 2>error && | |
127 | test_cmp expect error | |
128 | ' | |
129 | ||
d21fc934 | 130 | test_done |