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

[PATCH 2/2] add variable name to `git_config_*()` error message

From
Tanay Abhra <tanayabh@gmail.com>
Date
Jul 31, 2014, 13:42 UTC
Message-ID
<1406814126-10457-2-git-send-email-tanayabh@gmail.com>
In-Reply-To
<1406814126-10457-1-git-send-email-tanayabh@gmail.com>

Whenever a callback returns a negative value, the functions of `git_config_*()` family die printing the line number and file name. In addition to them, add the variable name to the error message.

Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
---
 config.c                | 4 ++--
 t/t4055-diff-context.sh | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/config.c b/config.c
index 7330789..77407da 100644
--- a/config.c
+++ b/config.c
@@ -442,9 +442,9 @@ static int git_parse_source(config_fn_t fn, void *data)
 			break;
 	}
 	if (cf->die_on_error)
-		die(_("bad config file line %d in %s"), cf->linenr, cf->name);
+		die(_("bad config variable '%s' at file line %d in %s"), var->buf, cf->linenr, cf->name);
 	else
-		return error(_("bad config file line %d in %s"), cf->linenr, cf->name);
+		return error(_("bad config variable '%s' at file line %d in %s"), var->buf, cf->linenr, cf->name);
 }
 
 static int parse_unit_factor(const char *end, uintmax_t *val)
diff --git a/t/t4055-diff-context.sh b/t/t4055-diff-context.sh
index cd04543..741e080 100755
--- a/t/t4055-diff-context.sh
+++ b/t/t4055-diff-context.sh
@@ -79,7 +79,7 @@ test_expect_success 'non-integer config parsing' '
 test_expect_success 'negative integer config parsing' '
 	git config diff.context -1 &&
 	test_must_fail git diff 2>output &&
-	test_i18ngrep "bad config file" output
+	test_i18ngrep "bad config variable" output
 '
 
 test_expect_success '-U0 is valid, so is diff.context=0' '
-- 
1.9.0.GIT
Previous: Tanay AbhraNext: Tanay Abhra
Message 2 of 4 in “config.c: mark error and warnings strings for translation”
  1. 1/2 config.c: mark error and warnings strings for translationTanay Abhra, Jul 31, 2014
  2. 2/2 add variable name to `git_config_*()` error messageTanay Abhra, Jul 31, 2014
  3. Tanay AbhraJul 31, 2014
  4. Matthieu MoyJul 31, 2014

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.