Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Applied review comments
  • Loading branch information
JohanMabille committed Feb 10, 2026
commit 91d80a59b79bf564bff5548070f91a93c0884bac
2 changes: 1 addition & 1 deletion src/subcommand/mv_subcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void mv_subcommand::run()
if (exists && !m_force)
{
// TODO: replace magic number with enum when diff command is merged
throw git_exception("destination already exists", 128);
throw git_exception("destination already exists", git2cpp_error_code::FILESYSTEM_ERROR);
}

std::error_code ec;
Expand Down
6 changes: 3 additions & 3 deletions src/subcommand/rm_subcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void rm_subcommand::run()
if (!fs::exists(path))
{
std::string msg = "fatal: pathspec '" + path + "' did not math any file";
throw git_exception(msg, 128);
throw git_exception(msg, git2cpp_error_code::FILESYSTEM_ERROR);
}
if (fs::is_directory(path))
{
Expand All @@ -43,7 +43,7 @@ void rm_subcommand::run()
if (!repo.does_track(path))
{
std::string msg = "fatal: pathsspec '" + path + "'is not tracked";
throw git_exception(msg, 128);
throw git_exception(msg, git2cpp_error_code::FILESYSTEM_ERROR);
}
files.push_back(path);
}
Expand All @@ -52,7 +52,7 @@ void rm_subcommand::run()
if (!directories.empty() && !m_recursive)
{
std::string msg = "fatal: not removing '" + directories.front() + "' recursively without -r";
throw git_exception(msg, 128);
throw git_exception(msg, git2cpp_error_code::FILESYSTEM_ERROR);
}

index.remove_entries(files);
Expand Down
1 change: 1 addition & 0 deletions src/utils/git_exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
enum class git2cpp_error_code
{
GENERIC_ERROR = -1,
FILESYSTEM_ERROR = 128,
BAD_ARGUMENT = 129,
};

Expand Down
4 changes: 3 additions & 1 deletion test/test_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ def test_rm_staged_file(xtl_clone, git2cpp_path, tmp_path):
status_cmd = [git2cpp_path, "status", "--long"]
p_status = subprocess.run(status_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_status.returncode == 0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't check that nothing was staged.

assert "Changes to be committed" not in p_status.stdout
assert "staged.txt" not in p_status.stdout


def test_rm_file_in_subdirectory(xtl_clone, commit_env_config, git2cpp_path, tmp_path):
Expand Down Expand Up @@ -356,4 +358,4 @@ def test_rm_mixed_files_and_directory(xtl_clone, commit_env_config, git2cpp_path
p_status = subprocess.run(status_cmd, capture_output=True, cwd=xtl_path, text=True)
assert p_status.returncode == 0
assert "Changes to be committed" in p_status.stdout
assert "deleted" in p_status.stdout
assert "deleted" in p_status.stdout