@@ -135,7 +135,7 @@ static struct strvec trailer_args = STRVEC_INIT;
135135 * is specified explicitly.
136136 */
137137static enum commit_msg_cleanup_mode cleanup_mode ;
138- static char * cleanup_arg ;
138+ static char * cleanup_config ;
139139
140140static enum commit_whence whence ;
141141static int use_editor = 1 , include_status = 1 ;
@@ -728,6 +728,13 @@ static void prepare_amend_commit(struct commit *commit, struct strbuf *sb,
728728 repo_unuse_commit_buffer (the_repository , commit , buffer );
729729}
730730
731+ static void change_data_free (void * util , const char * str UNUSED )
732+ {
733+ struct wt_status_change_data * d = util ;
734+ free (d -> rename_source );
735+ free (d );
736+ }
737+
731738static int prepare_to_commit (const char * index_file , const char * prefix ,
732739 struct commit * current_head ,
733740 struct wt_status * s ,
@@ -991,7 +998,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
991998 s -> use_color = 0 ;
992999 committable = run_status (s -> fp , index_file , prefix , 1 , s );
9931000 s -> use_color = saved_color_setting ;
994- string_list_clear (& s -> change , 1 );
1001+ string_list_clear_func (& s -> change , change_data_free );
9951002 } else {
9961003 struct object_id oid ;
9971004 const char * parent = "HEAD" ;
@@ -1380,8 +1387,6 @@ static int parse_and_validate_options(int argc, const char *argv[],
13801387 if (0 <= edit_flag )
13811388 use_editor = edit_flag ;
13821389
1383- cleanup_mode = get_cleanup_mode (cleanup_arg , use_editor );
1384-
13851390 handle_untracked_files_arg (s );
13861391
13871392 if (all && argc > 0 )
@@ -1629,8 +1634,10 @@ static int git_commit_config(const char *k, const char *v,
16291634 include_status = git_config_bool (k , v );
16301635 return 0 ;
16311636 }
1632- if (!strcmp (k , "commit.cleanup" ))
1633- return git_config_string (& cleanup_arg , k , v );
1637+ if (!strcmp (k , "commit.cleanup" )) {
1638+ FREE_AND_NULL (cleanup_config );
1639+ return git_config_string (& cleanup_config , k , v );
1640+ }
16341641 if (!strcmp (k , "commit.gpgsign" )) {
16351642 sign_commit = git_config_bool (k , v ) ? "" : NULL ;
16361643 return 0 ;
@@ -1651,6 +1658,7 @@ int cmd_commit(int argc,
16511658 struct repository * repo UNUSED )
16521659{
16531660 static struct wt_status s ;
1661+ static const char * cleanup_arg = NULL ;
16541662 static struct option builtin_commit_options [] = {
16551663 OPT__QUIET (& quiet , N_ ("suppress summary after successful commit" )),
16561664 OPT__VERBOSE (& verbose , N_ ("show diff in commit message template" )),
@@ -1750,6 +1758,12 @@ int cmd_commit(int argc,
17501758 if (verbose == -1 )
17511759 verbose = (config_commit_verbose < 0 ) ? 0 : config_commit_verbose ;
17521760
1761+ if (cleanup_arg ) {
1762+ free (cleanup_config );
1763+ cleanup_config = xstrdup (cleanup_arg );
1764+ }
1765+ cleanup_mode = get_cleanup_mode (cleanup_config , use_editor );
1766+
17531767 if (dry_run )
17541768 return dry_run_commit (argv , prefix , current_head , & s );
17551769 index_file = prepare_index (argv , prefix , current_head , 0 );
0 commit comments