From 124ae4dc7f2c5ba2235014af958d7a16a77ef695 Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Tue, 7 Jan 2025 08:48:54 +0100 Subject: [PATCH] fix: perform proper provision in an annex remote This commit fixes an issue where subdataset provision did not work if `provision` was invoked from an annex special remote-process. The reason for the error was that the special remote sets the environment variables `GIT_DIR` and `GIT_WORK_TREE`, which lead to problems in `datalad.get`. --- datalad_remake/commands/provision_cmd.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/datalad_remake/commands/provision_cmd.py b/datalad_remake/commands/provision_cmd.py index a6cf125..1f152ed 100644 --- a/datalad_remake/commands/provision_cmd.py +++ b/datalad_remake/commands/provision_cmd.py @@ -390,7 +390,15 @@ def install_subdataset( absolute_path.as_uri(), ] call_git_lines(args) - worktree.get(str(subdataset_path), get_data=False, result_renderer='disabled') + stored_environ = dict(os.environ) + try: + for key in ('GIT_DIR', 'GIT_WORK_TREE'): + if key in os.environ: + del os.environ[key] + worktree.get(str(subdataset_path), get_data=False, result_renderer='disabled') + finally: + os.environ.clear() + os.environ.update(stored_environ) uninstalled_subdatasets.remove(subdataset_path) uninstalled_subdatasets.update(get_uninstalled_subdatasets(worktree))