Skip to content

Conversation

@crazy-max
Copy link
Member

@crazy-max crazy-max commented Dec 15, 2022

closes #1470

Windows drives in WSL version 2 uses the 9P protocol which the WSL instance connects to. When running git operations on a 9p fs using git from /usr/bin/git, it can be quite slow:

$ cd /mnt/c/github.com/moby/moby
$ time git -c log.showSignature=false status --porcelain --ignored >/dev/null
real    1m5.620s
user    0m0.387s
sys     0m59.010s

But using git.exe is quite fast:

$ cd /mnt/c/github.com/moby/moby
$ time git.exe -c log.showSignature=false status --porcelain --ignored >/dev/null
real    0m0.147s
user    0m0.003s
sys     0m0.009s

This change will detect if git operations occur on WSL and on a 9p fs and in this case lookup for git.exe, otherwise fallback to git.

Signed-off-by: CrazyMax crazy-max@users.noreply.github.com

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
build/git.go Outdated
if err != nil {
logrus.Warnf("Failed to initialize git: %v", err)
if st, err := os.Stat(path.Join(wd, ".git")); err == nil && st.IsDir() {
return nil, errors.New("git not found in PATH, but .git directory exists")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a warning, not a failing error.

WARN: No git was found in the system. Current commit information was not captured by the build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice that warning is on caller side. But update the message.

build/git.go Outdated
if !gitc.IsInsideWorkTree() {
logrus.Warnf("Unable to determine git information")
return
return nil, errors.New("not inside a git repository")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an error. If no git repo then just continue.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants