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

[PATCH repost] Multiple refs from the same remote in one git fetch

From
MTMichael S. Tsirkin <mst@mellanox.co.il>
Date
Aug 22, 2006, 15:10 UTC
Message-ID
<20060822151029.GA19247@mellanox.co.il>
In-Reply-To
<20060814051302.GB21963@mellanox.co.il>

Hi, Junio! Is the following likely to get merged eventually? It was pointed out that I can work-around the limitation by using softlinks, so it's not a show-stopper for me.

---
Fix git fetch for when multiple refspecs reference the same remote head.
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
diff --git a/connect.c b/connect.c
index 4422a0d..3880191 100644
--- a/connect.c
+++ b/connect.c
@@ -115,6 +115,7 @@ int get_ack(int fd, unsigned char *resul
 int path_match(const char *path, int nr, char **match)
 {
 	int i;
+	int found = 0;
 	int pathlen = strlen(path);
 
 	for (i = 0; i < nr; i++) {
@@ -128,9 +129,9 @@ int path_match(const char *path, int nr,
 		if (pathlen > len && path[pathlen - len - 1] != '/')
 			continue;
 		*s = 0;
-		return (i + 1);
+		found = i + 1;
 	}
-	return 0;
+	return found;
 }
 
 struct refspec {
diff --git a/git-fetch.sh b/git-fetch.sh
index c2eebee..328168b 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -366,33 +366,44 @@ fetch_main () {
 		  exit 1 ;;
 	  esac
 	  found=
-	  single_force=
+	  found_any=
 	  for ref in $refs
 	  do
 	      case "$ref" in
 	      +$remote_name:*)
 		  single_force=t
 		  not_for_merge=
-		  found="$ref"
-		  break ;;
+		  found="$ref";;
 	      .+$remote_name:*)
 		  single_force=t
 		  not_for_merge=t
-		  found="$ref"
-		  break ;;
+		  found="$ref";;
 	      .$remote_name:*)
+		  single_force=
 		  not_for_merge=t
-		  found="$ref"
-		  break ;;
+		  found="$ref";;
 	      $remote_name:*)
+		  single_force=
+		  not_for_merge=
+		  found="$ref";;
+	      *)
+		  single_force=
 		  not_for_merge=
-		  found="$ref"
-		  break ;;
+		  found=;;
 	      esac
+	      if test "$found" != ""
+	      then
+		  found_any=1
+		  local_name=$(expr "z$found" : 'z[^:]*:\(.*\)')
+		  append_fetch_head "$sha1" "$remote" "$remote_name" \
+		      "$remote_nick" "$local_name" "$not_for_merge"
+	      fi
 	  done
-	  local_name=$(expr "z$found" : 'z[^:]*:\(.*\)')
-	  append_fetch_head "$sha1" "$remote" \
-		  "$remote_name" "$remote_nick" "$local_name" "$not_for_merge"
+	  if test "$found_any" == ""
+	  then
+	      append_fetch_head "$sha1" "$remote" "$remote_name" \
+	          "$remote_nick" "" ""
+	  fi
       done
     ) || exit ;;
   esac
-- 
MST
Previous: Michael S. TsirkinNext: Junio C Hamano
Message 26 of 27 in “mailinfo: accept >From in message header”
  1. mailinfo: accept >From in message headerMichael S. Tsirkin, Jul 27, 2006
  2. Junio C HamanoJul 27, 2006
  3. Michael S. TsirkinJul 27, 2006
  4. Multiple pulls from the same branch in .git/remotes/originMichael S. Tsirkin, Aug 7, 2006
  5. Junio C HamanoAug 7, 2006
  6. Michael S. TsirkinAug 7, 2006
  7. Junio C HamanoAug 7, 2006
  8. Michael S. TsirkinAug 7, 2006
  9. Junio C HamanoAug 7, 2006
  10. Michael S. TsirkinAug 7, 2006
  11. Multiple refs from the same remote in one git fetchMichael S. Tsirkin, Aug 7, 2006
  12. Junio C HamanoAug 7, 2006
  13. Michael S. TsirkinAug 12, 2006
  14. Junio C HamanoAug 12, 2006
  15. Michael S. TsirkinAug 14, 2006
  16. Junio C HamanoAug 14, 2006
  17. Michael S. TsirkinAug 14, 2006
  18. Junio C HamanoAug 14, 2006
  19. Michael S. TsirkinAug 14, 2006
  20. Junio C HamanoAug 14, 2006
  21. Michael S. TsirkinAug 14, 2006
  22. Jakub NarebskiAug 14, 2006
  23. Michael S. TsirkinAug 14, 2006
  24. Jakub NarebskiAug 14, 2006
  25. Michael S. TsirkinAug 14, 2006
  26. Multiple refs from the same remote in one git fetchMichael S. Tsirkin, Aug 22, 2006
  27. Junio C HamanoAug 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.