Skip to content

Commit ebb0b87

Browse files
Bryan C. Millsromaindoumenc
Bryan C. Mills
authored andcommitted
cmd/go: make vcstest repo scripts compatible with old Git versions
The scripts added in CL 421455 passed on the TryBots, but failed on a subset of the builders that have older 'git' binaries installed. Notably, the older versions of git do not support: - 'git branch -m' before the current branch has a commit - 'init.defaultBranch' in the '.gitconfig' file, and - 'git branch -c'. We address those by, respectively: - waiting to run 'git branch -m' until after the first commit - always running 'git branch -m' explicitly to set the branch name, and - using 'git checkout' instead of 'git branch -c' to set branch parents. Updates golang#27494. Change-Id: I42f012f5add8f31e41d077d752d8268aacbce8a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/445355 Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
1 parent 4cd610e commit ebb0b87

24 files changed

+41
-35
lines changed

src/cmd/go/testdata/vcstest/git/commit-after-tag.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2019-07-15T17:16:47-04:00
1211
git add go.mod main.go
1312
git commit -m 'all: add go.mod and main.go'
13+
git branch -m master
1414
git tag v1.0.0
1515

1616
at 2019-07-15T17:17:27-04:00

src/cmd/go/testdata/vcstest/git/empty-v2-without-v1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2019-10-07T14:15:32-04:00
1211
git add go.mod
1312
git commit -m 'add go.mod file without go source files'
13+
git branch -m master
1414
git tag v2.0.0
1515

1616
git log --oneline --decorate=short

src/cmd/go/testdata/vcstest/git/emptytest.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2018-07-03T22:35:49-04:00
1211
git add go.mod
1312
git commit -m 'initial'
13+
git branch -m master
1414

1515
git log --oneline
1616
cmp stdout .git-log

src/cmd/go/testdata/vcstest/git/gitrepo1.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2018-04-17T15:43:22-04:00
1211
unquote ''
1312
cp stdout README
1413
git add README
1514
git commit -a -m 'empty README'
15+
git branch -m master
1616
git tag v1.2.3
1717

1818
at 2018-04-17T15:45:48-04:00
19-
git branch -c v2
19+
git branch v2
2020
git checkout v2
2121
echo 'v2'
2222
cp stdout v2
2323
git add v2
2424
git commit -a -m 'v2'
2525
git tag v2.3
2626
git tag v2.0.1
27-
git branch -c v2.3.4
27+
git branch v2.3.4
2828

2929
at 2018-04-17T16:00:19-04:00
3030
echo 'intermediate'
@@ -40,7 +40,8 @@ git commit -a -m 'another'
4040
git tag v2.0.2
4141

4242
at 2018-04-17T16:16:52-04:00
43-
git branch -c master v3
43+
git checkout master
44+
git branch v3
4445
git checkout v3
4546
mkdir v3/sub/dir
4647
echo 'v3/sub/dir/file'

src/cmd/go/testdata/vcstest/git/hello.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME='Russ Cox'
66
env GIT_COMMITTER_EMAIL='[email protected]'
77

88
git init
9-
git branch -m master
109

1110
at 2017-09-21T21:05:58-04:00
1211
git add hello.go
1312
git commit -a -m 'hello'
13+
git branch -m master
1414

1515
git log --oneline --decorate=short
1616
cmp stdout .git-log

src/cmd/go/testdata/vcstest/git/insecurerepo.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2019-04-03T13:30:35-04:00
1211
git add go.mod
1312
git commit -m 'all: initialize module'
13+
git branch -m master
1414

1515
at 2019-09-04T14:39:48-04:00
1616
git add main.go

src/cmd/go/testdata/vcstest/git/mainonly.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2019-09-05T14:07:43-04:00
1211
git add main.go
1312
git commit -a -m 'add main.go'
13+
git branch -m master
1414

1515
git log --oneline --decorate=short
1616
cmp stdout .git-log

src/cmd/go/testdata/vcstest/git/modlegacy1-new.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2018-04-25T11:00:57-04:00
1211
git add go.mod new.go p1 p2
1312
git commit -m 'initial commit'
13+
git branch -m master
1414

1515
git log --oneline --decorate=short
1616
cmp stdout .git-log

src/cmd/go/testdata/vcstest/git/modlegacy1-old.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2018-04-25T10:59:24-04:00
1211
git add p1 p2
1312
git commit -m 'initial commit'
13+
git branch -m master
1414

1515
git log --oneline --decorate=short
1616
cmp stdout .git-log

src/cmd/go/testdata/vcstest/git/no-tags.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2019-07-15T17:20:47-04:00
1211
git add go.mod main.go
1312
git commit -m 'all: add go.mod and main.go'
13+
git branch -m master
1414

1515
git log --oneline --decorate=short
1616
cmp stdout .git-log

src/cmd/go/testdata/vcstest/git/odd-tags.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ git init
1010
at 2022-02-23T13:48:02-05:00
1111
git add README.txt
1212
git commit -m 'initial state'
13+
git branch -m main
1314
git tag 'v2.0.0+incompatible'
1415

1516
at 2022-02-23T13:48:35-05:00
@@ -19,7 +20,7 @@ git commit -m 'migrate to Go modules'
1920
git tag 'v0.1.0+build-metadata'
2021

2122
at 2022-02-23T14:41:55-05:00
22-
git branch -c v3-dev
23+
git branch v3-dev
2324
git checkout v3-dev
2425
cp v3/go.mod go.mod
2526
git commit go.mod -m 'update to /v3'

src/cmd/go/testdata/vcstest/git/prefixtagtests.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
88
at 2019-05-09T18:35:00-04:00
99

1010
git init
11-
git branch -m master
1211

1312
git add sub
1413
git commit -m 'create module sub'
14+
git branch -m master
1515

1616
echo 'v0.1.0'
1717
cp stdout status

src/cmd/go/testdata/vcstest/git/querytest.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2018-07-03T22:31:01-04:00
1211
git add go.mod
1312
git commit -a -m 'v1'
13+
git branch -m master
1414
git tag start
1515

16-
git branch -c v2
16+
git branch v2
1717

1818
at 2018-07-03T22:33:47-04:00
1919
echo 'before v0.0.0-pre1'

src/cmd/go/testdata/vcstest/git/retract-pseudo.txt

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ git init
1111

1212
git add go.mod p.go
1313
git commit -m 'create module retract-pseudo'
14+
git branch -m main
1415
git tag v1.0.0
1516

1617
git mv p.go q.go

src/cmd/go/testdata/vcstest/git/semver-branch.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ git init
1010
at 2022-02-02T14:15:21-05:00
1111
git add pkg go.mod
1212
git commit -a -m 'pkg: add empty package'
13+
git branch -m main
1314
git tag 'v0.1.0'
1415

1516
at 2022-02-02T14:19:44-05:00
16-
git branch -c 'v1.0.0'
17-
git branch -c 'v2.0.0'
17+
git branch 'v1.0.0'
18+
git branch 'v2.0.0'
1819
git checkout 'v1.0.0'
1920
cp v1/pkg/pkg.go pkg/pkg.go
2021
git commit -a -m 'pkg: start developing toward v1.0.0'
2122

2223
at 2022-02-03T10:53:13-05:00
23-
git branch -c 'v3.0.0-devel'
24+
git branch 'v3.0.0-devel'
2425
git checkout 'v3.0.0-devel'
2526
git checkout v0.1.0 pkg/pkg.go
2627
git commit -a -m 'pkg: remove panic'

src/cmd/go/testdata/vcstest/git/tagtests.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
88
at 2019-05-09T18:56:25-04:00
99

1010
git init
11-
git branch -m master
1211

1312
git add go.mod tagtests.go
1413
git commit -m 'create module tagtests'
15-
git branch -c b
14+
git branch -m master
15+
git branch b
1616

1717
git add v0.2.1
1818
git commit -m 'v0.2.1'

src/cmd/go/testdata/vcstest/git/v2repo.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2019-04-03T11:52:15-04:00
1211
env GIT_AUTHOR_DATE=2019-04-03T11:44:11-04:00
1312
git add go.mod
1413
git commit -m 'all: add go.mod'
14+
git branch -m master
1515
git tag 'v2.0.0'
1616

