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