threads / patch / 11468

patchdiff: load funcname patterns in "basic" config

Subject: [PATCH] diff: load funcname patterns in "basic" config

## tl;dr

2 messages between Jan 4, 2008 and Jan 4, 2008. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Jeff King· Jan 4, 2008, 09:16 UTC · lore

The funcname patterns influence the "comment" on @@ lines of the diff. They are safe to use with plumbing since they don't fundamentally change the meaning of the diff in any way.

Since all diff users call either diff_ui_config or diff_basic_config, we can get rid of the lazy reading of the config.

Signed-off-by: Jeff King <peff@peff.net>
---
I am slightly worried that I'm missing something fundamental here. Why
were these ever lazily loaded in the first place? Ditto for the user
diff drivers, which should just get loaded when the command parses the
config for the first time.
 diff.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
Show changes to diff.c +8 −3
diff --git a/diff.c b/diff.c
index 6bb0f62..1ea10c8 100644
--- a/diff.c
+++ b/diff.c
@@ -179,8 +179,6 @@ #include "run-command.h"
 		if (ep != var + 4) {
 			if (!strcmp(ep, ".command"))
 				return parse_lldiff_command(var, ep, value);
-			if (!strcmp(ep, ".funcname"))
-				return parse_funcname_pattern(var, ep, value);
 		}
 	}
 
@@ -195,6 +193,14 @@ #include "run-command.h"
 		return 0;
 	}
 
+	if (!prefixcmp(var, "diff.")) {
+		const char *ep = strrchr(var, '.');
+		if (ep != var + 4) {
+			if (!strcmp(ep, ".funcname"))
+				return parse_funcname_pattern(var, ep, value);
+		}
+	}
+
 	return git_default_config(var, value);
 }
 
@@ -1165,7 +1171,6 @@ #include "run-command.h"
 {
 	struct funcname_pattern *pp;
 
-	read_config_if_needed();
 	for (pp = funcname_pattern_list; pp; pp = pp->next)
 		if (!strcmp(ident, pp->name))
 			return pp->pattern;
-- 
1.5.4.rc2.1124.g7c85e-dirty
Jeff King· Jan 4, 2008, 09:19 UTC · re: Jeff King · lore

Re: [PATCH] diff: load funcname patterns in "basic" config

On Fri, Jan 04, 2008 at 04:16:14AM -0500, Jeff King wrote:
> --- a/diff.c
> +++ b/diff.c
> @@ -179,8 +179,6 @@ #include "run-command.h"

Heh, I had a goofy diff.default.funcname option set up to test this out. A slightly more readable version of the patch is below.

-- >8 -- diff: load funcname patterns in "basic" config

The funcname patterns influence the "comment" on @@ lines of the diff. They are safe to use with plumbing since they don't fundamentally change the meaning of the diff in any way.

Since all diff users call either diff_ui_config or diff_basic_config, we can get rid of the lazy reading of the config.

Signed-off-by: Jeff King <peff@peff.net>
---
 diff.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
Show changes to diff.c +8 −3
diff --git a/diff.c b/diff.c
index 6bb0f62..1ea10c8 100644
--- a/diff.c
+++ b/diff.c
@@ -179,8 +179,6 @@ int git_diff_ui_config(const char *var, const char *value)
 		if (ep != var + 4) {
 			if (!strcmp(ep, ".command"))
 				return parse_lldiff_command(var, ep, value);
-			if (!strcmp(ep, ".funcname"))
-				return parse_funcname_pattern(var, ep, value);
 		}
 	}
 
@@ -195,6 +193,14 @@ int git_diff_basic_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!prefixcmp(var, "diff.")) {
+		const char *ep = strrchr(var, '.');
+		if (ep != var + 4) {
+			if (!strcmp(ep, ".funcname"))
+				return parse_funcname_pattern(var, ep, value);
+		}
+	}
+
 	return git_default_config(var, value);
 }
 
@@ -1165,7 +1171,6 @@ static const char *funcname_pattern(const char *ident)
 {
 	struct funcname_pattern *pp;
 
-	read_config_if_needed();
 	for (pp = funcname_pattern_list; pp; pp = pp->next)
 		if (!strcmp(ident, pp->name))
 			return pp->pattern;
-- 
1.5.4.rc2.1124.g7c85e-dirty

← back to recent threads