All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fetch-pack should not ask for a ref which is already there
@ 2005-09-28 23:49 Johannes Schindelin
  2005-09-29  7:22 ` Junio C Hamano
  2005-09-29 18:26 ` Linus Torvalds
  0 siblings, 2 replies; 10+ messages in thread
From: Johannes Schindelin @ 2005-09-28 23:49 UTC (permalink / raw)
  To: Git Mailing List

With this patch, instead of blindly asking for every remote ref, fetch-pack
first looks in the local repository if that ref is already there.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

---

 fetch-pack.c |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 deletions(-)

6bf41421bed0d640677c5233d2be6813b2211979
diff --git a/fetch-pack.c b/fetch-pack.c
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -16,20 +16,27 @@ static int find_common(int fd[2], unsign
 	int count = 0, flushes = 0, retval;
 	FILE *revs;
 
-	revs = popen("git-rev-list $(git-rev-parse --all)", "r");
-	if (!revs)
-		die("unable to run 'git-rev-list'");
-
 	while (refs) {
 		unsigned char *remote = refs->old_sha1;
-		if (verbose)
-			fprintf(stderr,
-				"want %s (%s)\n", sha1_to_hex(remote),
-				refs->name);
-		packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
+		if(!has_sha1_file(remote)) {
+			if (verbose)
+				fprintf(stderr,
+					"want %s (%s)\n", sha1_to_hex(remote),
+					refs->name);
+			packet_write(fd[1], "want %s\n", sha1_to_hex(remote));
+			count++;
+		}
 		refs = refs->next;
 	}
 	packet_flush(fd[1]);
+
+	if(count==0)
+		return 1;
+
+	revs = popen("git-rev-list $(git-rev-parse --all)", "r");
+	if (!revs)
+		die("unable to run 'git-rev-list'");
+
 	flushes = 1;
 	retval = -1;
 	while (fgets(line, sizeof(line), revs) != NULL) {
@@ -86,7 +93,10 @@ static int fetch_pack(int fd[2], int nr_
 		packet_flush(fd[1]);
 		die("no matching remote head");
 	}
-	if (find_common(fd, sha1, ref) < 0)
+	status = find_common(fd, sha1, ref);
+	if(status > 0)
+		return 0;
+	if(status < 0)
 		fprintf(stderr, "warning: no common commits\n");
 	pid = fork();
 	if (pid < 0)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-09-30 12:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-28 23:49 [PATCH] fetch-pack should not ask for a ref which is already there Johannes Schindelin
2005-09-29  7:22 ` Junio C Hamano
2005-09-29  8:42   ` Johannes Schindelin
2005-09-29  9:14     ` Junio C Hamano
2005-09-29  9:30       ` Johannes Schindelin
2005-09-29 18:26 ` Linus Torvalds
2005-09-29 19:08   ` Johannes Schindelin
2005-09-29 19:28     ` Johannes Schindelin
2005-09-29 21:07       ` Linus Torvalds
2005-09-30 12:20         ` Johannes Schindelin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.