Re: [bug] generic issue with git_config handlers

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Pierre Habouzit <madcoder@...>
Cc: Junio C Hamano <gitster@...>, Git ML <git@...>
Date: Monday, February 4, 2008 - 2:27 am

Le jeudi 31 janvier 2008, Pierre Habouzit a écrit :

I would suggest this patch:

---8<---
diff --git a/config.c b/config.c
index 526a3f4..92613c5 100644
--- a/config.c
+++ b/config.c
@@ -139,7 +139,7 @@ static int get_value(config_fn_t fn, char *name, 
unsigned in
                if (!value)
                        return -1;
        }
-       return fn(name, value);
+       return fn(name, value ? value : "");
 }

 static int get_extended_base_var(char *name, int baselen, int c)
---8<---

but it breaks some test cases.

$ ./t1300-repo-config.sh -d -i -v

[...]

* expecting success: git config --get-regexp novalue > output &&
         cmp output expect
output expect differ: char 17, line 1
* FAIL 34: get-regexp variable with no value
        git config --get-regexp novalue > output &&
                 cmp output expect

$ cat output | hexdump -C
00000000  6e 6f 76 61 6c 75 65 2e  76 61 72 69 61 62 6c 65  |
novalue.variable|
00000010  20 0a                                             | .|
00000012

$ cat expect | hexdump -C
00000000  6e 6f 76 61 6c 75 65 2e  76 61 72 69 61 62 6c 65  |
novalue.variable|
00000010  0a                                                |.|
00000011

I don't know if the added space is a big problem.

It comes from the following code in builtin-config.c:44

	if (show_keys) {
		if (value_)
			printf("%s%c", key_, key_delim);
		else
			printf("%s", key_);

where "value_" is now "" instead of NULL.

At this point, as I don't know much the code in these files, I think I could 
very well use some advice from people more familiar with this.

Thanks in advance,
Christian.


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[bug] generic issue with git_config handlers, Pierre Habouzit, (Thu Jan 31, 5:16 am)
Re: [bug] generic issue with git_config handlers, Junio C Hamano, (Thu Jan 31, 5:25 am)
Re: [bug] generic issue with git_config handlers, Pierre Habouzit, (Thu Jan 31, 6:10 am)
Re: [bug] generic issue with git_config handlers, Christian Couder, (Mon Feb 4, 2:27 am)
Re: [bug] generic issue with git_config handlers, Johannes Sixt, (Mon Feb 4, 1:01 pm)
Re: [bug] generic issue with git_config handlers, Christian Couder, (Mon Feb 4, 7:13 pm)
Re: [bug] generic issue with git_config handlers, Junio C Hamano, (Mon Feb 4, 8:03 pm)
Re: [bug] generic issue with git_config handlers, Christian Couder, (Thu Feb 7, 1:45 am)