object-store: allow read_object_file_extended to read from any repo
read_object_file_extended is not widely used, so migrate it all at once. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
		
				
					committed by
					
						
						Junio C Hamano
					
				
			
			
				
	
			
			
			
						parent
						
							33b94066f2
						
					
				
				
					commit
					a3b72c89bd
				
			@ -161,12 +161,13 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);
 | 
					void *map_sha1_file(struct repository *r, const unsigned char *sha1, unsigned long *size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern void *read_object_file_extended(const struct object_id *oid,
 | 
					extern void *read_object_file_extended(struct repository *r,
 | 
				
			||||||
 | 
									       const struct object_id *oid,
 | 
				
			||||||
				       enum object_type *type,
 | 
									       enum object_type *type,
 | 
				
			||||||
				       unsigned long *size, int lookup_replace);
 | 
									       unsigned long *size, int lookup_replace);
 | 
				
			||||||
static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)
 | 
					static inline void *read_object_file(const struct object_id *oid, enum object_type *type, unsigned long *size)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return read_object_file_extended(oid, type, size, 1);
 | 
						return read_object_file_extended(the_repository, oid, type, size, 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Read and unpack an object file into memory, write memory to an object file */
 | 
					/* Read and unpack an object file into memory, write memory to an object file */
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								sha1-file.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								sha1-file.c
									
									
									
									
									
								
							@ -1403,7 +1403,8 @@ int pretend_object_file(void *buf, unsigned long len, enum object_type type,
 | 
				
			|||||||
 * deal with them should arrange to call read_object() and give error
 | 
					 * deal with them should arrange to call read_object() and give error
 | 
				
			||||||
 * messages themselves.
 | 
					 * messages themselves.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void *read_object_file_extended(const struct object_id *oid,
 | 
					void *read_object_file_extended(struct repository *r,
 | 
				
			||||||
 | 
									const struct object_id *oid,
 | 
				
			||||||
				enum object_type *type,
 | 
									enum object_type *type,
 | 
				
			||||||
				unsigned long *size,
 | 
									unsigned long *size,
 | 
				
			||||||
				int lookup_replace)
 | 
									int lookup_replace)
 | 
				
			||||||
@ -1413,10 +1414,10 @@ void *read_object_file_extended(const struct object_id *oid,
 | 
				
			|||||||
	const char *path;
 | 
						const char *path;
 | 
				
			||||||
	struct stat st;
 | 
						struct stat st;
 | 
				
			||||||
	const struct object_id *repl = lookup_replace ?
 | 
						const struct object_id *repl = lookup_replace ?
 | 
				
			||||||
		lookup_replace_object(the_repository, oid) : oid;
 | 
							lookup_replace_object(r, oid) : oid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	errno = 0;
 | 
						errno = 0;
 | 
				
			||||||
	data = read_object(the_repository, repl->hash, type, size);
 | 
						data = read_object(r, repl->hash, type, size);
 | 
				
			||||||
	if (data)
 | 
						if (data)
 | 
				
			||||||
		return data;
 | 
							return data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1428,11 +1429,11 @@ void *read_object_file_extended(const struct object_id *oid,
 | 
				
			|||||||
		die(_("replacement %s not found for %s"),
 | 
							die(_("replacement %s not found for %s"),
 | 
				
			||||||
		    oid_to_hex(repl), oid_to_hex(oid));
 | 
							    oid_to_hex(repl), oid_to_hex(oid));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!stat_sha1_file(the_repository, repl->hash, &st, &path))
 | 
						if (!stat_sha1_file(r, repl->hash, &st, &path))
 | 
				
			||||||
		die(_("loose object %s (stored in %s) is corrupt"),
 | 
							die(_("loose object %s (stored in %s) is corrupt"),
 | 
				
			||||||
		    oid_to_hex(repl), path);
 | 
							    oid_to_hex(repl), path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((p = has_packed_and_bad(the_repository, repl->hash)) != NULL)
 | 
						if ((p = has_packed_and_bad(r, repl->hash)) != NULL)
 | 
				
			||||||
		die(_("packed object %s (stored in %s) is corrupt"),
 | 
							die(_("packed object %s (stored in %s) is corrupt"),
 | 
				
			||||||
		    oid_to_hex(repl), p->pack_name);
 | 
							    oid_to_hex(repl), p->pack_name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -490,7 +490,7 @@ static struct stream_vtbl incore_vtbl = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static open_method_decl(incore)
 | 
					static open_method_decl(incore)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	st->u.incore.buf = read_object_file_extended(oid, type, &st->size, 0);
 | 
						st->u.incore.buf = read_object_file_extended(the_repository, oid, type, &st->size, 0);
 | 
				
			||||||
	st->u.incore.read_ptr = 0;
 | 
						st->u.incore.read_ptr = 0;
 | 
				
			||||||
	st->vtbl = &incore_vtbl;
 | 
						st->vtbl = &incore_vtbl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user