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

Clone/commit of private repo corrupts every time #621

Open
bigUNO opened this issue Oct 16, 2017 · 2 comments
Open

Clone/commit of private repo corrupts every time #621

bigUNO opened this issue Oct 16, 2017 · 2 comments
Labels

Comments

@bigUNO
Copy link

bigUNO commented Oct 16, 2017

When trying to clone a private repo in bitbucket.org, the git directory gets corrupted. I can clone HelloWorld and make commits so the logic in that portion of the code works.

git commit -m "example go-git commit"
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x8 pc=0x728dc8]

goroutine 1 [running]:
gopkg.in/src-d/go-git%2ev4.(*buildTreeHelper).copyTreeToStorageRecursive(0xc0423eddb8, 0xc042414540, 0x21, 0x0, 0x0, 0x0, 0xc000000000, 0x44260e, 0x0)
        C:/Users/johnsol/go/src/gopkg.in/src-d/go-git.v4/worktree_commit.go:167 +0x78
gopkg.in/src-d/go-git%2ev4.(*buildTreeHelper).copyTreeToStorageRecursive(0xc0423eddb8, 0xc04210cee0, 0x17, 0xc042191540, 0x0, 0x0, 0xc000000000, 0x44260e, 0x0)
        C:/Users/johnsol/go/src/gopkg.in/src-d/go-git.v4/worktree_commit.go:175 +0x218
gopkg.in/src-d/go-git%2ev4.(*buildTreeHelper).copyTreeToStorageRecursive(0xc0423eddb8, 0xc04210ce20, 0x15, 0xc0421914a0, 0x0, 0x0, 0xc000000000, 0x0, 0x0)
        C:/Users/johnsol/go/src/gopkg.in/src-d/go-git.v4/worktree_commit.go:175 +0x218
gopkg.in/src-d/go-git%2ev4.(*buildTreeHelper).copyTreeToStorageRecursive(0xc0423eddb8, 0xc0421e2080, 0xd, 0xc0421913b0, 0x0, 0x0, 0x0, 0x0, 0x0)
        C:/Users/johnsol/go/src/gopkg.in/src-d/go-git.v4/worktree_commit.go:175 +0x218
gopkg.in/src-d/go-git%2ev4.(*buildTreeHelper).copyTreeToStorageRecursive(0xc0423eddb8, 0xc042182040, 0x4, 0xc042191360, 0x0, 0x0, 0x0, 0x0, 0x0)
        C:/Users/johnsol/go/src/gopkg.in/src-d/go-git.v4/worktree_commit.go:175 +0x218
gopkg.in/src-d/go-git%2ev4.(*buildTreeHelper).copyTreeToStorageRecursive(0xc0423eddb8, 0x0, 0x0, 0xc042191090, 0x0, 0x0, 0xc000000000, 0xc042204bd0, 0x9a5da0)
        C:/Users/johnsol/go/src/gopkg.in/src-d/go-git.v4/worktree_commit.go:175 +0x218
gopkg.in/src-d/go-git%2ev4.(*buildTreeHelper).BuildTree(0xc0423f1db8, 0xc042204bd0, 0x0, 0x0, 0x0, 0x7ffe0014, 0x1d346842c37a532)
        C:/Users/johnsol/go/src/gopkg.in/src-d/go-git.v4/worktree_commit.go:127 +0x254
gopkg.in/src-d/go-git%2ev4.(*Worktree).Commit(0xc0423dd3c0, 0x801da2, 0xe, 0xc0423edf38, 0x0, 0x0, 0x0, 0x0, 0x40f05c)
        C:/Users/johnsol/go/src/gopkg.in/src-d/go-git.v4/worktree_commit.go:39 +0x149
main.copyMachine()
        C:/Users/johnsol/go/src/duplicator/duplicator.go:89 +0x4e6
main.main()
        C:/Users/johnsol/go/src/duplicator/duplicator.go:102 +0x27
exit status 2

When inspecting the repo after the program runs I get the following message.

λ git status
fatal: internal error: ce_mode is 40000

I'm wondering if this has more to do with SSH/Pageant on Windows. (I'm not a native Windows user). Can someone get me pointed in the right direction?

@bigUNO
Copy link
Author

bigUNO commented Oct 16, 2017

Snippet of code

const (
	url = "reverseflapjack@bitbucket.org:foo/bar.git"
	//url       = "https://github.com/octocat/Hello-World.git"
	directory = "hw"
	testfile  = "test.txt"
)

func defaultSignature() *object.Signature {
	return &object.Signature{
		Name:  "reverseflapjack",
		Email: "flapmyjacks@example.com",
		When:  time.Now(),
	}
}
....

	// clone the given repository to the given directory
	Info("git clone %s %s --recursive", url, directory) // logging
	r, err := git.PlainClone(directory, false, &git.CloneOptions{
		URL: url,
	})
	CheckIfError(err)

	w, err := r.Worktree()
	CheckIfError(err)
	// ... we need a file to commit so let's create a new file inside of the
	// worktree of the project using the go standard library.
	Info("echo \"hellow world!\" > example-git-file")
	filename := filepath.Join(directory, "example-git-file")
	err = ioutil.WriteFile(filename, []byte("hello world!"), 0644)
	CheckIfError(err)

	// Adds the new file to the staging area.
	Info("git add example-git-file")
	_, err = w.Add("example-git-file")
	CheckIfError(err)

	// We can verify the current status of the worktree using the method Status.
	Info("git status --porcelain")
	status, err := w.Status()
	CheckIfError(err)

	fmt.Println(status)

	// Commits the current staging are to the repository, with the new file
	// just created. We should provide the object.Signature of Author of the
	// commit.
	Info("git commit -m \"example go-git commit\"")
	commit, err := w.Commit("Adds test file", &git.CommitOptions{Author: defaultSignature()})
	CheckIfError(err)

	// Prints the current HEAD to verify that all worked well.
	Info("git show -s")
	// makes the commit
	obj, err := r.CommitObject(commit)
	CheckIfError(err)

	fmt.Println(obj)

@mcuadros
Copy link
Contributor

Are you using windows? Looks like the generated .git/index is corrupted do to invalid mode. But I can replicate this on Linux.

@smola smola added the bug label Sep 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants