Skip to content

Commit

Permalink
cmd/gomote: don't push .git even if it is a file
Browse files Browse the repository at this point in the history
In `git worktree` checkouts, rather than a .git directory, .git is a
file containing the path of the real repository. Presence of this file
will confuse git invoked by the go tool, so don't push it, just as we
don't push a .git directory.

For golang/go#58218.

Change-Id: I2d316d5672a87ba9cb7175a07e06e99a3392a85d
Reviewed-on: https://go-review.googlesource.com/c/build/+/480635
Reviewed-by: Carlos Amedee <amedee@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
  • Loading branch information
prattmic authored and gopherbot committed Mar 30, 2023
1 parent 579d681 commit bd9da1b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/gomote/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,21 @@ func doPush(ctx context.Context, name, goroot string, dryRun, detailedProgress b
if rel == "." {
return nil
}
if rel == ".git" {
if fi.IsDir() {
return filepath.SkipDir
}
return nil // .git is a file in `git worktree` checkouts.
}
if fi.IsDir() {
switch rel {
case ".git", "pkg", "bin":
case "pkg", "bin":
return filepath.SkipDir
}
}
inf := fileInfo{fi: fi}
if isGitIgnored(path) {
if fi.Mode().IsDir() {
if fi.IsDir() {
return filepath.SkipDir
}
return nil
Expand Down

0 comments on commit bd9da1b

Please sign in to comment.