-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go/internal/vcs: use git log to avoid unnecessary objects
"git show" by default shows the diff from the previous commit. "-s" suppress all output from the diff machinery. But it will still try to fetch the relevant objects, which may be unavailable if the repository is a partial clone. Use "git log" instead, which only needs the commit object. Fixes golang#65339
- Loading branch information
Showing
2 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Regression test for https://go.dev/issue/65339. | ||
# Unnecessary git tree object required | ||
|
||
[short] skip 'constructs a local git repo' | ||
[!git] skip | ||
|
||
env GIT_AUTHOR_NAME='Go Gopher' | ||
env GIT_AUTHOR_EMAIL='gopher@golang.org' | ||
env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME | ||
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL | ||
|
||
# Create 2 commit | ||
env GIT_COMMITTER_DATE 2024-01-30T10:52:00+08:00 | ||
env GIT_AUTHOR_DATE 2024-01-30T10:52:00+08:00 | ||
|
||
cd $WORK/repo | ||
exec git init | ||
exec git add go.mod main.go | ||
exec git commit -m 'initial commit' | ||
|
||
env GIT_COMMITTER_DATE 2024-01-30T10:53:00+08:00 | ||
env GIT_AUTHOR_DATE 2024-01-30T10:53:00+08:00 | ||
exec git add extra.go | ||
exec git commit -m 'add extra.go' | ||
|
||
# Assume the tree object from initial commit is not available (e.g. partial clone) | ||
exec git log --pretty=%T | ||
cmp stdout $WORK/.git-trees | ||
|
||
rm .git/objects/66/400c89b45cc96da36d232844dbf9ea5daa6bcf | ||
|
||
# Build the module, which should succeed | ||
go build -v -buildvcs=true | ||
|
||
-- $WORK/repo/go.mod -- | ||
module github.com/golang/issue65339 | ||
|
||
go 1.20 | ||
-- $WORK/repo/main.go -- | ||
package main | ||
|
||
func main() { | ||
println("hello, world") | ||
} | ||
-- $WORK/repo/extra.go -- | ||
package main | ||
-- $WORK/.git-trees -- | ||
ac724c6e5e3f86815e057ff58a639cab613abf28 | ||
66400c89b45cc96da36d232844dbf9ea5daa6bcf |