swift
714d48ca - update-checkout: Make stale PR merge ref refresh work during shallow clone

Commit
1 day ago
update-checkout: Make stale PR merge ref refresh work during shallow clone A regular fetch will not deepen a grafted commit, so the correct approach fails for a fresh shallow clone. Instead: 1. Fetch the merge ref as we already do, but with depth 2. If we omitted the depth and the local repository was shallow, this command would effectively (and wastefully) unshallow it, so do not fetch more than necessary. If it happens that we need to update the PR merge ref, its parent commits are enough history to find a merge base between it and the PR base branch. 2. No changes. Check out a branch at the PR merge ref, resetting the branch if it exists. 3. Grab the first parent of the merge ref and compare it to the remote base branch tip to determine whether the merge ref is stale. If up to date, that's it. Otherwise, proceed. 4. If the local repository is non-shallow, fetch the base branch. Otherwise, fetch and deepen the base branch incrementally until we find a merge base and until a certain limit. If we hit the limit, give up and ask the user to rebase the PR. 5. No changes. Merge in the freshly fetched base branch.
Author
Committer
Parents
Loading