From 0355d03590c7199437c417bd5fe03a4373c55fec Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:28:26 +0000 Subject: [PATCH 1/2] Initial plan From ab502b46b1e4657cecaba28a0e4b7effdb94c8d3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 14:34:58 +0000 Subject: [PATCH 2/2] Fix overmatching for match-relative-path on explicit files Co-authored-by: dictcp <1752436+dictcp@users.noreply.github.com> --- lib/file.c | 8 +++++--- tests/test_options/test_match_relative_path.py | 13 +++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/file.c b/lib/file.c index 0f41aa5e..f81bbb4b 100644 --- a/lib/file.c +++ b/lib/file.c @@ -184,10 +184,12 @@ gint rm_file_relpaths_cmp(const RmFile *file_a, const RmFile *file_b) { gint diff = file_a->depth - file_b->depth; RETURN_IF_NONZERO(diff); - /* If both files have depth 0, we still need to distinguish them by at - * least their basenames; otherwise, they would always compare equal. */ + /* Depth 0 means both commandline inputs were explicit files. + * Compare full paths to avoid overmatching by basename only. */ if(file_a->depth == 0) { - return rm_file_basenames_cmp(file_a, file_b); + RM_DEFINE_PATH(file_a); + RM_DEFINE_PATH(file_b); + return g_ascii_strcasecmp(file_a_path, file_b_path); } RmNode *node_a = file_a->folder; RmNode *node_b = file_b->folder; diff --git a/tests/test_options/test_match_relative_path.py b/tests/test_options/test_match_relative_path.py index 7d02abcb..e28921dd 100644 --- a/tests/test_options/test_match_relative_path.py +++ b/tests/test_options/test_match_relative_path.py @@ -66,3 +66,16 @@ def test_negative_match_relative_path_explicit_files(usual_setup_usual_teardown) assert footer['total_files'] == 2 assert footer['total_lint_size'] == 0 assert footer['duplicates'] == 0 + + +def test_negative_match_relative_path_explicit_files_same_basename(usual_setup_usual_teardown): + path_a = create_file('xxx', 'base_a/file') + path_b = create_file('xxx', 'base_b/file') + + head, *data, footer = run_rmlint( + '--match-relative-path', path_a, path_b, + use_default_dir=False + ) + assert footer['total_files'] == 2 + assert footer['total_lint_size'] == 0 + assert footer['duplicates'] == 0