]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
config: Make sure we handle empty lists from history properly
authorDaan De Meyer <daan@amutable.com>
Fri, 13 Feb 2026 08:01:03 +0000 (09:01 +0100)
committerDaan De Meyer <daan@amutable.com>
Fri, 13 Feb 2026 08:04:02 +0000 (09:04 +0100)
If we get an empty list from the history, that means the empty string
was specified on the cli, and hence we should treat it as a reset (by
setting the xxx_was_none field in the dict same as we would when parsing
it from the cli).

Note that we only need to do this for list based settings as regular
values will just have their default value written into the history.

mkosi/config.py

index f8cef3c871f7ffb9aad3a250725ddf0f0b0e820a..fbcc799e8e4068deb80ea704de0fd1b2113c0892 100644 (file)
@@ -5371,6 +5371,9 @@ def parse_config(
                     f"Ignoring {s.long} from the CLI. Run with -f to rebuild the image with this setting"
                 )
 
+            if s.dest in history and isinstance(history[s.dest], (list, dict, set)) and not history[s.dest]:
+                history[f"{s.dest}_was_none"] = True
+
         context.cli |= history
 
     cli = copy.deepcopy(context.cli)