diff options
author | Squibid <me@zacharyscheiman.com> | 2024-12-21 21:36:54 -0500 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2024-12-21 21:36:54 -0500 |
commit | 4af00678ca4aac6f26f61cae89718450654ec189 (patch) | |
tree | 3c413b55b69a2a2aff18e4380eb558b5b5698553 /XD.c | |
parent | cab498199e1faa29416aa5b13a0294a67f19fbf8 (diff) | |
download | XD-4af00678ca4aac6f26f61cae89718450654ec189.tar.gz XD-4af00678ca4aac6f26f61cae89718450654ec189.tar.bz2 XD-4af00678ca4aac6f26f61cae89718450654ec189.zip |
optimize...
make the stage check faster by filtering the status list
Diffstat (limited to 'XD.c')
-rw-r--r-- | XD.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -188,9 +188,13 @@ has_staged(git_repository *repo) { git_status_entry entry; git_status_list *list = NULL; + git_status_options opts = GIT_STATUS_OPTIONS_INIT; int i, c, r = 0; - if (git_status_list_new(&list, repo, NULL) < 0) { + opts.flags = GIT_STATUS_INDEX_NEW; + opts.show = GIT_STATUS_SHOW_INDEX_ONLY; + + if (git_status_list_new(&list, repo, &opts) < 0) { L("Error checking for staged changes: %s", git_error_last()->message); return 0; } @@ -200,9 +204,9 @@ has_staged(git_repository *repo) for (i = 0; i < c; i++) { entry = *git_status_byindex(list, i); - if (entry.status & GIT_STATUS_INDEX_NEW - || entry.status & GIT_STATUS_INDEX_DELETED - || entry.status & GIT_STATUS_INDEX_MODIFIED) { + if (entry.status & (GIT_STATUS_INDEX_NEW + | GIT_STATUS_INDEX_DELETED + | GIT_STATUS_INDEX_MODIFIED)) { r = 1; break; } |