feat: add retain_symlinks option to enable writing files through links (default: true)

This commit is contained in:
CJ van den Berg 2026-02-06 14:04:53 +01:00
parent 3a718bf6f6
commit c0107e32e0
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 15 additions and 1 deletions

View file

@ -38,6 +38,8 @@ pub const BlameLine = struct {
author_stamp: usize,
};
pub var retain_symlinks: bool = true;
arena: std.heap.ArenaAllocator,
allocator: Allocator,
external_allocator: Allocator,
@ -1599,7 +1601,14 @@ pub const StoreToFileError = error{
WriteFailed,
};
pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
pub fn store_to_existing_file_const(self: *const Self, file_path_: []const u8) StoreToFileError!void {
var file_path = file_path_;
var link_buf: [std.fs.max_path_bytes]u8 = undefined;
if (retain_symlinks) blk: {
const link = cwd().readLink(file_path, &link_buf) catch break :blk;
file_path = link;
}
var atomic = blk: {
var write_buffer: [4096]u8 = undefined;
const stat = cwd().statFile(file_path) catch