read-cache: delete unused hashing methods
[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 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
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
46                         git checkout -b side-$i main~$i &&
47                         echo updated $i >file-$i &&
48                         git add file-$i &&
49                         test_tick &&
50                         git commit -m side-$i || exit
51                 done
52         )
53 '
54
55 check main
56 check side-1 ^side-4
57 check side-1 ^side-7 --
58 check side-1 ^side-7 -- file-1
59 check side-1 ^side-7 -- file-2
60 check side-3 ^side-4 -- file-3
61 check side-3 ^side-2
62 check side-3 ^side-2 -- file-1
63
64 test_expect_success 'not only --stdin' '
65         cat >expect <<-EOF &&
66         7
67
68         file-1
69         file-2
70         EOF
71         cat >input <<-EOF &&
72         ^main^
73         --
74         file-2
75         EOF
76         git log --pretty=tformat:%s --name-only --stdin main -- file-1 \
77                 <input >actual &&
78         test_cmp expect actual
79 '
80
81 test_done