Skip to content

Commit 12d0a28

Browse files
committed
cmd/go: do not try to understand git fetch --depth=1 errors
We used to try a git fetch --depth=1 of a specific hash and distinguish between an error meaning "that's not a hash I can give you directly" (in which case we fall through and pull the whole repo) and some other error like connection failure, bad ssh key (in which case we give up). We've had repeated problems trying to understand the error meanings so just stop doing that, and fall back to trying a full fetch on any error at all. If the error really was some kind of network or auth or i/o problem, then it will happen the second time and we can report it then. Fixes #26894. Change-Id: If1eaaddb87e8bfeff7a3894cce4ecef39802198c Reviewed-on: https://go-review.googlesource.com/128904 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent ccf04c6 commit 12d0a28

File tree

1 file changed

+3
-3
lines changed
  • src/cmd/go/internal/modfetch/codehost

1 file changed

+3
-3
lines changed

src/cmd/go/internal/modfetch/codehost/git.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,9 @@ func (r *gitRepo) stat(rev string) (*RevInfo, error) {
347347
if err == nil {
348348
return r.statLocal(rev, ref)
349349
}
350-
if !strings.Contains(err.Error(), "unadvertised object") && !strings.Contains(err.Error(), "no such remote ref") && !strings.Contains(err.Error(), "does not support shallow") {
351-
return nil, err
352-
}
350+
// Don't try to be smart about parsing the error.
351+
// It's too complex and varies too much by git version.
352+
// No matter what went wrong, fall back to a complete fetch.
353353
}
354354

355355
// Last resort.

0 commit comments

Comments
 (0)