Skip to content

Commit 75b729c

Browse files
author
Stephan Dilly
committed
improve stage_add performance by simplification
1 parent 90f29a0 commit 75b729c

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

asyncgit/src/sync/utils.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! sync git api (various methods)
22
3-
use git2::{IndexAddOption, Repository, RepositoryOpenFlags};
3+
use git2::{Repository, RepositoryOpenFlags};
44
use scopetime::scope_time;
55
use std::path::Path;
66

@@ -70,19 +70,7 @@ pub fn stage_add(repo_path: &str, path: &Path) -> bool {
7070

7171
let mut index = repo.index().unwrap();
7272

73-
let cb = &mut |p: &Path, _matched_spec: &[u8]| -> i32 {
74-
if p == path {
75-
0
76-
} else {
77-
1
78-
}
79-
};
80-
let cb = Some(cb as &mut git2::IndexMatchedPath);
81-
82-
let flags = IndexAddOption::DISABLE_PATHSPEC_MATCH
83-
| IndexAddOption::CHECK_PATHSPEC;
84-
85-
if index.add_all(path, flags, cb).is_ok() {
73+
if index.add_path(path).is_ok() {
8674
index.write().unwrap();
8775
return true;
8876
}

0 commit comments

Comments
 (0)