From 619e5a0ed4a53653085961b7aefe1f93ed879949 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 3 Oct 2005 15:45:44 -0700 Subject: [PATCH 1/4] git-pull: do not barf on -a flag meant for git-fetch. Signed-off-by: Junio C Hamano --- git-pull.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git-pull.sh b/git-pull.sh index 0290e517c2..d4765188b4 100755 --- a/git-pull.sh +++ b/git-pull.sh @@ -32,7 +32,8 @@ do strategy_args="${strategy_args}-s $strategy " ;; -*) - usage + # Pass thru anything that is meant for fetch. + break ;; esac shift From 0bc458902020b705fa913ca340aa40fea0f87096 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 2 Oct 2005 21:40:51 -0700 Subject: [PATCH 2/4] Make sure get_sha1 does not accept ambiguous sha1 prefix (again). The earlier fix incorrectly dropped the code the original had to ensure the found SHA1 is at least unique within the same pack. Restore the check. Signed-off-by: Junio C Hamano --- sha1_name.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 8920de1c45..f64755fbce 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -91,14 +91,23 @@ static int find_short_packed_object(int len, const unsigned char *match, unsigne last = mid; } if (first < num) { - unsigned char now[20]; + unsigned char now[20], next[20]; nth_packed_object_sha1(p, first, now); if (match_sha(len, match, now)) { - if (!found) { - memcpy(found_sha1, now, 20); - found++; + if (nth_packed_object_sha1(p, first+1, next) || + !match_sha(len, match, next)) { + /* unique within this pack */ + if (!found) { + memcpy(found_sha1, now, 20); + found++; + } + else if (memcmp(found_sha1, now, 20)) { + found = 2; + break; + } } - else if (memcmp(found_sha1, now, 20)) { + else { + /* not even unique within this pack */ found = 2; break; } @@ -121,7 +130,7 @@ static int find_unique_short_object(int len, char *canonical, if (!has_unpacked && !has_packed) return -1; if (1 < has_unpacked || 1 < has_packed) - return -1; + return error("short SHA1 %.*s is ambiguous.", len, canonical); if (has_unpacked != has_packed) { memcpy(sha1, (has_packed ? packed_sha1 : unpacked_sha1), 20); return 0; From f5a5e9b9f4f08544660fd55cd211bdd57c55b32f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 3 Oct 2005 19:11:32 -0700 Subject: [PATCH 3/4] Avoid compiler warning. Signed-off-by: Junio C Hamano --- symbolic-ref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/symbolic-ref.c b/symbolic-ref.c index af087d211d..a72d7accb1 100644 --- a/symbolic-ref.c +++ b/symbolic-ref.c @@ -3,7 +3,7 @@ static const char git_symbolic_ref_usage[] = "git-symbolic-ref name [ref]"; -static int check_symref(const char *HEAD) +static void check_symref(const char *HEAD) { unsigned char sha1[20]; const char *git_HEAD = strdup(git_path("%s", HEAD)); From 70a0c6fe39da7e3f68836051408bc8eb3ce60ba7 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 4 Oct 2005 00:24:55 -0400 Subject: [PATCH 4/4] [PATCH] Limit the number of requests outstanding in ssh-fetch. This completes fetches if there are more than 100 outstanding requests and there are more to prefetch. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- ssh-fetch.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ssh-fetch.c b/ssh-fetch.c index 05d3e49f25..bf01fbc00d 100644 --- a/ssh-fetch.c +++ b/ssh-fetch.c @@ -36,12 +36,26 @@ static ssize_t force_write(int fd, void *buffer, size_t length) return ret; } +static int prefetches = 0; + +static struct object_list *in_transit = NULL; +static struct object_list **end_of_transit = &in_transit; + void prefetch(unsigned char *sha1) { char type = 'o'; + struct object_list *node; + if (prefetches > 100) { + fetch(in_transit->item->sha1); + } + node = xmalloc(sizeof(struct object_list)); + node->next = NULL; + node->item = lookup_unknown_object(sha1); + *end_of_transit = node; + end_of_transit = &node->next; force_write(fd_out, &type, 1); force_write(fd_out, sha1, 20); - //memcpy(requested + 20 * prefetches++, sha1, 20); + prefetches++; } static char conn_buf[4096]; @@ -51,6 +65,18 @@ int fetch(unsigned char *sha1) { int ret; signed char remote; + struct object_list *temp; + + if (memcmp(sha1, in_transit->item->sha1, 20)) { + // we must have already fetched it to clean the queue + return has_sha1_file(sha1) ? 0 : -1; + } + prefetches--; + temp = in_transit; + in_transit = in_transit->next; + if (!in_transit) + end_of_transit = &in_transit; + free(temp); if (conn_buf_posn) { remote = conn_buf[0];