Skip to content

Commit

Permalink
Changed git_info from char const* to string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
tfpf committed Aug 20, 2024
1 parent 07b02cf commit aa32ef8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions custom-prompt/custom-prompt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ void report_command_status(std::string_view& last_command, int exit_code, long l
* @param git_info Description of the status of the current Git repository.
* @param shlvl Current shell level.
*****************************************************************************/
void display_primary_prompt(char const* git_info, int shlvl)
void display_primary_prompt(std::string_view const& git_info, int shlvl)
{
LOG_DEBUG("Current Git repository state is '%s'.", git_info);
LOG_DEBUG("Current Git repository state is '%s'.", git_info.data());
char const* venv = std::getenv("VIRTUAL_ENV_PROMPT");
LOG_DEBUG("Current Python virtual environment is '%s'.", venv);
std::cout << "\n┌[" BB_GREEN USER RESET " " BBI_YELLOW HOST_ICON " " HOST RESET " " BB_CYAN DIRECTORY RESET "]";
if (git_info[0] != '\0')
if (!git_info.empty())
{
std::cout << "" << git_info;
}
Expand Down Expand Up @@ -384,7 +384,7 @@ int main_internal(int const argc, char const* argv[])
std::size_t columns = std::stoull(argv[5]);
report_command_status(last_command, exit_code, delay, prev_active_wid, columns);

char const* git_info = argv[6];
std::string_view git_info(argv[6]);
int shlvl = std::stoi(argv[7]);
display_primary_prompt(git_info, shlvl);

Expand Down

0 comments on commit aa32ef8

Please sign in to comment.