From 9a940eb7a4d7937d52560322c224d41463c21248 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sat, 11 Apr 2026 15:57:27 +0200 Subject: [PATCH] feat: add support for fuzzy finding into git submodules --- src/git.zig | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/git.zig b/src/git.zig index fa2d6abb..53427b0e 100644 --- a/src/git.zig +++ b/src/git.zig @@ -32,11 +32,18 @@ pub fn current_branch(context_: usize) Error!void { } pub fn workspace_files(context: usize) Error!void { - return git_line_output( - context, - @src().fn_name, - .{ "ls-files", "--cached", "--others", "--exclude-standard" }, - ); + 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" }, + ); } pub fn workspace_ignored_files(context: usize) Error!void { @@ -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());