don't recalculate the hash twice

This commit is contained in:
Squibid 2025-11-14 10:15:06 -05:00
parent 5e0e140b09
commit 73c2acd37e
Signed by: squibid
GPG key ID: BECE5684D3C4005D

5
XD.c
View file

@ -165,11 +165,12 @@ has_untracked(git_repository *repo)
git_status_options opts = GIT_STATUS_OPTIONS_INIT; git_status_options opts = GIT_STATUS_OPTIONS_INIT;
git_status_list *list = NULL; git_status_list *list = NULL;
repohash *storedhash; repohash *storedhash;
uint64_t newhash = generate_hash(repo);
int r = 0; int r = 0;
#ifdef GITHASH #ifdef GITHASH
if ((storedhash = read_hash(repo)) if ((storedhash = read_hash(repo))
&& storedhash->hash == generate_hash(repo)) { && storedhash->hash == newhash) {
r = storedhash->changes; r = storedhash->changes;
free(storedhash); free(storedhash);
return r; return r;
@ -192,7 +193,7 @@ has_untracked(git_repository *repo)
/* if any changes are found return 1 */ /* if any changes are found return 1 */
r = git_status_list_entrycount(list) > 0; r = git_status_list_entrycount(list) > 0;
#ifdef GITHASH #ifdef GITHASH
write_hash(repo, (repohash){ .hash = generate_hash(repo), .changes = r }); write_hash(repo, (repohash){ .hash = newhash, .changes = r });
#endif #endif
git_status_list_free(list); git_status_list_free(list);