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

Re: [PATCH] alias.c: use git_config_string() to get alias_val

From
Stephan Beyer <s-beyer@gmx.net>
Date
Apr 6, 2008, 11:02 UTC
Message-ID
<20080406110232.GA6965@leksak.fem-net>
In-Reply-To
<200804060749.34109.chriscool@tuxfamily.org>
Hi,
> So you should say in the commit message that you decided to cast to "const 
> char **" despite what is on the Janitor page, and most importantly explain 
> why in the commit message.

Ah, ok. Didn't knew that such reasoning goes into the commit message, but, yes, it makes sense.

Show 5 quoted lines
> > But instead of doing that, the original should be kept, because it is
> > better in code beauty, performance and memory usage. ;-)
> 
> Yes, so perhaps it's not a good idea to convert the original file to 
> git_config_string.
Or to use the cast. ;-)
[...]
> But I don't think it's worth the trouble.
I agree ;-)

So what to do? Keep it?

And there are still some easy `Janitor tasks', like in builtin-apply.c: --

diff --git a/builtin-apply.c b/builtin-apply.c
index b5f78ac..ce0a0c3 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2978,12 +2978,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
 
 static int git_apply_config(const char *var, const char *value)
 {
-	if (!strcmp(var, "apply.whitespace")) {
-		if (!value)
-			return config_error_nonbool(var);
-		apply_default_whitespace = xstrdup(value);
-		return 0;
-	}
+	if (!strcmp(var, "apply.whitespace"))
+		return git_config_string(&apply_default_whitespace, var, value);
 	return git_default_config(var, value);
 }
 
--
(Test case: git-apply a patch with trailing whitespaces and check with
apply.whitespace = nowarn / fix / error)

I have attached the patch because I do not want to drop another 
mail for it.
And now there is nothing to argue about, I hope, because it is as simple as
http://git.kernel.org/?p=git/git.git;a=commitdiff;h=9886ea417b7da9722c95630b5980ac174e04c71c


Regards,
 Stephan
-- 
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F


>From 78d1ac0fd19b274853d3c8439d45922c1a0fe82d Mon Sep 17 00:00:00 2001
From: Stephan Beyer <s-beyer@gmx.net>
Date: Sun, 6 Apr 2008 12:37:31 +0200
Subject: [PATCH] builtin-apply.c: use git_config_string() to get apply_default_whitespace

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
---
 builtin-apply.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/builtin-apply.c b/builtin-apply.c
index b5f78ac..ce0a0c3 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2978,12 +2978,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
 
 static int git_apply_config(const char *var, const char *value)
 {
-	if (!strcmp(var, "apply.whitespace")) {
-		if (!value)
-			return config_error_nonbool(var);
-		apply_default_whitespace = xstrdup(value);
-		return 0;
-	}
+	if (!strcmp(var, "apply.whitespace"))
+		return git_config_string(&apply_default_whitespace, var, value);
 	return git_default_config(var, value);
 }
 
-- 
1.5.5.rc3.8.g78d1a
Previous: Christian CouderNext: Christian Couder
Message 5 of 6 in “alias.c: use git_config_string() to get alias_val”
  1. alias.c: use git_config_string() to get alias_valStephan Beyer, Apr 5, 2008
  2. Christian CouderApr 5, 2008
  3. Stephan BeyerApr 5, 2008
  4. Christian CouderApr 6, 2008
  5. Stephan BeyerApr 6, 2008
  6. Christian CouderApr 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.