All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Support "valueless truth" in configuration parsing
@ 2024-07-18 14:44 Junio C Hamano
  2024-07-18 15:59 ` Konstantin Ryabitsev
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2024-07-18 14:44 UTC (permalink / raw)
  To: tools; +Cc: Konstantin Ryabitsev

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()


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Support "valueless truth" in configuration parsing
  2024-07-18 14:44 [PATCH] Support "valueless truth" in configuration parsing Junio C Hamano
@ 2024-07-18 15:59 ` Konstantin Ryabitsev
  2024-07-18 16:01   ` Konstantin Ryabitsev
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Ryabitsev @ 2024-07-18 15:59 UTC (permalink / raw)
  To: tools, Junio C Hamano


On Thu, 18 Jul 2024 07:44:52 -0700, Junio C Hamano wrote:
> With a configuration item somewhere (like ~/.gitconfig) like this:
> 
>     [sendemail]
>         suppressfrom
> 
> "b4" barfs while parsing the configuration file.
> 
> [...]

Applied, thanks!

[1/1] Support "valueless truth" in configuration parsing
      commit: d04d7f4ec48b083b7d83886b1b7e743111cc16d4

Best regards,
-- 
Konstantin Ryabitsev <konstantin@linuxfoundation.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Support "valueless truth" in configuration parsing
  2024-07-18 15:59 ` Konstantin Ryabitsev
@ 2024-07-18 16:01   ` Konstantin Ryabitsev
  0 siblings, 0 replies; 3+ messages in thread
From: Konstantin Ryabitsev @ 2024-07-18 16:01 UTC (permalink / raw)
  To: tools, Junio C Hamano

On Thu, Jul 18, 2024 at 11:59:41AM GMT, Konstantin Ryabitsev wrote:
> 
> On Thu, 18 Jul 2024 07:44:52 -0700, Junio C Hamano wrote:
> > With a configuration item somewhere (like ~/.gitconfig) like this:
> > 
> >     [sendemail]
> >         suppressfrom
> > 
> > "b4" barfs while parsing the configuration file.
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/1] Support "valueless truth" in configuration parsing
>       commit: d04d7f4ec48b083b7d83886b1b7e743111cc16d4

Also backported to stable-0.14.y.

Thanks!

-K

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-18 16:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-18 14:44 [PATCH] Support "valueless truth" in configuration parsing Junio C Hamano
2024-07-18 15:59 ` Konstantin Ryabitsev
2024-07-18 16:01   ` Konstantin Ryabitsev

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.