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

PlainOpen on non-git directory creates git directory structure #408

Closed
tantalic opened this issue May 31, 2017 · 3 comments
Closed

PlainOpen on non-git directory creates git directory structure #408

tantalic opened this issue May 31, 2017 · 3 comments
Assignees
Labels

Comments

@tantalic
Copy link

Calling PlainOpen on a directory path that is not a git repository has a side effect of creating the git directory structure within the directory:

├── objects
│   ├── info
│   └── pack
└── refs
    ├── heads
    └── tags

I would expect the following test to pass, but it fails as follows:

func (s *RepositorySuite) TestPlainOpenEmptyDir(c *C) {
	dir, err := ioutil.TempDir("", "plain-open-empty-dir")
	c.Assert(err, IsNil)
	defer os.RemoveAll(dir)

	r, err := PlainOpen(dir)
	c.Assert(err, Equals, ErrRepositoryNotExists)
	c.Assert(r, IsNil)

	entries, err := ioutil.ReadDir(dir)
	c.Assert(err, IsNil)
	c.Assert(len(entries), Equals, 0)
}

However, it currently fails:

FAIL: repository_test.go:368: RepositorySuite.TestPlainOpenEmptyDir

repository_test.go:379:
    c.Assert(len(entries), Equals, 0)
... obtained int = 2
... expected int = 0

OOPS: 139 passed, 1 FAILED
--- FAIL: Test (33.04s)
@tantalic
Copy link
Author

Possibly related to #387

@smola
Copy link
Collaborator

smola commented May 31, 2017

@tantalic Thank you for reporting this and getting a proper test case!

I have created a PR fixing this issue: #409

@smola smola closed this as completed in 88f88ea Jun 5, 2017
smola added a commit that referenced this issue Jun 5, 2017
storage/filesystem: call initialization explicitly, fixes #408
@tantalic
Copy link
Author

tantalic commented Jun 9, 2017

@smola thanks for getting this resolved. Now that it's in master what is the procedure for getting it into the gopkg.in/src-d/go-git.v4 branch?

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants