From a786d8458d913236d2690b930bd72f897c0952d1 Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Fri, 22 May 2026 16:38:49 +0200 Subject: [PATCH] refactor(git): move the zero-sha check into core/util --- lua/git/core/util.lua | 6 ++++++ lua/git/object.lua | 8 +------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/git/core/util.lua b/lua/git/core/util.lua index ac18937..f29cfed 100644 --- a/lua/git/core/util.lua +++ b/lua/git/core/util.lua @@ -26,6 +26,12 @@ function M.is_uri(name) return name:match("^%a+://") ~= nil end +---@param sha string? +---@return boolean +function M.is_zero_sha(sha) + return sha == nil or sha:match("^0+$") ~= nil +end + ---@param buf integer ---@param name string function M.set_buf_name(buf, name) diff --git a/lua/git/object.lua b/lua/git/object.lua index d66f42e..8898832 100644 --- a/lua/git/object.lua +++ b/lua/git/object.lua @@ -65,12 +65,6 @@ local function diff_section() } end ----@param sha string? ----@return boolean -local function is_zero(sha) - return sha == nil or sha:match("^0+$") ~= nil -end - ---@param rev ow.Git.Revision ---@return boolean local function is_immutable_rev(rev) @@ -291,7 +285,7 @@ end ---@param path string ---@return integer? local function side_buf(r, blob, path) - if not blob or is_zero(blob) then + if not blob or util.is_zero_sha(blob) then return nil end local full, status = r:resolve_sha(blob)