midx: use context in write_midx_pack_names()
In an effort to align the write_midx_internal() to use the chunk-format API, start converting chunk writing methods to match chunk_write_fn. The first case is to convert write_midx_pack_names() to take "void *data". We already have the necessary data in "struct write_midx_context", so this conversion is rather mechanical. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
		
				
					committed by
					
						
						Junio C Hamano
					
				
			
			
				
	
			
			
			
						parent
						
							577dc49696
						
					
				
				
					commit
					b4d941420b
				
			
							
								
								
									
										21
									
								
								midx.c
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								midx.c
									
									
									
									
									
								
							@ -643,27 +643,26 @@ static struct pack_midx_entry *get_sorted_entries(struct multi_pack_index *m,
 | 
			
		||||
	return deduplicated_entries;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static size_t write_midx_pack_names(struct hashfile *f,
 | 
			
		||||
				    struct pack_info *info,
 | 
			
		||||
				    uint32_t num_packs)
 | 
			
		||||
static size_t write_midx_pack_names(struct hashfile *f, void *data)
 | 
			
		||||
{
 | 
			
		||||
	struct write_midx_context *ctx = data;
 | 
			
		||||
	uint32_t i;
 | 
			
		||||
	unsigned char padding[MIDX_CHUNK_ALIGNMENT];
 | 
			
		||||
	size_t written = 0;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < num_packs; i++) {
 | 
			
		||||
	for (i = 0; i < ctx->nr; i++) {
 | 
			
		||||
		size_t writelen;
 | 
			
		||||
 | 
			
		||||
		if (info[i].expired)
 | 
			
		||||
		if (ctx->info[i].expired)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		if (i && strcmp(info[i].pack_name, info[i - 1].pack_name) <= 0)
 | 
			
		||||
		if (i && strcmp(ctx->info[i].pack_name, ctx->info[i - 1].pack_name) <= 0)
 | 
			
		||||
			BUG("incorrect pack-file order: %s before %s",
 | 
			
		||||
			    info[i - 1].pack_name,
 | 
			
		||||
			    info[i].pack_name);
 | 
			
		||||
			    ctx->info[i - 1].pack_name,
 | 
			
		||||
			    ctx->info[i].pack_name);
 | 
			
		||||
 | 
			
		||||
		writelen = strlen(info[i].pack_name) + 1;
 | 
			
		||||
		hashwrite(f, info[i].pack_name, writelen);
 | 
			
		||||
		writelen = strlen(ctx->info[i].pack_name) + 1;
 | 
			
		||||
		hashwrite(f, ctx->info[i].pack_name, writelen);
 | 
			
		||||
		written += writelen;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -990,7 +989,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
 | 
			
		||||
 | 
			
		||||
		switch (chunk_ids[i]) {
 | 
			
		||||
			case MIDX_CHUNKID_PACKNAMES:
 | 
			
		||||
				written += write_midx_pack_names(f, ctx.info, ctx.nr);
 | 
			
		||||
				written += write_midx_pack_names(f, &ctx);
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
			case MIDX_CHUNKID_OIDFANOUT:
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user