Skip to content
Prev Previous commit
Next Next commit
fix
  • Loading branch information
SandrineP committed Jul 30, 2025
commit eef5385e22ef43459c468d9e5e87bca3fe657004
8 changes: 4 additions & 4 deletions src/subcommand/commit_subcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ commit_subcommand::commit_subcommand(const libgit2_object&, CLI::App& app)
{
auto *sub = app.add_subcommand("commit", "Record changes to the repository");

sub->add_option("message", m_message, "Commit message");
sub->add_option("commit_message", m_commit_message, "Commit message");
Comment thread
ianthomas23 marked this conversation as resolved.
Outdated

sub->add_flag("-m,--message", m_message_flag, "");
sub->add_flag("-m,--message", m_commit_message_flag, "");

sub->callback([this]() { this->run(); });
};
Expand All @@ -25,10 +25,10 @@ void commit_subcommand::run()
auto repo = repository_wrapper::init(directory, bare);
auto author_committer_signatures = signature_wrapper::get_default_signature_from_env(repo);
Comment thread
SandrineP marked this conversation as resolved.
Outdated

if (!m_message_flag)
if (!m_commit_message_flag)
{
throw std::runtime_error("Please provide a message using the -m flag.");
}

repo.create_commit(author_committer_signatures, m_message);
repo.create_commit(author_committer_signatures, m_commit_message);
}
4 changes: 2 additions & 2 deletions src/subcommand/commit_subcommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class commit_subcommand
void run();

private:
bool m_message_flag = true; // TODO: change to false when a message can be provided if the "-m" flag is not provided
std::string m_message;
bool m_commit_message_flag = true; // TODO: change to false when a message can be provided if the "-m" flag is not provided
std::string m_commit_message;
};
6 changes: 3 additions & 3 deletions src/wrapper/repository_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ void repository_wrapper::create_commit(const signature_wrapper::author_committer
const std::string& message)
{
const char* message_encoding = "UTF-8";
git_oid* commit_id;
git_oid commit_id;

const char* update_ref = "ḦEAD";
std::string update_ref = "ḦEAD";
auto parent = revparse_single(update_ref);
std::size_t parent_count = 0;
const git_commit* parents[1] = {nullptr};
Expand All @@ -132,7 +132,7 @@ void repository_wrapper::create_commit(const signature_wrapper::author_committer

throw_if_error(git_tree_lookup(&tree, *this, &tree_id));

throw_if_error(git_commit_create(commit_id, *this, update_ref, author_committer_signatures.first, author_committer_signatures.second,
throw_if_error(git_commit_create(&commit_id, *this, update_ref.c_str(), author_committer_signatures.first, author_committer_signatures.second,
message_encoding, message.c_str(), tree, parent_count, parents));

git_tree_free(tree);
Expand Down