Skip to content
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

CleanOptions.Dir differs from -d flag in git clean #997

Open
msuozzo opened this issue Jan 12, 2024 · 0 comments
Open

CleanOptions.Dir differs from -d flag in git clean #997

msuozzo opened this issue Jan 12, 2024 · 0 comments

Comments

@msuozzo
Copy link

msuozzo commented Jan 12, 2024

Per the docs:

Normally, when no is specified, git clean will not recurse into untracked directories to avoid removing too much. Specify -d to have it recurse into such directories as well.

But from the current implementation:

	for _, fi := range files {
		// <snip>
		if fi.IsDir() {
			if !opts.Dir {
				continue
			}
			// <snip>
		}
		// <snip>
	}

This means when Dir is false, Worktree.Clean won't recurse into any subdirs, not just the "untracked" ones. I suspect this is because go-git appears to lack a notion of "untracked directory" as Status operates solely on files.

This is a pretty major disconnect in the semantics between git and go-git and I think should be considered an implementation bug.

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

No branches or pull requests

1 participant