[PATCH] git-merge-cache -q doesn't complain about failing merge program
[git/dscho.git] / git-ls-remote-script
blob921d3f8462b9cd9b3046e667c87c69beefce722d
1 #!/bin/sh
3 . git-sh-setup-script || die "Not a git archive"
5 usage () {
6 echo >&2 "usage: $0 [--heads] [--tags] [--overwrite | --store] repo"
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 -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 ;;
26 break ;;
27 esac
28 done
30 case "$#" in 1) ;; *) usage ;; esac
31 case ",$store,$overwrite," in *,,*) ;; *) usage ;; esac
33 case ",$heads,$tags," in
34 ,,,) heads=heads tags=tags other=other ;;
35 esac
37 . git-parse-remote "$@"
38 peek_repo="$_remote_repo"
40 tmp=.ls-remote-$$
41 trap "rm -fr $tmp-*" 0 1 2 3 15
42 tmpdir=$tmp-d
44 case "$peek_repo" in
45 http://* | https://* )
46 if [ -n "$GIT_SSL_NO_VERIFY" ]; then
47 curl_extra_args="-k"
49 curl -ns $curl_extra_args "$peek_repo/info/refs" || exit 1
52 rsync://* )
53 mkdir $tmpdir
54 rsync -rq "$peek_repo/refs" $tmpdir || exit 1
55 (cd $tmpdir && find refs -type f) |
56 while read path
58 cat "$tmpdir/$path" | tr -d '\012'
59 echo " $path"
60 done &&
61 rm -fr $tmpdir
64 * )
65 git-peek-remote "$peek_repo"
67 esac |
69 while read sha1 path
71 case "$path" in
72 refs/heads/*)
73 group=heads ;;
74 refs/tags/*)
75 group=tags ;;
77 group=other ;;
78 esac
79 case ",$heads,$tags,$other," in
80 *,$group,*)
83 continue;;
84 esac
86 echo "$sha1 $path"
88 case "$path,$store,$overwrite," in
89 *,,, | HEAD,*) continue ;;
90 esac
92 if test -f "$GIT_DIR/$path" && test "$overwrite" == ""
93 then
94 continue
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)."
104 done