diff --git a/src/subcommand/checkout_subcommand.cpp b/src/subcommand/checkout_subcommand.cpp index d0103d7..8ae8ebe 100644 --- a/src/subcommand/checkout_subcommand.cpp +++ b/src/subcommand/checkout_subcommand.cpp @@ -59,7 +59,7 @@ void checkout_subcommand::run() annotated_commit_wrapper checkout_subcommand::create_local_branch ( repository_wrapper& repo, - const std::string& target_name, + const std::string_view target_name, bool force ) { @@ -71,7 +71,7 @@ void checkout_subcommand::checkout_tree ( const repository_wrapper& repo, const annotated_commit_wrapper& target_annotated_commit, - const std::string& target_name, + const std::string_view target_name, const git_checkout_options& options ) { @@ -83,7 +83,7 @@ void checkout_subcommand::update_head ( repository_wrapper& repo, const annotated_commit_wrapper& target_annotated_commit, - const std::string& target_name + const std::string_view target_name ) { std::string_view annotated_ref = target_annotated_commit.reference_name(); diff --git a/src/subcommand/checkout_subcommand.hpp b/src/subcommand/checkout_subcommand.hpp index 2aab79e..e041174 100644 --- a/src/subcommand/checkout_subcommand.hpp +++ b/src/subcommand/checkout_subcommand.hpp @@ -20,7 +20,7 @@ class checkout_subcommand annotated_commit_wrapper create_local_branch ( repository_wrapper& repo, - const std::string& target_name, + const std::string_view target_name, bool force ); @@ -28,7 +28,7 @@ class checkout_subcommand ( const repository_wrapper& repo, const annotated_commit_wrapper& target_annotated_commit, - const std::string& target_name, + const std::string_view target_name, const git_checkout_options& options ); @@ -36,7 +36,7 @@ class checkout_subcommand ( repository_wrapper& repo, const annotated_commit_wrapper& target_annotated_commit, - const std::string& target_name + const std::string_view target_name ); std::string m_branch_name = {}; diff --git a/src/utils/git_exception.cpp b/src/utils/git_exception.cpp index 7be528f..18bca2c 100644 --- a/src/utils/git_exception.cpp +++ b/src/utils/git_exception.cpp @@ -11,7 +11,7 @@ void throw_if_error(int exit_code) } -git_exception::git_exception(const std::string& message, int error_code) +git_exception::git_exception(const std::string_view message, int error_code) : m_message(message), m_error_code(error_code) {} diff --git a/src/utils/git_exception.hpp b/src/utils/git_exception.hpp index 673949d..e9d67ec 100644 --- a/src/utils/git_exception.hpp +++ b/src/utils/git_exception.hpp @@ -8,13 +8,15 @@ void throw_if_error(int exit_code); class git_exception : public std::exception { public: - git_exception(const std::string& message, int error_code); + + git_exception(const std::string_view message, int error_code); int error_code() const; const char* what() const noexcept override; private: + std::string m_message; int m_error_code; };