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

Re: [RFC] multi_ack protocol v2

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 27, 2005, 18:04 UTC
Message-ID
<Pine.LNX.4.63.0510272003060.22251@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vwtjy3lch.fsf@assigned-by-dhcp.cox.net>
Hi,
On Thu, 27 Oct 2005, Junio C Hamano wrote:
Show 7 quoted lines
> Another thing that would probably be helpful is to redo
> get_remote_heads() slightly differently, so that it can return
> information on *all* refs the other end has.  We need to extend
> "struct ref" to mark which one was actually matched/ignored by
> path_match() and ignore_funny.  An completely untested patch is
> attached, based on fetch-pack that still runs rev-list as an
> external process, to outline the idea.

A completely tested patch (unfortunately in the middle of my work) does not touch get_remote_heads() at all:

diff --git a/fetch-pack.c b/fetch-pack.c
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -274,7 +290,27 @@ static void mark_recent_complete_commits
 	}
 }
 
-static int everything_local(struct ref *refs)
+static void filter_refs(struct ref **refs, int nr_match, char **match)
+{
+	struct ref *prev, *current, *next;
+
+	if (!nr_match)
+		return;
+
+	for (prev = NULL, current = *refs; current; current = next) {
+		next = current->next;
+		if (!path_match(current->name, nr_match, match)) {
+			if (prev == NULL)
+				*refs = next;
+			else
+				prev->next = next;
+			free(current);
+		} else
+			prev = current;
+	}
+}
+
+static int everything_local(struct ref **refs, int nr_match, char **match)
 {
 	struct ref *ref;
 	int retval;
@@ -283,7 +319,7 @@ static int everything_local(struct ref *
 	track_object_refs = 0;
 	save_commit_buffer = 0;
 
-	for (ref = refs; ref; ref = ref->next) {
+	for (ref = *refs; ref; ref = ref->next) {
 		struct object *o;
 
 		o = parse_object(ref->old_sha1);
@@ -305,8 +341,10 @@ static int everything_local(struct ref *
 	if (cutoff)
 		mark_recent_complete_commits(cutoff);
 
-	for (retval = 1; refs ; refs = refs->next) {
-		const unsigned char *remote = refs->old_sha1;
+	filter_refs(refs, nr_match, match);
+
+	for (retval = 1, ref = *refs; ref ; ref = ref->next) {
+		const unsigned char *remote = ref->old_sha1;
 		unsigned char local[20];
 		struct object *o;
 
@@ -317,16 +355,16 @@ static int everything_local(struct ref *
 				continue;
 			fprintf(stderr,
 				"want %s (%s)\n", sha1_to_hex(remote),
-				refs->name);
+				ref->name);
 			continue;
 		}
 
-		memcpy(refs->new_sha1, local, 20);
+		memcpy(ref->new_sha1, local, 20);
 		if (!verbose)
 			continue;
 		fprintf(stderr,
 			"already have %s (%s)\n", sha1_to_hex(remote),
-			refs->name);
+			ref->name);
 	}
 	return retval;
 }
@@ -338,12 +376,12 @@ static int fetch_pack(int fd[2], int nr_
 	int status;
 	pid_t pid;
 
-	get_remote_heads(fd[0], &ref, nr_match, match, 1);
+	get_remote_heads(fd[0], &ref, 0, NULL, 1);
 	if (!ref) {
 		packet_flush(fd[1]);
 		die("no matching remote head");
 	}
-	if (everything_local(ref)) {
+	if (everything_local(&ref, nr_match, match)) {
 		packet_flush(fd[1]);
 		goto all_done;
 	}
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 10 in “[RFC] multi_ack protocol v2”
  1. Johannes SchindelinOct 27, 2005
  2. Junio C HamanoOct 27, 2005
  3. Johannes SchindelinOct 27, 2005
  4. Sergey VlasovOct 27, 2005
  5. Johannes SchindelinOct 27, 2005
  6. Junio C HamanoOct 27, 2005
  7. Johannes SchindelinOct 27, 2005
  8. Junio C HamanoOct 27, 2005
  9. Paul MackerrasOct 27, 2005
  10. Johannes SchindelinOct 27, 2005

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.