mirror of
				https://git.proxmox.com/git/libgit2
				synced 2025-10-31 07:41:33 +00:00 
			
		
		
		
	Merge pull request #866 from arrbee/fix-config-file-parsing
Config file parser includes = in name if no space around it
This commit is contained in:
		
						commit
						c86dd38a64
					
				| @ -1343,10 +1343,8 @@ static int parse_variable(diskfile_backend *cfg, char **var_name, char **var_val | ||||
| 	else | ||||
| 		value_start = var_end + 1; | ||||
| 
 | ||||
| 	if (git__isspace(var_end[-1])) { | ||||
| 		do var_end--; | ||||
| 		while (git__isspace(var_end[0])); | ||||
| 	} | ||||
| 	do var_end--; | ||||
| 	while (git__isspace(*var_end)); | ||||
| 
 | ||||
| 	*var_name = git__strndup(line, var_end - line + 1); | ||||
| 	GITERR_CHECK_ALLOC(*var_name); | ||||
|  | ||||
| @ -266,6 +266,22 @@ void test_config_read__foreach_match(void) | ||||
| 	git_config_free(cfg); | ||||
| } | ||||
| 
 | ||||
| void test_config_read__whitespace_not_required_around_assignment(void) | ||||
| { | ||||
| 	git_config *cfg; | ||||
| 	const char *str; | ||||
| 
 | ||||
| 	cl_git_pass(git_config_open_ondisk(&cfg, cl_fixture("config/config14"))); | ||||
| 
 | ||||
| 	cl_git_pass(git_config_get_string(&str, cfg, "a.b")); | ||||
| 	cl_assert_equal_s(str, "c"); | ||||
| 
 | ||||
| 	cl_git_pass(git_config_get_string(&str, cfg, "d.e")); | ||||
| 	cl_assert_equal_s(str, "f"); | ||||
| 
 | ||||
| 	git_config_free(cfg); | ||||
| } | ||||
| 
 | ||||
| #if 0 | ||||
| 
 | ||||
| BEGIN_TEST(config10, "a repo's config overrides the global config") | ||||
|  | ||||
							
								
								
									
										4
									
								
								tests-clar/resources/config/config14
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests-clar/resources/config/config14
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| [a] | ||||
|     b=c | ||||
| [d] | ||||
|     e = f | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Vicent Martí
						Vicent Martí