Skip to content

Commit

Permalink
Completed status detection code
Browse files Browse the repository at this point in the history
  • Loading branch information
tfpf committed Oct 28, 2024
1 parent 9b024ce commit d34b6e4
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion custom-prompt/custom-prompt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ int GitRepository::compare_tag_update_description(char const* name, C::git_oid*
tag_name = tag_name.substr(10);
}
self->description += " 󰓼 " + tag_name;
// Found a match. Stop iterating.
return 1;
}

Expand All @@ -337,7 +338,28 @@ int GitRepository::compare_tag_update_description(char const* name, C::git_oid*
int GitRepository::update_dirty_staged_untracked(char const* path, unsigned status_flags, void* self_)
{
GitRepository* self = static_cast<GitRepository*>(self_);
LOG_DEBUG("path=%s", path);
if (status_flags
& (C::GIT_STATUS_WT_DELETED | C::GIT_STATUS_WT_MODIFIED | C::GIT_STATUS_WT_RENAMED
| C::GIT_STATUS_WT_TYPECHANGE))
{
self->dirty = true;
}
else if (status_flags
& (C::GIT_STATUS_INDEX_DELETED | C::GIT_STATUS_INDEX_MODIFIED | C::GIT_STATUS_INDEX_NEW
| C::GIT_STATUS_INDEX_RENAMED | C::GIT_STATUS_INDEX_TYPECHANGE))
{
self->staged = true;
}
else if (status_flags & C::GIT_STATUS_WT_NEW)
{
self->untracked = true;
}
if (self->dirty && self->staged && self->untracked)
{
// Found all possible statuses. No use searching further. Stop
// iterating.
return 1;
}
return 0;
}

Expand Down

0 comments on commit d34b6e4

Please sign in to comment.