git-p4: add options --commit and --disable-rebase
[git] / t / t6017-rev-list-stdin.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2009, Junio C Hamano
4 #
5
6 test_description='log family learns --stdin'
7
8 . ./test-lib.sh
9
10 check () {
11         for cmd in rev-list "log --stat"
12         do
13                 for i in "$@"
14                 do
15                         printf "%s\n" $i
16                 done >input &&
17                 test_expect_success "check $cmd $*" '
18                         git $cmd $(cat input) >expect &&
19                         git $cmd --stdin <input >actual &&
20                         sed -e "s/^/input /" input &&
21                         sed -e "s/^/output /" expect &&
22                         test_cmp expect actual
23                 '
24         done
25 }
26
27 them='1 2 3 4 5 6 7'
28
29 test_expect_success setup '
30         (
31                 for i in 0 $them
32                 do
33                         for j in $them
34                         do
35                                 echo $i.$j >file-$j &&
36                                 git add file-$j || exit
37                         done &&
38                         test_tick &&
39                         git commit -m $i || exit
40                 done &&
41                 for i in $them
42                 do
43                         git checkout -b side-$i master~$i &&
44                         echo updated $i >file-$i &&
45                         git add file-$i &&
46                         test_tick &&
47                         git commit -m side-$i || exit
48                 done
49         )
50 '
51
52 check master
53 check side-1 ^side-4
54 check side-1 ^side-7 --
55 check side-1 ^side-7 -- file-1
56 check side-1 ^side-7 -- file-2
57 check side-3 ^side-4 -- file-3
58 check side-3 ^side-2
59 check side-3 ^side-2 -- file-1
60
61 test_expect_success 'not only --stdin' '
62         cat >expect <<-EOF &&
63         7
64
65         file-1
66         file-2
67         EOF
68         cat >input <<-EOF &&
69         ^master^
70         --
71         file-2
72         EOF
73         git log --pretty=tformat:%s --name-only --stdin master -- file-1 \
74                 <input >actual &&
75         test_cmp expect actual
76 '
77
78 test_done