golang/go
View on GitHubcmd/go: misleading `fatal:` log message when working in a git repo with no commits
Open
#52,263 opened on Apr 10, 2022
GoCommandNeedsInvestigationhelp wanted
Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
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.