mirror of
				https://git.proxmox.com/git/libgit2
				synced 2025-11-04 14:08:17 +00:00 
			
		
		
		
	index: fix shared prefix computation when writing index entry
When using compressed index entries, each entry's path is preceded by a varint encoding how long the shared prefix with the previous index entry actually is. We currently encode a length of `(path_len - same_len)`, which is doubly wrong. First, `path_len` is already set to `path_len - same_len` previously. Second, we want to encode the shared prefix rather than the un-shared suffix length. Fix this by using `same_len` as the varint value instead.
This commit is contained in:
		
							parent
							
								
									83e0392cea
								
							
						
					
					
						commit
						c71dff7e8a
					
				@ -2661,8 +2661,7 @@ static int write_disk_entry(git_filebuf *file, git_index_entry *entry, const cha
 | 
			
		||||
 | 
			
		||||
	if (last) {
 | 
			
		||||
		path += git_encode_varint((unsigned char *) path,
 | 
			
		||||
					  disk_size,
 | 
			
		||||
					  path_len - same_len);
 | 
			
		||||
					  disk_size, same_len);
 | 
			
		||||
	}
 | 
			
		||||
	memcpy(path, path_start, path_len);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user