Skip to contentSkip to conversation

Support "valueless truth" in configuration parsing

PATCH Applied Junio C Hamano 2 participants 3 messages Jul 18, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support "valueless truth" in configuration parsing

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".

---

* 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(-)
src/b4/__init__.py +4 -1
index 7164d3f..ae15b83 100644
@@ -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()
#1 lore raw
Quoted 8 lines · Junio C Hamano

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,

Signature · 1 line
Konstantin Ryabitsev <[email protected]>
#2 lore raw
Quoted 7 lines · Konstantin Ryabitsev
Quoted 5 lines · Junio C Hamano

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

[sendemail]
suppressfrom

Quoted 8 lines
Quoted 3 lines

"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