git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] git-fetch: reuse ls-remote result.

From
Junio C Hamano <junkio@cox.net>
Date
Nov 23, 2006, 07:24 UTC
Message-ID
<7vbqmylj6z.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200611222213.44336.andyparkins@gmail.com>

This will become necessary to update the dumb protocol transports to fetch from a repository with packed and then pruned tags.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * I am doing this to allow dumb protocol transports to work
   with a repository with packed and then pruned refs, but it
   should be reusable for other purposes, such as wildcarding the
   refspecs Andy is interested in.
 git-fetch.sh |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/git-fetch.sh b/git-fetch.sh
index eb32476..170c2cb 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -88,6 +88,10 @@ then
 	: >"$GIT_DIR/FETCH_HEAD"
 fi
 
+# Global that is reused later
+ls_remote_result=$(git ls-remote $upload_pack "$remote") ||
+	die "Cannot find the reflist at $remote"
+
 append_fetch_head () {
     head_="$1"
     remote_="$2"
@@ -233,10 +237,7 @@ reflist=$(get_remote_refs_for_fetch "$@"
 if test "$tags"
 then
 	taglist=`IFS="	" &&
-		  (
-			git-ls-remote $upload_pack --tags "$remote" ||
-			echo fail ouch
-		  ) |
+		  echo "$ls_remote_result" |
 	          while read sha1 name
 		  do
 			case "$sha1" in
@@ -245,6 +246,8 @@ then
 			esac
 			case "$name" in
 			*^*) continue ;;
+			refs/tags/*) ;;
+			*) continue ;;
 			esac
 		  	if git-check-ref-format "$name"
 			then
@@ -431,7 +434,7 @@ case "$no_tags$tags" in
 		# effective only when we are following remote branch
 		# using local tracking branch.
 		taglist=$(IFS=" " &&
-		git-ls-remote $upload_pack --tags "$remote" |
+		echo "$ls_remote_result" |
 		sed -n	-e 's|^\('"$_x40"'\)	\(refs/tags/.*\)^{}$|\1 \2|p' \
 			-e 's|^\('"$_x40"'\)	\(refs/tags/.*\)$|\1 \2|p' |
 		while read sha1 name
-- 
1.4.4.1.g77614
Previous: Andy Parkins
Message 2 of 2 in “Implemented glob support in pull refspecs”
  1. Implemented glob support in pull refspecsAndy Parkins, Nov 22, 2006
  2. 1/3 git-fetch: reuse ls-remote result.Junio C Hamano, Nov 23, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.