Skip to content

Commit 1299733

Browse files
committed
cmd/go: let list -m -json include an Origin
MergeOrigin will work when m1 or m2 both not nil. But if one of it is nil. It should return other one which is not nil. Fixes #67363
1 parent 3776465 commit 1299733

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/cmd/go/internal/modload/build.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ func addUpdate(ctx context.Context, m *modinfo.ModulePublic) {
166166
// If the two origins conflict including if either is nil,
167167
// mergeOrigin returns nil.
168168
func mergeOrigin(m1, m2 *codehost.Origin) *codehost.Origin {
169-
if m1 == nil || m2 == nil {
170-
return nil
169+
if m1 == nil {
170+
return m2
171+
}
172+
if m2 == nil {
173+
return m1
171174
}
172175

173176
if m2.VCS != m1.VCS ||

0 commit comments

Comments
 (0)