Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

in Windows, pulling from repo that has symlinks results in ErrUnstagedChanges #801

Open
808codist opened this issue Apr 4, 2018 · 2 comments

Comments

@808codist
Copy link

Steps to reproduce:

  1. Create a repo with symlinks on github (or other git repo host)
  2. On Windows machine, use _examples/clone/main.go to clone the repo
    • I ran as Administrator
    • I modified source to set CloneOptions.Auth
  3. Without using clone from previous step, push a new commit to the repo
  4. Back on Windows machine, use _examples/pull/main.go to pull just-pushed commit
    • I ran as Administrator
    • I modified source to set PullOptions.Auth
  5. Notice worktree contains unstaged changes error message

Seems to be Windows-specific, since I could not reproduce on Linux (CentOS), with same modified source.

details:

  • go version go1.10 windows/amd64
  • Windows 10 Version 1709 (OS Build 16299.309)
  • gopkg.in/src-d/go-git.v4
@808codist
Copy link
Author

808codist commented Apr 4, 2018

Better way to reproduce the bug, go run this code on a Windows box:

package main

import (
	"io/ioutil"
	"os"

	"golang.org/x/crypto/ssh"
	"gopkg.in/src-d/go-git.v4"
	"gopkg.in/src-d/go-git.v4/_examples"
	"gopkg.in/src-d/go-git.v4/plumbing/transport"
	go_git_ssh "gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
	"fmt"
)

const privateSshKeyFile = "C:/full/path/private/key/file"
const url = "git@github.com:808codist/go-git-symlink-test.git"

func main() {
	examples.CheckArgs("<directory>")
	directory := os.Args[1]

	r, err := git.PlainClone(directory, false, &git.CloneOptions{
		URL:               url,
		RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
		Auth:              getAuth(),
	})
	examples.CheckIfError(err)

	w, err := r.Worktree()
	examples.CheckIfError(err)

	status, err := w.Status()
	examples.CheckIfError(err)
	if len(status) > 0 {
		fmt.Println("Changes exist!:\n", status)
	} else {
		fmt.Println("No changes - yay!!!!!")
	}
}

func getAuth() transport.AuthMethod {
	var auth transport.AuthMethod
	sshKey, err := ioutil.ReadFile(privateSshKeyFile)
	examples.CheckIfError(err)
	signer, err := ssh.ParsePrivateKey([]byte(sshKey))
	examples.CheckIfError(err)
	auth = &go_git_ssh.PublicKeys{User: "git", Signer: signer}
	return auth
}

@808codist
Copy link
Author

Note that git status on the local clone returns "nothing to commit, working tree clean"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants