Skip to content

Commit

Permalink
cmd/go/internal/modfetch: simplify a redundant condition
Browse files Browse the repository at this point in the history
In gitRepo.stat, we were checking ref != "" twice,
which confused me during casual reading because it made it seem like
the string could be empty when it actually never is.

For golang#56881.

Change-Id: Ib83303a149ea771399cb55fedd5dfa02ad411ff0
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/549855
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Bryan Mills <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
  • Loading branch information
Bryan C. Mills authored and gopherbot committed Dec 14, 2023
1 parent 6aa4826 commit 7c282ba
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/cmd/go/internal/modfetch/codehost/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,20 +530,20 @@ func (r *gitRepo) stat(ctx context.Context, rev string) (info *RevInfo, err erro
if r.fetchLevel <= fetchSome && ref != "" && hash != "" && !r.local {
r.fetchLevel = fetchSome
var refspec string
if ref != "" && ref != "HEAD" {
// If we do know the ref name, save the mapping locally
// so that (if it is a tag) it can show up in localTags
// on a future call. Also, some servers refuse to allow
// full hashes in ref specs, so prefer a ref name if known.
refspec = ref + ":" + ref
} else {
if ref == "HEAD" {
// Fetch the hash but give it a local name (refs/dummy),
// because that triggers the fetch behavior of creating any
// other known remote tags for the hash. We never use
// refs/dummy (it's not refs/tags/dummy) and it will be
// overwritten in the next command, and that's fine.
ref = hash
refspec = hash + ":refs/dummy"
} else {
// If we do know the ref name, save the mapping locally
// so that (if it is a tag) it can show up in localTags
// on a future call. Also, some servers refuse to allow
// full hashes in ref specs, so prefer a ref name if known.
refspec = ref + ":" + ref
}

release, err := base.AcquireNet()
Expand Down

0 comments on commit 7c282ba

Please sign in to comment.