Skip to content

Commit

Permalink
Merge pull request #682 from mih/empty-cfg
Browse files Browse the repository at this point in the history
`set_gitconfig_items_in_env()`: treat `None` as empty string
  • Loading branch information
mih committed May 14, 2024
2 parents 9b9984e + 10c4a44 commit c5b3620
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion datalad_next/config/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ def set_gitconfig_items_in_env(items: Mapping[str, str | Tuple[str, ...]]):
Multi-value configuration keys are supported (values provided as a tuple).
Any item with a value of ``None`` will be posted into the ENV with an
empty string as value, i.e. the corresponding ``GIT_CONFIG_VALUE_{count}``
variable will be an empty string. ``None`` item values indicate that the
configuration key was unset on the command line, via the global option
``-c``.
No verification (e.g., of syntax compliance) is performed.
"""
_clean_env_from_gitconfig_items()
Expand All @@ -83,7 +89,10 @@ def set_gitconfig_items_in_env(items: Mapping[str, str | Tuple[str, ...]]):
values = value if isinstance(value, tuple) else (value,)
for v in values:
environ[f'GIT_CONFIG_KEY_{count}'] = key
environ[f'GIT_CONFIG_VALUE_{count}'] = v
# we support None even though not an allowed input type, because
# of https://github.com/datalad/datalad/issues/7589
# this can be removed, when that issue is resolved.
environ[f'GIT_CONFIG_VALUE_{count}'] = '' if v is None else str(v)
count += 1
if count:
environ['GIT_CONFIG_COUNT'] = str(count)
Expand Down

0 comments on commit c5b3620

Please sign in to comment.