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

[PATCH] Don't sent objects for refs we're not going to update.

From
STStephen C. Tweedie <sct@redhat.com>
Date
Feb 21, 2006, 18:48 UTC
Message-ID
<1140547702.5509.24.camel@orbit.scot.redhat.com>
In-Reply-To
<1140547568.5509.21.camel@orbit.scot.redhat.com>

send_pack() sends only those refs we've asked to be updated on the destination---either via an explicit refspec or by matching local and remote refs. But rev_list() builds an object list for *all* refs it can find. For a tree with many tags/heads, this means that it is impossible to push updates even to a single refspec, as exec_rev_list() overflows its arg length limit.

Fix this by skipping refs with no peer_ref set in exec_rev_list(). send_pack() already skips it when sending refs; we need to skip it when building the object list for the pack too.

Signed-off-by: Stephen Tweedie <sct@redhat.com>
---
 send-pack.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
4aa39c0920eea37987ca8a6b10861da7a87b5c14
diff --git a/send-pack.c b/send-pack.c
index 990be3f..d2a39d9 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -42,8 +42,10 @@ static void exec_rev_list(struct ref *re
 
 	args[i++] = "rev-list";	/* 0 */
 	args[i++] = "--objects";	/* 1 */
-	while (refs) {
+	for (; refs; refs = refs->next) {
 		char *buf = malloc(100);
+		if (!refs->peer_ref)
+			continue;
 		if (i > 900)
 			die("git-rev-list environment overflow");
 		if (!is_zero_sha1(refs->old_sha1) &&
@@ -56,7 +58,6 @@ static void exec_rev_list(struct ref *re
 			args[i++] = buf;
 			snprintf(buf, 50, "%s", sha1_to_hex(refs->new_sha1));
 		}
-		refs = refs->next;
 	}
 	args[i] = NULL;
 	execv_git_cmd(args);
-- 
1.2.2.g6643-dirty
Previous: Stephen C. TweedieNext: Junio C Hamano
Message 2 of 7 in “Git cannot push to repository with too many tags/heads”
  1. Stephen C. TweedieFeb 21, 2006
  2. Don't sent objects for refs we're not going to update.Stephen C. Tweedie, Feb 21, 2006
  3. Junio C HamanoFeb 22, 2006
  4. Junio C HamanoFeb 22, 2006
  5. send-pack: do not give up when remote has insanely large number of refs.Junio C Hamano, Feb 22, 2006
  6. Stephen C. TweedieFeb 22, 2006
  7. Junio C HamanoFeb 22, 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.