git_config_string janitorial conversions.
cover git_config_string janitorial conversions.
These patches are related to the git_config_string "janitorial" work.
There may be more cleanup possible, but these are the straightforward changes.
Brian Hetro (5):
builtin-commit.c: Use 'git_config_string' to get 'commit.template' builtin-log.c: Use 'git_config_string' to get 'format.subjectprefix'
and 'format.suffix'
convert.c: Use 'git_config_string' to get 'smudge' and 'clean' diff.c: Use 'git_config_string' to get 'diff.external' http.c: Use 'git_config_string' to clean up SSL config.
builtin-commit.c | 11 ++++------- builtin-log.c | 16 ++++------------ convert.c | 25 +++++++++---------------- diff.c | 8 ++------ http.c | 36 ++++++++++++------------------------ 5 files changed, 31 insertions(+), 65 deletions(-)
Quoted 1 line · Brian Hetro
These patches are related to the
git_config_string"janitorial" work.
Your patches look good to me.
By the way, your first patch in the series seems to fix a bug:
Review
Quoted 5 lines
int
git_commit_config(const char *k, const char *v, void *cb){(quoted diff) +0
-3- if (!strcmp(k, "commit.template")) { - if (!v) - return config_error_nonbool(v);
It should have been:
- return config_error_nonbool(k);
Review
Quoted 5 lines
(quoted diff) +2
-3- template_file = xstrdup(v); - return 0; - } + if (!strcmp(k, "commit.template")) + return git_config_string(&template_file, k, v);
There is the same bug in "wt-status.c". I will send a fix for this one.
So (for the patch series):
Thanks,
Christian.
PATCH 1/5 builtin-commit.c: Use 'git_config_string' to get 'commit.template'
In reply to Brian Hetro--- builtin-commit.c | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-)
builtin-commit.c +4 -7
@@ -45,7 +45,8 @@ static enum {COMMIT_PARTIAL , } commit_style; -static char *logfile, *force_author, *template_file; +static char *logfile, *force_author; +static const char *template_file;static char *edit_message, *use_message;static char *author_name, *author_email, *author_date;static int all, edit_flag, also, interactive, only, amend, signoff;
@@ -877,12 +878,8 @@ static void print_summary(const char *prefix, const unsigned char *sha1)int git_commit_config (const char *k,const char *v,void *cb) { -if (!strcmp (k,"commit.template" )) { -if (!v) -return config_error_nonbool (v); - template_file =xstrdup (v); -return 0 ; - } +if (!strcmp (k,"commit.template" )) +return git_config_string (&template_file, k, v);return git_status_config (k, v, cb); }
Signature · 1 line
1.5.6.1.204.g699135
PATCH 2/5 builtin-log.c: Use 'git_config_string' to get 'format.subjectprefix' and 'format.suffix'
--- builtin-log.c | 16 ++++------------ 1 files changed, 4 insertions(+), 12 deletions(-)
builtin-log.c +4 -12
@@ -234,12 +234,8 @@ static int git_log_config(const char *var, const char *value, void *cb) {if (!strcmp (var,"format.pretty" ))return git_config_string (&fmt_pretty, var, value); -if (!strcmp (var,"format.subjectprefix" )) { -if (!value) -config_error_nonbool (var); - fmt_patch_subject_prefix =xstrdup (value); -return 0 ; - } +if (!strcmp (var,"format.subjectprefix" )) +return git_config_string (&fmt_patch_subject_prefix, var, value);if (!strcmp (var,"log.date" ))return git_config_string (&default_date_mode, var, value);if (!strcmp (var,"log.showroot" )) {
@@ -489,12 +485,8 @@ static int git_format_config(const char *var, const char *value, void *cb)add_header (value);return 0 ; } -if (!strcmp (var,"format.suffix" )) { -if (!value) -return config_error_nonbool (var); - fmt_patch_suffix =xstrdup (value); -return 0 ; - } +if (!strcmp (var,"format.suffix" )) +return git_config_string (&fmt_patch_suffix, var, value);if (!strcmp (var,"format.cc" )) {if (!value)return config_error_nonbool (var);
Signature · 1 line
1.5.6.1.204.g699135
PATCH 3/5 convert.c: Use 'git_config_string' to get 'smudge' and 'clean'
--- convert.c | 25 +++++++++---------------- 1 files changed, 9 insertions(+), 16 deletions(-)
convert.c +9 -16
@@ -319,8 +319,8 @@ static int apply_filter(const char *path, const char *src, size_t len,static struct convert_driver {const char *name;struct convert_driver *next; -char *smudge; -char *clean; +const char *smudge; +const char *clean; } *user_convert, **user_convert_tail;static int read_convert_config (const char *var,const char *value,void *cb)
@@ -358,19 +358,12 @@ static int read_convert_config(const char *var, const char *value, void *cb)* The command-line will not be interpolated in any way. */ -if (!strcmp ("smudge" , ep)) { -if (!value) -return config_error_nonbool (var); - drv->smudge =strdup (value); -return 0 ; - } +if (!strcmp ("smudge" , ep)) +return git_config_string (&drv->smudge, var, value); + +if (!strcmp ("clean" , ep)) +return git_config_string (&drv->clean, var, value); -if (!strcmp ("clean" , ep)) { -if (!value) -return config_error_nonbool (var); - drv->clean =strdup (value); -return 0 ; - }return 0 ; }
@@ -576,7 +569,7 @@ int convert_to_git(const char *path, const char *src, size_t len,struct git_attr_check check[3 ];int crlf =CRLF_GUESS ;int ident =0 , ret =0 ; -char *filter =NULL ; +const char *filter =NULL ;setup_convert_check (check);if (!git_checkattr (path,ARRAY_SIZE (check), check)) {
@@ -606,7 +599,7 @@ int convert_to_working_tree(const char *path, const char *src, size_t len, strucstruct git_attr_check check[3 ];int crlf =CRLF_GUESS ;int ident =0 , ret =0 ; -char *filter =NULL ; +const char *filter =NULL ;setup_convert_check (check);if (!git_checkattr (path,ARRAY_SIZE (check), check)) {
Signature · 1 line
1.5.6.1.204.g699135
PATCH 4/5 diff.c: Use 'git_config_string' to get 'diff.external'
--- diff.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
diff.c +2 -6
@@ -153,12 +153,8 @@ int git_diff_ui_config(const char *var, const char *value, void *cb) diff_auto_refresh_index =git_config_bool (var, value);return 0 ; } -if (!strcmp (var,"diff.external" )) { -if (!value) -return config_error_nonbool (var); - external_diff_cmd_cfg =xstrdup (value); -return 0 ; - } +if (!strcmp (var,"diff.external" )) +return git_config_string (&external_diff_cmd_cfg, var, value);if (!prefixcmp (var,"diff." )) {const char *ep =strrchr (var,'.' );
Signature · 1 line
1.5.6.1.204.g699135
PATCH 5/5 http.c: Use 'git_config_string' to clean up SSL config.
--- http.c | 36 ++++++++++++------------------------ 1 files changed, 12 insertions(+), 24 deletions(-)
http.c +12 -24
@@ -13,14 +13,14 @@ static CURL *curl_default;char curl_errorstr[CURL_ERROR_SIZE ];static int curl_ssl_verify =-1 ; -static char *ssl_cert =NULL ; +static const char *ssl_cert =NULL ;#if LIBCURL_VERSION_NUM >=0x070902 -static char *ssl_key =NULL ; +static const char *ssl_key =NULL ;#endif #if LIBCURL_VERSION_NUM >=0x070908 -static char *ssl_capath =NULL ; +static const char *ssl_capath =NULL ;#endif -static char *ssl_cainfo =NULL ; +static const char *ssl_cainfo =NULL ;static long curl_low_speed_limit =-1 ;static long curl_low_speed_time =-1 ;static int curl_ftp_no_epsv =0 ;
@@ -100,39 +100,27 @@ static int http_options(const char *var, const char *value, void *cb) }if (!strcmp ("http.sslcert" , var)) { -if (ssl_cert ==NULL ) { -if (!value) -return config_error_nonbool (var); - ssl_cert =xstrdup (value); - } +if (ssl_cert ==NULL ) +return git_config_string (&ssl_cert, var, value);return 0 ; }#if LIBCURL_VERSION_NUM >=0x070902 if (!strcmp ("http.sslkey" , var)) { -if (ssl_key ==NULL ) { -if (!value) -return config_error_nonbool (var); - ssl_key =xstrdup (value); - } +if (ssl_key ==NULL ) +return git_config_string (&ssl_key, var, value);return 0 ; }#endif #if LIBCURL_VERSION_NUM >=0x070908 if (!strcmp ("http.sslcapath" , var)) { -if (ssl_capath ==NULL ) { -if (!value) -return config_error_nonbool (var); - ssl_capath =xstrdup (value); - } +if (ssl_capath ==NULL ) +return git_config_string (&ssl_capath, var, value);return 0 ; }#endif if (!strcmp ("http.sslcainfo" , var)) { -if (ssl_cainfo ==NULL ) { -if (!value) -return config_error_nonbool (var); - ssl_cainfo =xstrdup (value); - } +if (ssl_cainfo ==NULL ) +return git_config_string (&ssl_cainfo, var, value);return 0 ; }
Signature · 1 line
1.5.6.1.204.g699135