git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/5] convert.c: Use 'git_config_string' to get 'smudge' and 'clean'

From
Brian Hetro <whee@smaertness.net>
Date
Jul 5, 2008, 05:24 UTC
Message-ID
<81a6961a970f77cc8166c1ae59cae6326bc5c143.1215234749.git.whee@smaertness.net>
In-Reply-To
<f1c8159441e6afc5021e5f087f6feaf5b53e61df.1215234749.git.whee@smaertness.net>
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
Previous: Brian HetroNext: Brian Hetro
Message 4 of 7 in “git_config_string janitorial conversions.”
  1. 0/5 git_config_string janitorial conversions.Brian Hetro, Jul 5, 2008
  2. 1/5 builtin-commit.c: Use 'git_config_string' to get 'commit.template'Brian Hetro, Jul 5, 2008
  3. 2/5 builtin-log.c: Use 'git_config_string' to get 'format.subjectprefix' and 'format.suffix'Brian Hetro, Jul 5, 2008
  4. 3/5 convert.c: Use 'git_config_string' to get 'smudge' and 'clean'Brian Hetro, Jul 5, 2008
  5. 4/5 diff.c: Use 'git_config_string' to get 'diff.external'Brian Hetro, Jul 5, 2008
  6. 5/5 http.c: Use 'git_config_string' to clean up SSL config.Brian Hetro, Jul 5, 2008
  7. Christian CouderJul 6, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.