feat: add support for fuzzy finding into git submodules

This commit is contained in:
CJ van den Berg 2026-04-11 15:57:27 +02:00
parent fb135afe16
commit 9a940eb7a4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -32,7 +32,14 @@ pub fn current_branch(context_: usize) Error!void {
}
pub fn workspace_files(context: usize) Error!void {
return git_line_output(
return if (is_file(".gitmodules"))
git_line_output(
context,
@src().fn_name,
.{ "ls-files", "--cached", "--exclude-standard", "--recurse-submodules" },
)
else
git_line_output(
context,
@src().fn_name,
.{ "ls-files", "--cached", "--others", "--exclude-standard" },
@ -411,4 +418,12 @@ pub fn blame(context_: usize, file_path: []const u8) !void {
}.result, exit_null(tag));
}
fn is_file(rel_path: []const u8) bool {
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
const abs_path = std.fs.cwd().realpath(rel_path, &path_buf) catch return false;
var file = std.fs.openFileAbsolute(abs_path, .{ .mode = .read_only }) catch return false;
defer file.close();
return true;
}
const module_name = @typeName(@This());