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

Worktree Add function adds ".git" directory #814

@tkrisko

Description

@tkrisko

Hi There

The below code cause ".git" is added to the index.

func TestAdd(t *testing.T) { repoPath, err := ioutil.TempDir("", "TestAdd") if err != nil {	t.Fatal(err) } repo, err := git.PlainInit(repoPath, false) if err != nil {	t.Fatal(err) } w, err := repo.Worktree() if err != nil {	t.Fatal(err) } _, err = w.Add(".") if err != nil {	t.Fatal(err) } w.Commit("Test Add", &git.CommitOptions{Author: getSignature()}) iter, err := repo.Log(&git.LogOptions{}) err = iter.ForEach(func(c *object.Commit) error {	files, err := c.Files()	if err != nil {	t.Fatal(err)	}	err = files.ForEach(func(f *object.File) error {	t.Log(f.Name())	return nil	})	return nil }) } func getSignature() *object.Signature { when := time.Now() sig := &object.Signature{	Name: "foo",	Email: "foo@foo.foo",	When: when, } return sig } 

I would assume the Add will ignore ".git" directory. However the output looks like:

=== RUN TestAdd --- PASS: TestAdd (0.01s)	bogus_test.go:38: .git/HEAD	bogus_test.go:38: .git/objects/cb/089cd89a7d7686d284d8761201649346b5aa1c PASS ok	github.kohls.com/EnterpriseDevOps/go-git2consul/repository	0.027s 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions