parse_fetch: convert to use struct object_id
Convert the parse_fetch function to use struct object_id. Remove the strlen check as get_oid_hex will fail safely on receiving a too-short NUL-terminated string. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Jeff King <peff@peff.net>maint
							parent
							
								
									854ecb9cad
								
							
						
					
					
						commit
						8338c911d1
					
				|  | @ -803,19 +803,19 @@ static void parse_fetch(struct strbuf *buf) | ||||||
| 		if (skip_prefix(buf->buf, "fetch ", &p)) { | 		if (skip_prefix(buf->buf, "fetch ", &p)) { | ||||||
| 			const char *name; | 			const char *name; | ||||||
| 			struct ref *ref; | 			struct ref *ref; | ||||||
| 			unsigned char old_sha1[20]; | 			struct object_id old_oid; | ||||||
|  |  | ||||||
| 			if (strlen(p) < 40 || get_sha1_hex(p, old_sha1)) | 			if (get_oid_hex(p, &old_oid)) | ||||||
| 				die("protocol error: expected sha/ref, got %s'", p); | 				die("protocol error: expected sha/ref, got %s'", p); | ||||||
| 			if (p[40] == ' ') | 			if (p[GIT_SHA1_HEXSZ] == ' ') | ||||||
| 				name = p + 41; | 				name = p + GIT_SHA1_HEXSZ + 1; | ||||||
| 			else if (!p[40]) | 			else if (!p[GIT_SHA1_HEXSZ]) | ||||||
| 				name = ""; | 				name = ""; | ||||||
| 			else | 			else | ||||||
| 				die("protocol error: expected sha/ref, got %s'", p); | 				die("protocol error: expected sha/ref, got %s'", p); | ||||||
|  |  | ||||||
| 			ref = alloc_ref(name); | 			ref = alloc_ref(name); | ||||||
| 			hashcpy(ref->old_oid.hash, old_sha1); | 			oidcpy(&ref->old_oid, &old_oid); | ||||||
|  |  | ||||||
| 			*list = ref; | 			*list = ref; | ||||||
| 			list = &ref->next; | 			list = &ref->next; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 brian m. carlson
						brian m. carlson