don't recalculate the hash twice
This commit is contained in:
parent
5e0e140b09
commit
73c2acd37e
1 changed files with 3 additions and 2 deletions
5
XD.c
5
XD.c
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue