git-ls-remote.shon commit Fix git-verify-tag for light-weight tags (5a6850e)
   1#!/bin/sh
   2#
   3. git-sh-setup || die "Not a git archive"
   4
   5usage () {
   6    echo >&2 "usage: $0 [--heads] [--tags] <repository> <refs>..."
   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  -t|--t|--ta|--tag|--tags)
  16  tags=tags; shift ;;
  17  --)
  18  shift; break ;;
  19  -*)
  20  usage ;;
  21  *)
  22  break ;;
  23  esac
  24done
  25
  26case "$#" in 0) usage ;; esac
  27
  28case ",$heads,$tags," in
  29,,,) heads=heads tags=tags other=other ;;
  30esac
  31
  32. git-parse-remote
  33peek_repo="$(get_remote_url "$@")"
  34shift
  35
  36tmp=.ls-remote-$$
  37trap "rm -fr $tmp-*" 0 1 2 3 15
  38tmpdir=$tmp-d
  39
  40case "$peek_repo" in
  41http://* | https://* )
  42        if [ -n "$GIT_SSL_NO_VERIFY" ]; then
  43            curl_extra_args="-k"
  44        fi
  45        curl -nsf $curl_extra_args "$peek_repo/info/refs" ||
  46                echo "failed    slurping"
  47        ;;
  48
  49rsync://* )
  50        mkdir $tmpdir
  51        rsync -rq "$peek_repo/refs" $tmpdir || {
  52                echo "failed    slurping"
  53                exit
  54        }
  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                echo "failed    slurping"
  67        ;;
  68esac |
  69sort -t '       ' -k 2 |
  70while read sha1 path
  71do
  72        case "$sha1" in
  73        failed)
  74                die "Failed to find remote refs"
  75        esac
  76        case "$path" in
  77        refs/heads/*)
  78                group=heads ;;
  79        refs/tags/*)
  80                group=tags ;;
  81        *)
  82                group=other ;;
  83        esac
  84        case ",$heads,$tags,$other," in
  85        *,$group,*)
  86                ;;
  87        *)
  88                continue;;
  89        esac
  90        case "$#" in
  91        0)
  92                match=yes ;;
  93        *)
  94                match=no
  95                for pat
  96                do
  97                        case "/$path" in
  98                        */$pat )
  99                                match=yes
 100                                break ;;
 101                        esac
 102                done
 103        esac
 104        case "$match" in
 105        no)
 106                continue ;;
 107        esac
 108        echo "$sha1     $path"
 109done