Skip to content

Commit

Permalink
handle_path_include: don't look at NULL value
Browse files Browse the repository at this point in the history
When we see config like:

  [include]
  path

the expand_user_path helper notices that the config value is
empty, but we then dereference NULL while printing the error
message (glibc will helpfully print "(null)" for us here,
but we cannot rely on that).

  $ git -c include.path rev-parse
  error: Could not expand include path '(null)'
  fatal: unable to parse command-line config

Instead of tweaking our message, let's actually use
config_error_nonbool to match other config variables that
expect a value:

  $ git -c include.path rev-parse
  error: Missing value for 'include.path'
  fatal: unable to parse command-line config

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jan 28, 2014
1 parent 53ec551 commit 67beb60
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ static int handle_path_include(const char *path, struct config_include_data *inc
{
int ret = 0;
struct strbuf buf = STRBUF_INIT;
char *expanded = expand_user_path(path);
char *expanded;

if (!path)
return config_error_nonbool("include.path");

expanded = expand_user_path(path);
if (!expanded)
return error("Could not expand include path '%s'", path);
path = expanded;
Expand Down

0 comments on commit 67beb60

Please sign in to comment.