Remove the cpio emulator script.
[git/mingw.git] / git-ls-remote.sh
blobb290b95eef3c9a5955337c04a632b9047417ea26
1 #!/bin/sh
4 usage () {
5 echo >&2 "usage: $0 [--heads] [--tags] [-u|--upload-pack <upload-pack>]"
6 echo >&2 " <repository> <refs>..."
7 exit 1;
10 die () {
11 echo >&2 "$*"
12 exit 1
15 # Fix some commands on Windows
16 case $(uname -s) in
17 *MINGW*)
18 # Windows has its own (incompatible) sort and find
19 sort () {
20 /usr/bin/sort "$@"
22 find () {
23 /usr/bin/find "$@"
26 esac
28 exec=
29 while test $# != 0
31 case "$1" in
32 -h|--h|--he|--hea|--head|--heads)
33 heads=heads; shift ;;
34 -t|--t|--ta|--tag|--tags)
35 tags=tags; shift ;;
36 -u|--u|--up|--upl|--uploa|--upload|--upload-|--upload-p|--upload-pa|\
37 --upload-pac|--upload-pack)
38 shift
39 exec="--upload-pack=$1"
40 shift;;
41 -u=*|--u=*|--up=*|--upl=*|--uplo=*|--uploa=*|--upload=*|\
42 --upload-=*|--upload-p=*|--upload-pa=*|--upload-pac=*|--upload-pack=*)
43 exec=--upload-pack=$(expr "z$1" : 'z-[^=]*=\(.*\)')
44 shift;;
45 --)
46 shift; break ;;
47 -*)
48 usage ;;
50 break ;;
51 esac
52 done
54 case "$#" in 0) usage ;; esac
56 case ",$heads,$tags," in
57 ,,,) heads=heads tags=tags other=other ;;
58 esac
60 . git-parse-remote
61 peek_repo="$(get_remote_url "$@")"
62 shift
64 tmp=.ls-remote-$$
65 trap "rm -fr $tmp-*" 0 1 2 3 15
66 tmpdir=$tmp-d
68 case "$peek_repo" in
69 http://* | https://* | ftp://* )
70 if [ -n "$GIT_SSL_NO_VERIFY" ]; then
71 curl_extra_args="-k"
73 if [ -n "$GIT_CURL_FTP_NO_EPSV" -o \
74 "`git config --bool http.noEPSV`" = true ]; then
75 curl_extra_args="${curl_extra_args} --disable-epsv"
77 curl -nsf $curl_extra_args --header "Pragma: no-cache" "$peek_repo/info/refs" ||
78 echo "failed slurping"
81 rsync://* )
82 mkdir $tmpdir &&
83 rsync -rlq "$peek_repo/HEAD" $tmpdir &&
84 rsync -rq "$peek_repo/refs" $tmpdir || {
85 echo "failed slurping"
86 exit
88 head=$(cat "$tmpdir/HEAD") &&
89 case "$head" in
90 ref:' '*)
91 head=$(expr "z$head" : 'zref: \(.*\)') &&
92 head=$(cat "$tmpdir/$head") || exit
93 esac &&
94 echo "$head HEAD"
95 (cd $tmpdir && find refs -type f) |
96 while read path
98 tr -d '\012' <"$tmpdir/$path"
99 echo " $path"
100 done &&
101 rm -fr $tmpdir
105 if test -f "$peek_repo" ; then
106 git bundle list-heads "$peek_repo" ||
107 echo "failed slurping"
108 else
109 git-peek-remote $exec "$peek_repo" ||
110 echo "failed slurping"
113 esac |
114 sort -t ' ' -k 2 |
115 while read sha1 path
117 case "$sha1" in
118 failed)
119 exit 1 ;;
120 esac
121 case "$path" in
122 refs/heads/*)
123 group=heads ;;
124 refs/tags/*)
125 group=tags ;;
127 group=other ;;
128 esac
129 case ",$heads,$tags,$other," in
130 *,$group,*)
133 continue;;
134 esac
135 case "$#" in
137 match=yes ;;
139 match=no
140 for pat
142 case "/$path" in
143 */$pat )
144 match=yes
145 break ;;
146 esac
147 done
148 esac
149 case "$match" in
151 continue ;;
152 esac
153 echo "$sha1 $path"
154 done