]>
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 | |
38529e28 | 52 | http://* | https://* | ftp://* ) |
0fec0822 JH |
53 | if [ -n "$GIT_SSL_NO_VERIFY" ]; then |
54 | curl_extra_args="-k" | |
55 | fi | |
3ea099d4 SK |
56 | if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \ |
57 | "`git-repo-config --bool http.noEPSV`" = true ]; then | |
58 | curl_extra_args="${curl_extra_args} --disable-epsv" | |
59 | fi | |
7fa8ddd6 | 60 | curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" || |
a5cd85e0 | 61 | echo "failed slurping" |
0fec0822 JH |
62 | ;; |
63 | ||
64 | rsync://* ) | |
e686eba4 JH |
65 | mkdir $tmpdir && |
66 | rsync -rlq "$peek_repo/HEAD" $tmpdir && | |
a5cd85e0 JH |
67 | rsync -rq "$peek_repo/refs" $tmpdir || { |
68 | echo "failed slurping" | |
69 | exit | |
70 | } | |
e686eba4 JH |
71 | head=$(cat "$tmpdir/HEAD") && |
72 | case "$head" in | |
73 | ref:' '*) | |
74 | head=$(expr "z$head" : 'zref: \(.*\)') && | |
75 | head=$(cat "$tmpdir/$head") || exit | |
76 | esac && | |
77 | echo "$head HEAD" | |
0fec0822 JH |
78 | (cd $tmpdir && find refs -type f) | |
79 | while read path | |
80 | do | |
81 | cat "$tmpdir/$path" | tr -d '\012' | |
82 | echo " $path" | |
83 | done && | |
84 | rm -fr $tmpdir | |
85 | ;; | |
86 | ||
87 | * ) | |
96b086d6 | 88 | git-peek-remote $exec "$peek_repo" || |
a5cd85e0 | 89 | echo "failed slurping" |
0fec0822 JH |
90 | ;; |
91 | esac | | |
972b6fe7 | 92 | sort -t ' ' -k 2 | |
0fec0822 JH |
93 | while read sha1 path |
94 | do | |
a5cd85e0 JH |
95 | case "$sha1" in |
96 | failed) | |
b3d98993 | 97 | exit 1 ;; |
a5cd85e0 | 98 | esac |
0fec0822 JH |
99 | case "$path" in |
100 | refs/heads/*) | |
101 | group=heads ;; | |
102 | refs/tags/*) | |
103 | group=tags ;; | |
104 | *) | |
105 | group=other ;; | |
106 | esac | |
107 | case ",$heads,$tags,$other," in | |
108 | *,$group,*) | |
109 | ;; | |
110 | *) | |
111 | continue;; | |
112 | esac | |
972b6fe7 JH |
113 | case "$#" in |
114 | 0) | |
115 | match=yes ;; | |
116 | *) | |
117 | match=no | |
118 | for pat | |
119 | do | |
120 | case "/$path" in | |
121 | */$pat ) | |
122 | match=yes | |
123 | break ;; | |
124 | esac | |
125 | done | |
0fec0822 | 126 | esac |
972b6fe7 JH |
127 | case "$match" in |
128 | no) | |
129 | continue ;; | |
130 | esac | |
131 | echo "$sha1 $path" | |
0fec0822 | 132 | done |