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.

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

Closed
@tantalic

Description

@tantalic

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)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions