]> git.ipfire.org Git - thirdparty/git.git/blame - git-ls-remote-script
Teach format-patch, rebase and cherry a..b format
[thirdparty/git.git] / git-ls-remote-script
CommitLineData
0fec0822
JH
1#!/bin/sh
2#
3. git-sh-setup-script || die "Not a git archive"
4
5usage () {
6 echo >&2 "usage: $0 [--heads] [--tags] [--overwrite | --store] repo"
7 exit 1;
8}
9
10while case "$#" in 0) break;; esac
11do
12 case "$1" in
13 -h|--h|--he|--hea|--head|--heads)
14 heads=heads; shift ;;
15 -o|--o|--ov|--ove|--over|--overw|--overwr|--overwri|--overwrit|--overwrite)
16 overwrite=overwrite; shift ;;
17 -s|--s|--st|--sto|--stor|--store)
18 store=store; shift ;;
19 -t|--t|--ta|--tag|--tags)
20 tags=tags; shift ;;
21 --)
22 shift; break ;;
23 -*)
24 usage ;;
25 *)
26 break ;;
27 esac
28done
29
30case "$#" in 1) ;; *) usage ;; esac
31case ",$store,$overwrite," in *,,*) ;; *) usage ;; esac
32
33case ",$heads,$tags," in
34,,,) heads=heads tags=tags other=other ;;
35esac
36
37. git-parse-remote "$@"
38peek_repo="$_remote_repo"
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
affa40d2 49 curl -nsf $curl_extra_args "$peek_repo/info/refs" || exit 1
0fec0822
JH
50 ;;
51
52rsync://* )
53 mkdir $tmpdir
54 rsync -rq "$peek_repo/refs" $tmpdir || exit 1
55 (cd $tmpdir && find refs -type f) |
56 while read path
57 do
58 cat "$tmpdir/$path" | tr -d '\012'
59 echo " $path"
60 done &&
61 rm -fr $tmpdir
62 ;;
63
64* )
65 git-peek-remote "$peek_repo"
66 ;;
67esac |
68
69while read sha1 path
70do
71 case "$path" in
72 refs/heads/*)
73 group=heads ;;
74 refs/tags/*)
75 group=tags ;;
76 *)
77 group=other ;;
78 esac
79 case ",$heads,$tags,$other," in
80 *,$group,*)
81 ;;
82 *)
83 continue;;
84 esac
85
86 echo "$sha1 $path"
87
88 case "$path,$store,$overwrite," in
89 *,,, | HEAD,*) continue ;;
90 esac
91
92 if test -f "$GIT_DIR/$path" && test "$overwrite" == ""
93 then
94 continue
95 fi
96
97 # Be careful. We may not have that object yet!
98 if git-cat-file -t "$sha1" >/dev/null 2>&1
99 then
100 echo "$sha1" >"$GIT_DIR/$path"
101 else
102 echo >&2 "* You have not fetched updated $path ($sha1)."
103 fi
104done