git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: larsxschneider@gmail.com
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net, Johannes.Schindelin@gmx.de,
	jehan@orb.com, whee@smaertness.net, me@ttaylorr.com,
	Lars Schneider <larsxschneider@gmail.com>
Subject: [PATCH v1 1/2] convert: refactor conversion driver config parsing
Date: Sun,  8 Jul 2018 20:30:35 +0200	[thread overview]
Message-ID: <20180708183036.29459-2-larsxschneider@gmail.com> (raw)
In-Reply-To: <20180708183036.29459-1-larsxschneider@gmail.com>

From: Lars Schneider <larsxschneider@gmail.com>

Refactor conversion driver config parsing to ease the parsing of new
configs in a subsequent patch.

No functional change intended.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---
 convert.c | 64 +++++++++++++++++++++++++++----------------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/convert.c b/convert.c
index 64d0d30e08..949bc783e4 100644
--- a/convert.c
+++ b/convert.c
@@ -1003,43 +1003,43 @@ static int read_convert_config(const char *var, const char *value, void *cb)
 	int namelen;
 	struct convert_driver *drv;
 
-	/*
-	 * External conversion drivers are configured using
-	 * "filter.<name>.variable".
-	 */
-	if (parse_config_key(var, "filter", &name, &namelen, &key) < 0 || !name)
-		return 0;
-	for (drv = user_convert; drv; drv = drv->next)
-		if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
-			break;
-	if (!drv) {
-		drv = xcalloc(1, sizeof(struct convert_driver));
-		drv->name = xmemdupz(name, namelen);
-		*user_convert_tail = drv;
-		user_convert_tail = &(drv->next);
-	}
+	if (parse_config_key(var, "filter", &name, &namelen, &key) >= 0 && name) {
+		/*
+		 * External conversion drivers are configured using
+		 * "filter.<name>.variable".
+		 */
+		for (drv = user_convert; drv; drv = drv->next)
+			if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
+				break;
+		if (!drv) {
+			drv = xcalloc(1, sizeof(struct convert_driver));
+			drv->name = xmemdupz(name, namelen);
+			*user_convert_tail = drv;
+			user_convert_tail = &(drv->next);
+		}
 
-	/*
-	 * filter.<name>.smudge and filter.<name>.clean specifies
-	 * the command line:
-	 *
-	 *	command-line
-	 *
-	 * The command-line will not be interpolated in any way.
-	 */
+		/*
+		 * filter.<name>.smudge and filter.<name>.clean specifies
+		 * the command line:
+		 *
+		 *	command-line
+		 *
+		 * The command-line will not be interpolated in any way.
+		 */
 
-	if (!strcmp("smudge", key))
-		return git_config_string(&drv->smudge, var, value);
+		if (!strcmp("smudge", key))
+			return git_config_string(&drv->smudge, var, value);
 
-	if (!strcmp("clean", key))
-		return git_config_string(&drv->clean, var, value);
+		if (!strcmp("clean", key))
+			return git_config_string(&drv->clean, var, value);
 
-	if (!strcmp("process", key))
-		return git_config_string(&drv->process, var, value);
+		if (!strcmp("process", key))
+			return git_config_string(&drv->process, var, value);
 
-	if (!strcmp("required", key)) {
-		drv->required = git_config_bool(var, value);
-		return 0;
+		if (!strcmp("required", key)) {
+			drv->required = git_config_bool(var, value);
+			return 0;
+		}
 	}
 
 	return 0;
-- 
2.18.0


  reply	other threads:[~2018-07-08 18:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-08 18:30 [PATCH v1 0/2] convert: add alias support for 'working-tree-encoding' attributes larsxschneider
2018-07-08 18:30 ` larsxschneider [this message]
2018-07-08 18:35   ` [PATCH v1 1/2] convert: refactor conversion driver config parsing Lars Schneider
2018-07-09 20:01     ` Junio C Hamano
2018-07-10 16:25   ` Junio C Hamano
2018-07-08 18:30 ` [PATCH v1 2/2] convert: add alias support for 'working-tree-encoding' attributes larsxschneider
2018-07-08 18:39   ` Lars Schneider
2018-07-10 16:31   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180708183036.29459-2-larsxschneider@gmail.com \
    --to=larsxschneider@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jehan@orb.com \
    --cc=me@ttaylorr.com \
    --cc=peff@peff.net \
    --cc=whee@smaertness.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).