mirror of
				https://git.proxmox.com/git/libgit2
				synced 2025-11-04 08:48:25 +00:00 
			
		
		
		
	mwindow: init mwindow files in git_libgit2_init
This commit is contained in:
		
							parent
							
								
									edf420f37b
								
							
						
					
					
						commit
						886bd6a617
					
				@ -59,8 +59,9 @@ static int init_common(void)
 | 
			
		||||
	if ((ret = git_hash_global_init()) == 0 &&
 | 
			
		||||
		(ret = git_sysdir_global_init()) == 0 &&
 | 
			
		||||
		(ret = git_filter_global_init()) == 0 &&
 | 
			
		||||
		(ret = git_transport_ssh_global_init()) == 0)
 | 
			
		||||
		ret = git_openssl_stream_global_init();
 | 
			
		||||
		(ret = git_transport_ssh_global_init()) == 0 &&
 | 
			
		||||
		(ret = git_openssl_stream_global_init()) == 0)
 | 
			
		||||
		ret = git_mwindow_global_init();
 | 
			
		||||
 | 
			
		||||
	GIT_MEMORY_BARRIER;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,20 +33,7 @@ static git_mwindow_ctl mem_ctl;
 | 
			
		||||
/* Global list of mwindow files, to open packs once across repos */
 | 
			
		||||
git_strmap *git__pack_cache = NULL;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Run under mwindow lock
 | 
			
		||||
 */
 | 
			
		||||
int git_mwindow_files_init(void)
 | 
			
		||||
{
 | 
			
		||||
	if (git__pack_cache)
 | 
			
		||||
		return 0;
 | 
			
		||||
 | 
			
		||||
	git__on_shutdown(git_mwindow_files_free);
 | 
			
		||||
 | 
			
		||||
	return git_strmap_alloc(&git__pack_cache);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void git_mwindow_files_free(void)
 | 
			
		||||
static void git_mwindow_files_free(void)
 | 
			
		||||
{
 | 
			
		||||
	git_strmap *tmp = git__pack_cache;
 | 
			
		||||
 | 
			
		||||
@ -54,6 +41,14 @@ void git_mwindow_files_free(void)
 | 
			
		||||
	git_strmap_free(tmp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int git_mwindow_global_init(void)
 | 
			
		||||
{
 | 
			
		||||
	assert(!git__pack_cache);
 | 
			
		||||
 | 
			
		||||
	git__on_shutdown(git_mwindow_files_free);
 | 
			
		||||
	return git_strmap_alloc(&git__pack_cache);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
 | 
			
		||||
{
 | 
			
		||||
	int error;
 | 
			
		||||
@ -69,12 +64,6 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (git_mwindow_files_init() < 0) {
 | 
			
		||||
		git_mutex_unlock(&git__mwindow_mutex);
 | 
			
		||||
		git__free(packname);
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	pos = git_strmap_lookup_index(git__pack_cache, packname);
 | 
			
		||||
	git__free(packname);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -43,8 +43,7 @@ int git_mwindow_file_register(git_mwindow_file *mwf);
 | 
			
		||||
void git_mwindow_file_deregister(git_mwindow_file *mwf);
 | 
			
		||||
void git_mwindow_close(git_mwindow **w_cursor);
 | 
			
		||||
 | 
			
		||||
int git_mwindow_files_init(void);
 | 
			
		||||
void git_mwindow_files_free(void);
 | 
			
		||||
extern int git_mwindow_global_init(void);
 | 
			
		||||
 | 
			
		||||
struct git_pack_file; /* just declaration to avoid cyclical includes */
 | 
			
		||||
int git_mwindow_get_pack(struct git_pack_file **out, const char *path);
 | 
			
		||||
 | 
			
		||||
@ -591,9 +591,6 @@ int git_odb_backend_pack(git_odb_backend **backend_out, const char *objects_dir)
 | 
			
		||||
	struct pack_backend *backend = NULL;
 | 
			
		||||
	git_buf path = GIT_BUF_INIT;
 | 
			
		||||
 | 
			
		||||
	if (git_mwindow_files_init() < 0)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	if (pack_backend__alloc(&backend, 8) < 0)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user