diff --git a/borgmatic/config/generate.py b/borgmatic/config/generate.py index 05bbd36..e69d435 100644 --- a/borgmatic/config/generate.py +++ b/borgmatic/config/generate.py @@ -230,6 +230,8 @@ def merge_source_configuration_into_destination(destination_config, source_confi new configuration keys and comments. ''' + if not source_config: + return destination_config if not destination_config or not isinstance(source_config, collections.abc.Mapping): return source_config diff --git a/tests/unit/config/test_generate.py b/tests/unit/config/test_generate.py index a0a79ba..8e5a07f 100644 --- a/tests/unit/config/test_generate.py +++ b/tests/unit/config/test_generate.py @@ -123,3 +123,12 @@ def test_merge_source_configuration_into_destination_inserts_sequence_of_maps(): 'foo': [{'first': 'source1', 'second': 'dest2'}, {'other': 'source2'}], 'bar': 'dest3', } + + +def test_merge_source_configuration_into_destination_without_source_does_nothing(): + original_destination_config = {'foo': 'dest1', 'bar': 'dest2'} + destination_config = dict(original_destination_config) + + module.merge_source_configuration_into_destination(destination_config, None) + + assert destination_config == original_destination_config