diff options
Diffstat (limited to 'lib/gall/repository.lua')
-rw-r--r-- | lib/gall/repository.lua | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/gall/repository.lua b/lib/gall/repository.lua index af1ded4..bd047b6 100644 --- a/lib/gall/repository.lua +++ b/lib/gall/repository.lua @@ -136,12 +136,14 @@ function repomethod:normalise(sha) local ref, err = self:get_ref(sha) return ref, err else - local ok, out = self:_run_with_input(sha, chomp, "cat-file", "--batch-check") - if not ok then - error(out) + local ok, out, err = self:_run_with_input(sha, chomp, "cat-file", "--batch-check") + if ok ~= 0 then + error((out or "") .. "\n" .. (err or "")) + end + local fullsha = out:match("^("..string.rep("[0-9a-f]", 40)..")") + if fullsha then + return fullsha end - sha = out:match("^("..string.rep("[0-9a-f]", 40)..")") - return sha end return nil, "Unable to normalise " .. tostring(sha) end @@ -255,11 +257,8 @@ end local function _create(path, full) -- Cause a bare repository to be created (or a non-bare if full is true) - local args = { - stderr = true, - repo = path, - "-q" - } + local args = { stderr = true, repo = path, "-q" } + if not full then args[#args+1] = "--bare" end |