git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] git_config_string janitorial conversions.
@ 2008-07-05  5:24 Brian Hetro
  2008-07-05  5:24 ` [PATCH 1/5] builtin-commit.c: Use 'git_config_string' to get 'commit.template' Brian Hetro
  2008-07-06  3:47 ` [PATCH 0/5] git_config_string janitorial conversions Christian Couder
  0 siblings, 2 replies; 7+ messages in thread
From: Brian Hetro @ 2008-07-05  5:24 UTC (permalink / raw)
  To: git; +Cc: gitster, Brian Hetro

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(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] builtin-commit.c: Use 'git_config_string' to get 'commit.template'
  2008-07-05  5:24 [PATCH 0/5] git_config_string janitorial conversions Brian Hetro
@ 2008-07-05  5:24 ` Brian Hetro
  2008-07-05  5:24   ` [PATCH 2/5] builtin-log.c: Use 'git_config_string' to get 'format.subjectprefix' and 'format.suffix' Brian Hetro
  2008-07-06  3:47 ` [PATCH 0/5] git_config_string janitorial conversions Christian Couder
  1 sibling, 1 reply; 7+ messages in thread
From: Brian Hetro @ 2008-07-05  5:24 UTC (permalink / raw)
  To: git; +Cc: gitster, Brian Hetro

Signed-off-by: Brian Hetro <whee@smaertness.net>
---
 builtin-commit.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index e3ad38b..745c11e 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -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);
 }
-- 
1.5.6.1.204.g699135

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] builtin-log.c: Use 'git_config_string' to get 'format.subjectprefix' and 'format.suffix'
  2008-07-05  5:24 ` [PATCH 1/5] builtin-commit.c: Use 'git_config_string' to get 'commit.template' Brian Hetro
@ 2008-07-05  5:24   ` Brian Hetro
  2008-07-05  5:24     ` [PATCH 3/5] convert.c: Use 'git_config_string' to get 'smudge' and 'clean' Brian Hetro
  0 siblings, 1 reply; 7+ messages in thread
From: Brian Hetro @ 2008-07-05  5:24 UTC (permalink / raw)
  To: git; +Cc: gitster, Brian Hetro

Signed-off-by: Brian Hetro <whee@smaertness.net>
---
 builtin-log.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/builtin-log.c b/builtin-log.c
index 9979e37..430d876 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -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);
-- 
1.5.6.1.204.g699135

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] convert.c: Use 'git_config_string' to get 'smudge' and 'clean'
  2008-07-05  5:24   ` [PATCH 2/5] builtin-log.c: Use 'git_config_string' to get 'format.subjectprefix' and 'format.suffix' Brian Hetro
@ 2008-07-05  5:24     ` Brian Hetro
  2008-07-05  5:24       ` [PATCH 4/5] diff.c: Use 'git_config_string' to get 'diff.external' Brian Hetro
  0 siblings, 1 reply; 7+ messages in thread
From: Brian Hetro @ 2008-07-05  5:24 UTC (permalink / raw)
  To: git; +Cc: gitster, Brian Hetro

Signed-off-by: Brian Hetro <whee@smaertness.net>
---
 convert.c |   25 +++++++++----------------
 1 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/convert.c b/convert.c
index 1c66844..352b69d 100644
--- a/convert.c
+++ b/convert.c
@@ -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, struc
 	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)) {
-- 
1.5.6.1.204.g699135

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] diff.c: Use 'git_config_string' to get 'diff.external'
  2008-07-05  5:24     ` [PATCH 3/5] convert.c: Use 'git_config_string' to get 'smudge' and 'clean' Brian Hetro
@ 2008-07-05  5:24       ` Brian Hetro
  2008-07-05  5:24         ` [PATCH 5/5] http.c: Use 'git_config_string' to clean up SSL config Brian Hetro
  0 siblings, 1 reply; 7+ messages in thread
From: Brian Hetro @ 2008-07-05  5:24 UTC (permalink / raw)
  To: git; +Cc: gitster, Brian Hetro

Signed-off-by: Brian Hetro <whee@smaertness.net>
---
 diff.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/diff.c b/diff.c
index 803fbba..6a39b39 100644
--- a/diff.c
+++ b/diff.c
@@ -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, '.');
 
-- 
1.5.6.1.204.g699135

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] http.c: Use 'git_config_string' to clean up SSL config.
  2008-07-05  5:24       ` [PATCH 4/5] diff.c: Use 'git_config_string' to get 'diff.external' Brian Hetro
@ 2008-07-05  5:24         ` Brian Hetro
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Hetro @ 2008-07-05  5:24 UTC (permalink / raw)
  To: git; +Cc: gitster, Brian Hetro

Signed-off-by: Brian Hetro <whee@smaertness.net>
---
 http.c |   36 ++++++++++++------------------------
 1 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/http.c b/http.c
index 105dc93..c22adcc 100644
--- a/http.c
+++ b/http.c
@@ -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;
 	}
 
-- 
1.5.6.1.204.g699135

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] git_config_string janitorial conversions.
  2008-07-05  5:24 [PATCH 0/5] git_config_string janitorial conversions Brian Hetro
  2008-07-05  5:24 ` [PATCH 1/5] builtin-commit.c: Use 'git_config_string' to get 'commit.template' Brian Hetro
@ 2008-07-06  3:47 ` Christian Couder
  1 sibling, 0 replies; 7+ messages in thread
From: Christian Couder @ 2008-07-06  3:47 UTC (permalink / raw)
  To: Brian Hetro; +Cc: git, gitster

Le samedi 5 juillet 2008, Brian Hetro a écrit :
> 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:

> int git_commit_config(const char *k, const char *v, void *cb)
> {
> -       if (!strcmp(k, "commit.template")) {
> -               if (!v)
> -                       return config_error_nonbool(v);

It should have been:
-                       return config_error_nonbool(k);

> -               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):

Tested-by: Christian Couder <chriscool@tuxfamily.org>

Thanks,
Christian.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-07-06  3:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-05  5:24 [PATCH 0/5] git_config_string janitorial conversions Brian Hetro
2008-07-05  5:24 ` [PATCH 1/5] builtin-commit.c: Use 'git_config_string' to get 'commit.template' Brian Hetro
2008-07-05  5:24   ` [PATCH 2/5] builtin-log.c: Use 'git_config_string' to get 'format.subjectprefix' and 'format.suffix' Brian Hetro
2008-07-05  5:24     ` [PATCH 3/5] convert.c: Use 'git_config_string' to get 'smudge' and 'clean' Brian Hetro
2008-07-05  5:24       ` [PATCH 4/5] diff.c: Use 'git_config_string' to get 'diff.external' Brian Hetro
2008-07-05  5:24         ` [PATCH 5/5] http.c: Use 'git_config_string' to clean up SSL config Brian Hetro
2008-07-06  3:47 ` [PATCH 0/5] git_config_string janitorial conversions Christian Couder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).