* [PATCH] guard config parser from value=NULL
@ 2008-02-09 17:05 Martin Koegler
2008-02-09 21:07 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Martin Koegler @ 2008-02-09 17:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Martin Koegler
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
---
config.c | 10 +++++-----
setup.c | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/config.c b/config.c
index 658a11c..b2ea263 100644
--- a/config.c
+++ b/config.c
@@ -416,7 +416,7 @@ int git_default_config(const char *var, const char *value)
return 0;
}
- if (!strcmp(var, "user.name")) {
+ if (value && !strcmp(var, "user.name")) {
strlcpy(git_default_name, value, sizeof(git_default_name));
return 0;
}
@@ -426,12 +426,12 @@ int git_default_config(const char *var, const char *value)
return 0;
}
- if (!strcmp(var, "i18n.commitencoding")) {
+ if (value && !strcmp(var, "i18n.commitencoding")) {
git_commit_encoding = xstrdup(value);
return 0;
}
- if (!strcmp(var, "i18n.logoutputencoding")) {
+ if (value && !strcmp(var, "i18n.logoutputencoding")) {
git_log_output_encoding = xstrdup(value);
return 0;
}
@@ -442,12 +442,12 @@ int git_default_config(const char *var, const char *value)
return 0;
}
- if (!strcmp(var, "core.pager")) {
+ if (value && !strcmp(var, "core.pager")) {
pager_program = xstrdup(value);
return 0;
}
- if (!strcmp(var, "core.editor")) {
+ if (value && !strcmp(var, "core.editor")) {
editor_program = xstrdup(value);
return 0;
}
diff --git a/setup.c b/setup.c
index 23c9a11..8d792dc 100644
--- a/setup.c
+++ b/setup.c
@@ -445,7 +445,7 @@ int check_repository_format_version(const char *var, const char *value)
is_bare_repository_cfg = git_config_bool(var, value);
if (is_bare_repository_cfg == 1)
inside_work_tree = -1;
- } else if (strcmp(var, "core.worktree") == 0) {
+ } else if (value && strcmp(var, "core.worktree") == 0) {
if (git_work_tree_cfg)
free(git_work_tree_cfg);
git_work_tree_cfg = xstrdup(value);
--
1.5.4.gbd71f
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] guard config parser from value=NULL
2008-02-09 17:05 [PATCH] guard config parser from value=NULL Martin Koegler
@ 2008-02-09 21:07 ` Junio C Hamano
2008-02-10 17:08 ` Martin Koegler
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2008-02-09 21:07 UTC (permalink / raw)
To: Martin Koegler; +Cc: git
Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:
> @@ -416,7 +416,7 @@ int git_default_config(const char *var, const char *value)
> return 0;
> }
>
> - if (!strcmp(var, "user.name")) {
> + if (value && !strcmp(var, "user.name")) {
> strlcpy(git_default_name, value, sizeof(git_default_name));
> return 0;
> }
This is wrong, isn't it? When somebody says
[user]
name
we should not silently ignore it, but instead say "user.name is
not a bool!" and error out.
The same comment applies to all other
if (value && !strcmp(var, "<varname>"))
conversions.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] guard config parser from value=NULL
2008-02-09 21:07 ` Junio C Hamano
@ 2008-02-10 17:08 ` Martin Koegler
0 siblings, 0 replies; 3+ messages in thread
From: Martin Koegler @ 2008-02-10 17:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Govind Salinas
On Sat, Feb 09, 2008 at 01:07:53PM -0800, Junio C Hamano wrote:
> Martin Koegler <mkoegler@auto.tuwien.ac.at> writes:
>
> > @@ -416,7 +416,7 @@ int git_default_config(const char *var, const char *value)
> > return 0;
> > }
> >
> > - if (!strcmp(var, "user.name")) {
> > + if (value && !strcmp(var, "user.name")) {
> > strlcpy(git_default_name, value, sizeof(git_default_name));
> > return 0;
> > }
>
> This is wrong, isn't it? When somebody says
>
> [user]
> name
>
> we should not silently ignore it, but instead say "user.name is
> not a bool!" and error out.
>
> The same comment applies to all other
>
> if (value && !strcmp(var, "<varname>"))
>
> conversions.
For all in config.c, yes.
For setup.c, I would say no. The code is called, when trying to find a
git repository.
I have seen, that a similar patch for the config.c stuff has been
posted. I will wait some days to see, what happens with it.
mfg Martin Kögler
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-10 17:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-09 17:05 [PATCH] guard config parser from value=NULL Martin Koegler
2008-02-09 21:07 ` Junio C Hamano
2008-02-10 17:08 ` Martin Koegler
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).