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

stage deleted files in doAddDirectory #242

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 30 additions & 1 deletion worktree_status.go
Expand Up @@ -283,10 +283,16 @@ func (w *Worktree) doAddDirectory(idx *index.Index, s Status, directory string,
}
}

var entries []*index.Entry
entries, err = idx.Glob(directory + "/*")
if err != nil {
return false, err
}

var a bool
for _, file := range files {
name := path.Join(directory, file.Name())

var a bool
if file.IsDir() {
if file.Name() == GitDirName {
// ignore special git directory
Expand All @@ -306,6 +312,29 @@ func (w *Worktree) doAddDirectory(idx *index.Index, s Status, directory string,
}
}

for _, e := range entries {
var foundMatch bool
for _, file := range files {
if file.IsDir() {
continue
}

if e.Name == path.Join(directory, file.Name()) {
foundMatch = true
break
}
}

if foundMatch {
continue
}

a, _, err = w.doAddFile(idx, s, e.Name, ignorePattern)
if !added && a {
added = true
}
}

return
}

Expand Down