commit: 34b619eb646e8de4041268f05b04c44db9485243
Author: Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 30 18:21:45 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Oct 31 00:34:49 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=34b619eb
sync/git: invoke add_safe_directory() earlier when updating a repo
Otherwise "git rev-parse --is-shallow-repository" may fail
fatal: detected dubious ownership in repository at
'/home/flo/data/repos/gentoo/tex-overlay'
To add an exception for this directory, call:
git config --global --add safe.directory
/home/flo/data/repos/gentoo/tex-overlay
Traceback (most recent call last):
File
"/usr/lib/python3.12/site-packages/portage/util/_async/AsyncFunction.py", line
41, in _target_wrapper
result = target(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/portage/sync/controller.py", line
172, in sync
taskmaster.run_tasks(tasks, func, status, options=task_opts)
File "/usr/lib/python3.12/site-packages/portage/sync/controller.py", line 65,
in run_tasks
result = getattr(inst, func)(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/portage/sync/syncbase.py", line 370,
in sync
return self.update()
^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/portage/sync/modules/git/git.py",
line 242, in update
subprocess.check_output(
File "/usr/lib/python3.12/subprocess.py", line 466, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/subprocess.py", line 571, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'rev-parse',
'--is-shallow-repository']' returned non-zero exit status 128.
Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1171
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/portage/sync/modules/git/git.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/portage/sync/modules/git/git.py
b/lib/portage/sync/modules/git/git.py
index 24389ca02a..48109b7844 100644
--- a/lib/portage/sync/modules/git/git.py
+++ b/lib/portage/sync/modules/git/git.py
@@ -152,6 +152,8 @@ class GitSync(NewBase):
{"GIT_CEILING_DIRECTORIES":
self._gen_ceiling_string(self.repo.location)}
)
+ self.add_safe_directory()
+
if self.repo.module_specific_options.get("sync-git-env"):
shlexed_env =
shlex_split(self.repo.module_specific_options["sync-git-env"])
env = {
@@ -261,8 +263,6 @@ class GitSync(NewBase):
f"
{self.repo.module_specific_options['sync-git-pull-extra-opts']}"
)
- self.add_safe_directory()
-
try:
remote_branch = portage._unicode_decode(
subprocess.check_output(