Skip to content

Commit 7a51e2d

Browse files
committed
path root fix
1 parent 7734793 commit 7a51e2d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/authorship/rebase_authorship.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ fn get_pathspecs_from_commits(
10361036
Ok(pathspecs.into_iter().collect())
10371037
}
10381038

1039-
fn filter_pathspecs_to_ai_touched_files(
1039+
pub fn filter_pathspecs_to_ai_touched_files(
10401040
repo: &Repository,
10411041
commit_shas: &[String],
10421042
pathspecs: &[String],

src/git/repository.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,16 @@ pub fn find_repository(global_args: &Vec<String>) -> Result<Repository, GitAiErr
17991799
)));
18001800
}
18011801

1802+
// Rewrite global_args if -C path doesn't match the actual workdir/
1803+
// So every git command can assume it's being run in repo root
1804+
let mut global_args = global_args.clone();
1805+
if global_args.len() == 2 && global_args[0] == "-C" {
1806+
let workdir_str = workdir.display().to_string();
1807+
if global_args[1] != workdir_str {
1808+
global_args[1] = workdir_str;
1809+
}
1810+
}
1811+
18021812
// Canonicalize workdir for reliable path comparisons (especially on Windows)
18031813
// On Windows, canonical paths use the \\?\ UNC prefix, which makes path.starts_with()
18041814
// comparisons work correctly. We store both regular and canonical versions.

0 commit comments

Comments
 (0)