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