{"thread":{"id":"3971","subject":"[PATCH] git-fetch: resolve remote symrefs for HTTP transport","startedAt":"2006-04-26T16:10:01Z","lastAt":"2006-04-26T17:09:46Z","messageCount":2,"participants":["Nick Hengeveld","Shawn Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"19160","messageId":"20060426161001.GH32744@reactrix.com","threadId":"3971","inReplyTo":null,"subject":"[PATCH] git-fetch: resolve remote symrefs for HTTP transport","fromName":"Nick Hengeveld","fromEmail":"nickh@reactrix.com","sentAt":"2006-04-26T16:10:01Z","receivedAt":"2006-04-26T16:10:01Z","isPatch":true,"sender":{"key":"nickh@reactrix.com","avatar":null},"body":"git-fetch validates that a remote ref resolves to a SHA1 prior to calling\ngit-http-fetch.  This adds support for resolving a few levels of symrefs\nto get to the SHA1.\n\nSigned-off-by: Nick Hengeveld <nickh@reactrix.com>\n\n\n---\n\nMaybe this isn't the right way to handle this - since we're already\ncalling perl we could use LWP to do the transfers (using keepalive\neven?) or we could let git-http-fetch take care of it and deal with\nremote names that don't resolve.  It may also make sense to modify\ngit-http-fetch so it can fetch more than one head at a time.\n\n git-fetch.sh |   16 ++++++++++++----\n 1 files changed, 12 insertions(+), 4 deletions(-)\n\naa50f9012834993d8bd080050bc13b23465f9185\ndiff --git a/git-fetch.sh b/git-fetch.sh\nindex 83143f8..280f62e 100755\n--- a/git-fetch.sh\n+++ b/git-fetch.sh\n@@ -270,14 +270,22 @@ fetch_main () {\n \t  if [ -n \"$GIT_SSL_NO_VERIFY\" ]; then\n \t      curl_extra_args=\"-k\"\n \t  fi\n-\t  remote_name_quoted=$(perl -e '\n+\t  max_depth=5\n+\t  depth=0\n+\t  head=\"ref: $remote_name\"\n+\t  while (expr \"z$head\" : \"zref:\" && expr $depth \\< $max_depth) >/dev/null\n+\t  do\n+\t    remote_name_quoted=$(perl -e '\n \t      my $u = $ARGV[0];\n+              $u =~ s/^ref:\\s*//;\n \t      $u =~ s{([^-a-zA-Z0-9/.])}{sprintf\"%%%02x\",ord($1)}eg;\n \t      print \"$u\";\n-\t  ' \"$remote_name\")\n-\t  head=$(curl -nsfL $curl_extra_args \"$remote/$remote_name_quoted\") &&\n+\t  ' \"$head\")\n+\t    head=$(curl -nsfL $curl_extra_args \"$remote/$remote_name_quoted\")\n+\t    depth=$( expr \\( $depth + 1 \\) )\n+\t  done\n \t  expr \"z$head\" : \"z$_x40\\$\" >/dev/null ||\n-\t\t  die \"Failed to fetch $remote_name from $remote\"\n+\t      die \"Failed to fetch $remote_name from $remote\"\n \t  echo >&2 Fetching \"$remote_name from $remote\" using http\n \t  git-http-fetch -v -a \"$head\" \"$remote/\" || exit\n \t  ;;\n-- \n1.3.0.g368f0-dirty\n"},{"id":"19161","messageId":"20060426170946.GA7843@spearce.org","threadId":"3971","inReplyTo":"20060426161001.GH32744@reactrix.com","subject":"Re: [PATCH] git-fetch: resolve remote symrefs for HTTP transport","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2006-04-26T17:09:46Z","receivedAt":"2006-04-26T17:09:46Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Nick Hengeveld <nickh@reactrix.com> wrote:\n> \n> Maybe this isn't the right way to handle this - since we're already\n> calling perl we could use LWP to do the transfers (using keepalive\n> even?)\n\nLWP, no.  My Mac OS X perl installation appears to have LWP installed\nby dumb luck but my Gentoo Linux perl doesn't have LWP anywhere\nin @INC.  :-) Yet both systems run GIT happily.\n\nThe HTTP support in GIT is already linked against libcurl and libcurl\nis required to use said HTTP support.  I would think that libcurl\nis capable of using Keep-Alive when possible, and libcurl and C\nare certainly available anywhere GIT's HTTP support is currently\nbeing used.  Ideally any HTTP feature should either be using the\ncurl command line tool, or better, be written in C against the\nlibcurl library.  But not LWP.  Its not always available even though\na valid perl is.\n\n-- \nShawn.\n"}]}