@@ -1414,8 +1414,10 @@ static int git_default_core_config(const char *var, const char *value,
14141414 return 0 ;
14151415 }
14161416
1417- if (!strcmp (var , "core.attributesfile" ))
1417+ if (!strcmp (var , "core.attributesfile" )) {
1418+ FREE_AND_NULL (git_attributes_file );
14181419 return git_config_pathname (& git_attributes_file , var , value );
1420+ }
14191421
14201422 if (!strcmp (var , "core.hookspath" )) {
14211423 if (ctx -> kvi && ctx -> kvi -> scope == CONFIG_SCOPE_LOCAL &&
@@ -1428,6 +1430,7 @@ static int git_default_core_config(const char *var, const char *value,
14281430 "again with "
14291431 "`GIT_CLONE_PROTECTION_ACTIVE=false`" ),
14301432 value );
1433+ FREE_AND_NULL (git_hooks_path );
14311434 return git_config_pathname (& git_hooks_path , var , value );
14321435 }
14331436
@@ -1576,8 +1579,10 @@ static int git_default_core_config(const char *var, const char *value,
15761579 return 0 ;
15771580 }
15781581
1579- if (!strcmp (var , "core.editor" ))
1582+ if (!strcmp (var , "core.editor" )) {
1583+ FREE_AND_NULL (editor_program );
15801584 return git_config_string (& editor_program , var , value );
1585+ }
15811586
15821587 if (!strcmp (var , "core.commentchar" ) ||
15831588 !strcmp (var , "core.commentstring" )) {
@@ -1595,11 +1600,13 @@ static int git_default_core_config(const char *var, const char *value,
15951600 return 0 ;
15961601 }
15971602
1598- if (!strcmp (var , "core.askpass" ))
1603+ if (!strcmp (var , "core.askpass" )) {
1604+ FREE_AND_NULL (askpass_program );
15991605 return git_config_string (& askpass_program , var , value );
1606+ }
16001607
16011608 if (!strcmp (var , "core.excludesfile" )) {
1602- free (excludes_file );
1609+ FREE_AND_NULL (excludes_file );
16031610 return git_config_pathname (& excludes_file , var , value );
16041611 }
16051612
@@ -1702,11 +1709,15 @@ static int git_default_sparse_config(const char *var, const char *value)
17021709
17031710static int git_default_i18n_config (const char * var , const char * value )
17041711{
1705- if (!strcmp (var , "i18n.commitencoding" ))
1712+ if (!strcmp (var , "i18n.commitencoding" )) {
1713+ FREE_AND_NULL (git_commit_encoding );
17061714 return git_config_string (& git_commit_encoding , var , value );
1715+ }
17071716
1708- if (!strcmp (var , "i18n.logoutputencoding" ))
1717+ if (!strcmp (var , "i18n.logoutputencoding" )) {
1718+ FREE_AND_NULL (git_log_output_encoding );
17091719 return git_config_string (& git_log_output_encoding , var , value );
1720+ }
17101721
17111722 /* Add other config variables here and to Documentation/config.txt. */
17121723 return 0 ;
@@ -1779,19 +1790,26 @@ static int git_default_push_config(const char *var, const char *value)
17791790
17801791static int git_default_mailmap_config (const char * var , const char * value )
17811792{
1782- if (!strcmp (var , "mailmap.file" ))
1793+ if (!strcmp (var , "mailmap.file" )) {
1794+ FREE_AND_NULL (git_mailmap_file );
17831795 return git_config_pathname (& git_mailmap_file , var , value );
1784- if (!strcmp (var , "mailmap.blob" ))
1796+ }
1797+
1798+ if (!strcmp (var , "mailmap.blob" )) {
1799+ FREE_AND_NULL (git_mailmap_blob );
17851800 return git_config_string (& git_mailmap_blob , var , value );
1801+ }
17861802
17871803 /* Add other config variables here and to Documentation/config.txt. */
17881804 return 0 ;
17891805}
17901806
17911807static int git_default_attr_config (const char * var , const char * value )
17921808{
1793- if (!strcmp (var , "attr.tree" ))
1809+ if (!strcmp (var , "attr.tree" )) {
1810+ FREE_AND_NULL (git_attr_tree );
17941811 return git_config_string (& git_attr_tree , var , value );
1812+ }
17951813
17961814 /*
17971815 * Add other attribute related config variables here and to
0 commit comments