1. Stefan Saasen
  2. git

Commits

Junio C Hamano  committed 144c83f Merge

Merge branch 'fixes'

  • Participants
  • Parent commits e1d04f8, 70a0c6f
  • Branches master

Comments (0)

Files changed (4)

File git-pull.sh

View file
 		strategy_args="${strategy_args}-s $strategy "
 		;;
 	-*)
-		usage
+		# Pass thru anything that is meant for fetch.
+		break
 		;;
 	esac
 	shift

File sha1_name.c

View file
 			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;
 				}
 	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;

File ssh-fetch.c

View file
 	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];
 {
 	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];

File symbolic-ref.c

View file
 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));