1717
git show-ref --tags --heads

src/cmd/go/testdata/vcstest/git/v2sub.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ git init
1010
at 2022-02-22T15:53:33-05:00
1111
git add v2sub.go v2
1212
git commit -m 'all: add package v2sub and v2sub/v2'
13+
git branch -m main
1314
git tag v2.0.0
1415

1516
at 2022-02-22T15:55:07-05:00

src/cmd/go/testdata/vcstest/git/v3pkg.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2019-07-15T14:01:24-04:00
1211
env GIT_AUTHOR_DATE=2019-07-15T13:59:34-04:00
1312
git add go.mod v3pkg.go
1413
git commit -a -m 'all: add go.mod with v3 path'
14+
git branch -m master
1515
git tag 'v3.0.0'
1616

1717
git show-ref --tags --heads

src/cmd/go/testdata/vcstest/git/vgotest1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
66
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
77

88
git init
9-
git branch -m master
109

1110
at 2018-02-19T17:21:09-05:00
1211
git add LICENSE README.md
1312
git commit -m 'initial commit'
13+
git branch -m master
1414

1515
git checkout --detach HEAD
1616

src/cmd/go/testdata/vcstest/hg/hgrepo1.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
99
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
1010

1111
git init
12-
git branch -m master
1312

1413
at 2018-04-17T15:43:22-04:00
1514
unquote ''
1615
cp stdout README
1716
git add README
1817
git commit -a -m 'empty README'
18+
git branch -m master
1919
git tag v1.2.3
2020

2121
at 2018-04-17T15:45:48-04:00
22-
git branch -c v2
22+
git branch v2
2323
git checkout v2
2424
echo 'v2'
2525
cp stdout v2
2626
git add v2
2727
git commit -a -m 'v2'
2828
git tag v2.3
2929
git tag v2.0.1
30-
git branch -c v2.3.4
30+
git branch v2.3.4
3131
git tag branch-v2.3.4
3232

3333
at 2018-04-17T16:00:19-04:00
@@ -45,7 +45,8 @@ git tag v2.0.2
4545
git tag branch-v2
4646

4747
at 2018-04-17T16:16:52-04:00
48-
git branch -c master v3
48+
git checkout master
49+
git branch v3
4950
git checkout v3
5051
mkdir v3/sub/dir
5152
echo 'v3/sub/dir/file'

src/cmd/go/testdata/vcstest/hg/vgotest1.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ env GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME
88
env GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL
99

1010
git init
11-
git branch -m master
1211

1312
# 0
1413
at 2018-02-19T17:21:09-05:00
1514
git add LICENSE README.md
1615
git commit -m 'initial commit'
16+
git branch -m master
1717

1818
# 1
19-
git branch -c mybranch
19+
git branch mybranch
2020
git checkout mybranch
2121

2222
at 2018-02-19T18:10:06-05:00
@@ -30,8 +30,8 @@ git tag v1.0.0
3030
git tag v2.0.0
3131
git tag mytag
3232

33-
git branch -c v1
34-
git branch -c v2
33+
git branch v1
34+
git branch v2
3535
git checkout v2
3636

3737
# 2

src/cmd/go/testdata/vcstest/svn/test1-svn-git.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ git init
2828
git config --add core.ignorecase true
2929
git config --add core.precomposeunicode true
3030

31-
git branch -m master
3231
git add README
3332
at 2017-09-22T11:39:03-04:00
3433
git commit -a -m 'README'
34+
git branch -m master
3535

3636
git rev-parse HEAD
3737
stdout '^7f800d2ac276dd7042ea0e8d7438527d236fd098$'

src/cmd/go/testdata/vcstest/svn/test2-svn-git.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ git init
2727
git config --add core.ignorecase true
2828
git config --add core.precomposeunicode true
2929

30-
git branch -m master
3130
git add README
3231
at 2017-09-22T11:39:03-04:00
3332
git commit -a -m 'README'
33+
git branch -m master
3434

3535
git rev-parse HEAD
3636
stdout '^7f800d2ac276dd7042ea0e8d7438527d236fd098$'

0 commit comments

Comments
 (0)