GIT 0.99.4.
[git/mingw.git] / git-ls-remote-script
blob75f60278669851d627a9ff2f8e87c9382af72c6a
1 #!/bin/sh
3 . git-sh-setup-script || die "Not a git archive"
5 usage () {
6 echo >&2 "usage: $0 [--heads] [--tags] <repository> <refs>..."
7 exit 1;
10 while case "$#" in 0) break;; esac
12 case "$1" in
13 -h|--h|--he|--hea|--head|--heads)
14 heads=heads; shift ;;
15 -t|--t|--ta|--tag|--tags)
16 tags=tags; shift ;;
17 --)
18 shift; break ;;
19 -*)
20 usage ;;
22 break ;;
23 esac
24 done
26 case "$#" in 0) usage ;; esac
28 case ",$heads,$tags," in
29 ,,,) heads=heads tags=tags other=other ;;
30 esac
32 . git-parse-remote "$1"
33 peek_repo="$_remote_repo"
34 shift
36 tmp=.ls-remote-$$
37 trap "rm -fr $tmp-*" 0 1 2 3 15
38 tmpdir=$tmp-d
40 case "$peek_repo" in
41 http://* | https://* )
42 if [ -n "$GIT_SSL_NO_VERIFY" ]; then
43 curl_extra_args="-k"
45 curl -nsf $curl_extra_args "$peek_repo/info/refs" || exit 1
48 rsync://* )
49 mkdir $tmpdir
50 rsync -rq "$peek_repo/refs" $tmpdir || exit 1
51 (cd $tmpdir && find refs -type f) |
52 while read path
54 cat "$tmpdir/$path" | tr -d '\012'
55 echo " $path"
56 done &&
57 rm -fr $tmpdir
60 * )
61 git-peek-remote "$peek_repo"
63 esac |
64 sort -t ' ' -k 2 |
65 while read sha1 path
67 case "$path" in
68 refs/heads/*)
69 group=heads ;;
70 refs/tags/*)
71 group=tags ;;
73 group=other ;;
74 esac
75 case ",$heads,$tags,$other," in
76 *,$group,*)
79 continue;;
80 esac
81 case "$#" in
83 match=yes ;;
85 match=no
86 for pat
88 case "/$path" in
89 */$pat )
90 match=yes
91 break ;;
92 esac
93 done
94 esac
95 case "$match" in
96 no)
97 continue ;;
98 esac
99 echo "$sha1 $path"
100 done