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 <gavinmak@google.com>
Reviewed-by: Carlos Fernandez <carlosfsanz@meta.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Lucas Alves <ltanure@gmail.com>
Tested-by: Lucas Alves <ltanure@gmail.com>
Reviewed-by: Lucas Alves <ltanure@gmail.com>
This commit is contained in:
Lucas Tanure
2026-03-07 09:15:45 +00:00
committed by LUCI
parent 0176586544
commit 0251fb33c4
+9
View File
@@ -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