]>
Commit | Line | Data |
---|---|---|
0fec0822 JH |
1 | #!/bin/sh |
2 | # | |
12aac5de | 3 | . git-sh-setup |
0fec0822 JH |
4 | |
5 | usage () { | |
972b6fe7 | 6 | echo >&2 "usage: $0 [--heads] [--tags] <repository> <refs>..." |
0fec0822 JH |
7 | exit 1; |
8 | } | |
9 | ||
10 | while case "$#" in 0) break;; esac | |
11 | do | |
12 | case "$1" in | |
13 | -h|--h|--he|--hea|--head|--heads) | |
14 | heads=heads; shift ;; | |
0fec0822 JH |
15 | -t|--t|--ta|--tag|--tags) |
16 | tags=tags; shift ;; | |
17 | --) | |
18 | shift; break ;; | |
19 | -*) | |
20 | usage ;; | |
21 | *) | |
22 | break ;; | |
23 | esac | |
24 | done | |
25 | ||
972b6fe7 | 26 | case "$#" in 0) usage ;; esac |
0fec0822 JH |
27 | |
28 | case ",$heads,$tags," in | |
29 | ,,,) heads=heads tags=tags other=other ;; | |
30 | esac | |
31 | ||
215a7ad1 | 32 | . git-parse-remote |
e0bfc81e | 33 | peek_repo="$(get_remote_url "$@")" |
972b6fe7 | 34 | shift |
0fec0822 JH |
35 | |
36 | tmp=.ls-remote-$$ | |
37 | trap "rm -fr $tmp-*" 0 1 2 3 15 | |
38 | tmpdir=$tmp-d | |
39 | ||
40 | case "$peek_repo" in | |
41 | http://* | https://* ) | |
42 | if [ -n "$GIT_SSL_NO_VERIFY" ]; then | |
43 | curl_extra_args="-k" | |
44 | fi | |
a5cd85e0 JH |
45 | curl -nsf $curl_extra_args "$peek_repo/info/refs" || |
46 | echo "failed slurping" | |
0fec0822 JH |
47 | ;; |
48 | ||
49 | rsync://* ) | |
50 | mkdir $tmpdir | |
a5cd85e0 JH |
51 | rsync -rq "$peek_repo/refs" $tmpdir || { |
52 | echo "failed slurping" | |
53 | exit | |
54 | } | |
0fec0822 JH |
55 | (cd $tmpdir && find refs -type f) | |
56 | while read path | |
57 | do | |
58 | cat "$tmpdir/$path" | tr -d '\012' | |
59 | echo " $path" | |
60 | done && | |
61 | rm -fr $tmpdir | |
62 | ;; | |
63 | ||
64 | * ) | |
a5cd85e0 JH |
65 | git-peek-remote "$peek_repo" || |
66 | echo "failed slurping" | |
0fec0822 JH |
67 | ;; |
68 | esac | | |
972b6fe7 | 69 | sort -t ' ' -k 2 | |
0fec0822 JH |
70 | while read sha1 path |
71 | do | |
a5cd85e0 JH |
72 | case "$sha1" in |
73 | failed) | |
74 | die "Failed to find remote refs" | |
75 | esac | |
0fec0822 JH |
76 | case "$path" in |
77 | refs/heads/*) | |
78 | group=heads ;; | |
79 | refs/tags/*) | |
80 | group=tags ;; | |
81 | *) | |
82 | group=other ;; | |
83 | esac | |
84 | case ",$heads,$tags,$other," in | |
85 | *,$group,*) | |
86 | ;; | |
87 | *) | |
88 | continue;; | |
89 | esac | |
972b6fe7 JH |
90 | case "$#" in |
91 | 0) | |
92 | match=yes ;; | |
93 | *) | |
94 | match=no | |
95 | for pat | |
96 | do | |
97 | case "/$path" in | |
98 | */$pat ) | |
99 | match=yes | |
100 | break ;; | |
101 | esac | |
102 | done | |
0fec0822 | 103 | esac |
972b6fe7 JH |
104 | case "$match" in |
105 | no) | |
106 | continue ;; | |
107 | esac | |
108 | echo "$sha1 $path" | |
0fec0822 | 109 | done |