mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-11-26 06:32:19 +00:00
If the manifest checkout in `.repo/manifests` is on a detached HEAD, or on a local branch without an upstream, `Sync._GetBranch` read a missing `merge` config and crashed with `'NoneType' object has no attribute 'startswith'`. When smart sync is enabled by default, this broke plain `repo sync` for such checkouts because `AttributeError` bypassed the fallback to a regular ToT sync in `_ExecuteHelper`, which only catches `SmartSyncError` and `ManifestParseError`. Pinning the manifest via `repo init -b <sha>` or `repo init -b refs/tags/<tag>` also sent the raw revision to the manifest server as a branch name. Add `ManifestProject.GetMergeBranch(heads_only=...)` (shared with `XmlManifest._Load`) to resolve the upstream ref of the current manifest branch, returning `None` under `heads_only=True` unless it tracks `refs/heads/*`, and raise `SmartSyncError` in `_SmartSyncSetup` before running the remote helper or contacting the manifest server. Implicit smart sync now falls back to a regular ToT sync, and explicit smart sync fails early with an actionable error message. Bug: 580004259 Test: vpython3 run_tests Change-Id: Ice1f9bfe7ea8c923a283bcbd0ac7576cf33e42f6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/655123 Tested-by: Brian Gan <brgan@google.com> Commit-Queue: Brian Gan <brgan@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>