From 0251fb33c485c3664df634517190b9c510ce7578 Mon Sep 17 00:00:00 2001 From: Lucas Tanure Date: Sat, 7 Mar 2026 09:15:45 +0000 Subject: [PATCH] project: don't re-shallow manually unshallowed repos during sync If a user has manually unshallowed a repo (e.g. via `git fetch --unshallow`), the absence of the `shallow` file in the gitdir indicates a full clone. Re-applying depth during a subsequent sync would undo the user's intent. Skip re-shallowing in this case by clearing depth when the project is not new and no shallow file is present. Change-Id: I4ee0e78018de9078fe1bd77a9615613ef0c40d33 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/558743 Reviewed-by: Gavin Mak Reviewed-by: Carlos Fernandez Reviewed-by: Mike Frysinger Commit-Queue: Lucas Alves Tested-by: Lucas Alves Reviewed-by: Lucas Alves --- project.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/project.py b/project.py index 5ac5320ce..67c00bdbb 100644 --- a/project.py +++ b/project.py @@ -1391,6 +1391,15 @@ class Project: else: depth = self.manifest.manifestProject.depth + # If the project has been manually unshallowed (e.g. via + # `git fetch --unshallow`), don't re-shallow it during sync. + if ( + depth + and not is_new + and not os.path.exists(os.path.join(self.gitdir, "shallow")) + ): + depth = None + if depth and clone_filter_for_depth: depth = None clone_filter = clone_filter_for_depth