packed_object_info(): use object_id for returning delta base
If a caller sets the object_info.delta_base_sha1 to a non-NULL pointer, we'll write the oid of the object's delta base to it. But we can increase our type safety by switching this to a real object_id struct. All of our callers are just pointing into the hash member of an object_id anyway, so there's no inconvenience. Note that we do still keep it as a pointer-to-struct, because the NULL sentinel value tells us whether the caller is even interested in the information. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									63f4a7fc01
								
							
						
					
					
						commit
						b99b6bcc57
					
				|  | @ -262,7 +262,7 @@ static void expand_atom(struct strbuf *sb, const char *atom, int len, | ||||||
| 			strbuf_addstr(sb, data->rest); | 			strbuf_addstr(sb, data->rest); | ||||||
| 	} else if (is_atom("deltabase", atom, len)) { | 	} else if (is_atom("deltabase", atom, len)) { | ||||||
| 		if (data->mark_query) | 		if (data->mark_query) | ||||||
| 			data->info.delta_base_sha1 = data->delta_base_oid.hash; | 			data->info.delta_base_oid = &data->delta_base_oid; | ||||||
| 		else | 		else | ||||||
| 			strbuf_addstr(sb, | 			strbuf_addstr(sb, | ||||||
| 				      oid_to_hex(&data->delta_base_oid)); | 				      oid_to_hex(&data->delta_base_oid)); | ||||||
|  |  | ||||||
|  | @ -300,7 +300,7 @@ struct object_info { | ||||||
| 	enum object_type *typep; | 	enum object_type *typep; | ||||||
| 	unsigned long *sizep; | 	unsigned long *sizep; | ||||||
| 	off_t *disk_sizep; | 	off_t *disk_sizep; | ||||||
| 	unsigned char *delta_base_sha1; | 	struct object_id *delta_base_oid; | ||||||
| 	struct strbuf *type_name; | 	struct strbuf *type_name; | ||||||
| 	void **contentp; | 	void **contentp; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @ -1556,7 +1556,7 @@ int packed_object_info(struct repository *r, struct packed_git *p, | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (oi->delta_base_sha1) { | 	if (oi->delta_base_oid) { | ||||||
| 		if (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) { | 		if (type == OBJ_OFS_DELTA || type == OBJ_REF_DELTA) { | ||||||
| 			const unsigned char *base; | 			const unsigned char *base; | ||||||
|  |  | ||||||
|  | @ -1567,9 +1567,9 @@ int packed_object_info(struct repository *r, struct packed_git *p, | ||||||
| 				goto out; | 				goto out; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			hashcpy(oi->delta_base_sha1, base); | 			hashcpy(oi->delta_base_oid->hash, base); | ||||||
| 		} else | 		} else | ||||||
| 			hashclr(oi->delta_base_sha1); | 			oidclr(oi->delta_base_oid); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	oi->whence = in_delta_base_cache(p, obj_offset) ? OI_DBCACHED : | 	oi->whence = in_delta_base_cache(p, obj_offset) ? OI_DBCACHED : | ||||||
|  |  | ||||||
|  | @ -279,9 +279,9 @@ static int deltabase_atom_parser(const struct ref_format *format, struct used_at | ||||||
| 	if (arg) | 	if (arg) | ||||||
| 		return strbuf_addf_ret(err, -1, _("%%(deltabase) does not take arguments")); | 		return strbuf_addf_ret(err, -1, _("%%(deltabase) does not take arguments")); | ||||||
| 	if (*atom->name == '*') | 	if (*atom->name == '*') | ||||||
| 		oi_deref.info.delta_base_sha1 = oi_deref.delta_base_oid.hash; | 		oi_deref.info.delta_base_oid = &oi_deref.delta_base_oid; | ||||||
| 	else | 	else | ||||||
| 		oi.info.delta_base_sha1 = oi.delta_base_oid.hash; | 		oi.info.delta_base_oid = &oi.delta_base_oid; | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | @ -1354,8 +1354,8 @@ static int loose_object_info(struct repository *r, | ||||||
| 	struct strbuf hdrbuf = STRBUF_INIT; | 	struct strbuf hdrbuf = STRBUF_INIT; | ||||||
| 	unsigned long size_scratch; | 	unsigned long size_scratch; | ||||||
|  |  | ||||||
| 	if (oi->delta_base_sha1) | 	if (oi->delta_base_oid) | ||||||
| 		hashclr(oi->delta_base_sha1); | 		oidclr(oi->delta_base_oid); | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
| 	 * If we don't care about type or size, then we don't | 	 * If we don't care about type or size, then we don't | ||||||
|  | @ -1474,8 +1474,8 @@ static int do_oid_object_info_extended(struct repository *r, | ||||||
| 			*(oi->sizep) = co->size; | 			*(oi->sizep) = co->size; | ||||||
| 		if (oi->disk_sizep) | 		if (oi->disk_sizep) | ||||||
| 			*(oi->disk_sizep) = 0; | 			*(oi->disk_sizep) = 0; | ||||||
| 		if (oi->delta_base_sha1) | 		if (oi->delta_base_oid) | ||||||
| 			hashclr(oi->delta_base_sha1); | 			oidclr(oi->delta_base_oid); | ||||||
| 		if (oi->type_name) | 		if (oi->type_name) | ||||||
| 			strbuf_addstr(oi->type_name, type_name(co->type)); | 			strbuf_addstr(oi->type_name, type_name(co->type)); | ||||||
| 		if (oi->contentp) | 		if (oi->contentp) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Jeff King
						Jeff King