From 1ce6c82f35957d74ad3a08a7306dd14393135ef6 Mon Sep 17 00:00:00 2001 From: Anton Kaymakchi Date: Tue, 21 Jul 2020 11:05:29 +0300 Subject: speed up commit with all: true option --- worktree_commit.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/worktree_commit.go b/worktree_commit.go index 167f2e0..a9d0e04 100644 --- a/worktree_commit.go +++ b/worktree_commit.go @@ -58,17 +58,23 @@ func (w *Worktree) autoAddModifiedAndDeleted() error { return err } + idx, err := w.r.Storer.Index() + if err != nil { + return err + } + for path, fs := range s { if fs.Worktree != Modified && fs.Worktree != Deleted { continue } - if _, err := w.Add(path); err != nil { + if _, _, err := w.doAddFile(idx, s, path, nil); err != nil { return err } + } - return nil + return w.r.Storer.SetIndex(idx) } func (w *Worktree) updateHEAD(commit plumbing.Hash) error { -- cgit