]> git.ipfire.org Git - thirdparty/git.git/commitdiff
imap-send: don't use git_die_config() inside callback
authorJeff King <peff@peff.net>
Thu, 7 Dec 2023 07:24:58 +0000 (02:24 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Dec 2023 23:26:21 +0000 (08:26 +0900)
The point of git_die_config() is to let configset users mention the
file/line info for invalid config, like:

  if (!git_config_get_int("foo.bar", &value)) {
if (!is_ok(value))
git_die_config("foo.bar");
  }

Using it from within a config callback is unnecessary, because we can
simply return an error, at which point the config machinery will mention
the file/line of the offending variable. Worse, using git_die_config()
can actually produce the wrong location when the key is found in
multiple spots. For instance, with config like:

  [imap]
  host
  host = foo

we'll report the line number of the "host = foo" line, but the problem
is on the implicit-bool "host" line.

We can fix it by just returning an error code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
imap-send.c

index 996651e4f80abd5fa2daf570f9d981934d328aeb..5b0fe4f95a03852f6175f7deab9f17dc7648dbb5 100644 (file)
@@ -1346,7 +1346,7 @@ static int git_imap_config(const char *var, const char *val,
                server.port = git_config_int(var, val, ctx->kvi);
        else if (!strcmp("imap.host", var)) {
                if (!val) {
-                       git_die_config("imap.host", "Missing value for 'imap.host'");
+                       return error("Missing value for 'imap.host'");
                } else {
                        if (starts_with(val, "imap:"))
                                val += 5;