golang/go

cmd/go: misleading `fatal:` log message when working in a git repo with no commits

Open

#52.263 aperta il 10 apr 2022

Vedi su GitHub
 (4 commenti) (2 reazioni) (0 assegnatari)Go (19.008 fork)batch import
GoCommandNeedsInvestigationhelp wanted

Metriche repository

Star
 (133.883 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

What version of Go are you using (go version)?

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

What did you do?

$ cd /tmp                                                                                                                                                                     [19/19]
$ git init x
Initialized empty Git repository in /tmp/x/.git/
$ cd x
$ go mod init x
go: creating new go.mod: module x
$ cat > main.go
// You can edit this code!
// Click here and start typing.
package main

import "fmt"

func main() {
        fmt.Println("Hello, 世界")
}
$ go build -v
# cd /tmp/x; git -c log.showsignature=false show -s --format=%H:%ct
fatal: your current branch 'master' does not have any commits yet
$

What did you expect to see?

A successful build.

What did you see instead?

Build itself failed.

Edit: The build does succeed even though the "fatal" message is printed.

Guida contributor