All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: tools@kernel.org
Cc: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Subject: [PATCH] Support "valueless truth" in configuration parsing
Date: Thu, 18 Jul 2024 07:44:52 -0700	[thread overview]
Message-ID: <xmqq34o6zrmj.fsf@gitster.g> (raw)

With a configuration item somewhere (like ~/.gitconfig) like this:

    [sendemail]
        suppressfrom

"b4" barfs while parsing the configuration file.

The code assumes that "git config -z" output, after splitting at
NUL, would always be a LF separated variable and value, but that
does not hold for such a variable defined with only its name without
"= <value>", which means that variable is given the value "true".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * It seems that this part of the parser hasn't changed at all since
   ae57d6ea (Initial commit after porting from korg-helpers,
   2020-03-14).  The patch was made against the current tip 47743a82
   (Improve tests exclusion from the built packages, 2024-07-17),
   but presumably it would apply anywhere.

 src/b4/__init__.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 7164d3f..ae15b83 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -2824,7 +2824,10 @@ def get_config_from_git(regexp: str, defaults: Opti
     for line in out.split('\x00'):
         if not line:
             continue
-        key, value = line.split('\n', 1)
+        if '\n' in line:
+            key, value = line.split('\n', 1)
+        else:
+            key, value = line, 'true'
         try:
             chunks = key.split('.')
             cfgkey = chunks[-1].lower()


             reply	other threads:[~2024-07-18 14:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-18 14:44 Junio C Hamano [this message]
2024-07-18 15:59 ` [PATCH] Support "valueless truth" in configuration parsing Konstantin Ryabitsev
2024-07-18 16:01   ` Konstantin Ryabitsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq34o6zrmj.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=konstantin@linuxfoundation.org \
    --cc=tools@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.