8000 git: repository, add empty dir check to clone by CLBRITTON2 · Pull Request #1594 · go-git/go-git · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

git: repository, add empty dir check to clone #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CLBRITTON2
Copy link
Contributor

Proposed fix for #1156
Opening as a draft PR to see whether or not the cleanup logic is necessary.
I recycled the cleanup function into an empty dir check to prevent unwanted file deletions on error, but I think an early error would allow the cleanup logic to stay in place without interfering with a user's expectations if we want to keep it.

add check to return early from clone if the destination dir is not
empty, remove cleanup logic that removed files from errored clones - git
doesn't have this logic, update repository_test to test against new
error type
@CLBRITTON2 CLBRITTON2 force-pushed the v6-transport-clone branch from 58dc7c0 to 2db07ff Compare July 1, 2025 11:46
func PlainClone(path string, o *CloneOptions) (*Repository, error) {
return PlainCloneContext(context.Background(), path, o)
}

// PlainCloneContext a repository into the path with the given options, isBare
// defines if the new repository will be bare or normal. If the path is not empty
// ErrRepositoryAlreadyExists is returned.
// ErrCloneDirNotEmpty is returned.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep the existing error, as that more closely aligns with upstream.

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

Successfully merging this pull request may close these issues.

2 participants
0