summaryrefslogtreecommitdiff
path: root/lib/gall/repository.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gall/repository.lua')
-rw-r--r--lib/gall/repository.lua31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/gall/repository.lua b/lib/gall/repository.lua
index bd047b6..5c157d8 100644
--- a/lib/gall/repository.lua
+++ b/lib/gall/repository.lua
@@ -8,6 +8,7 @@
local ll = require "gall.ll"
local object = require "gall.object"
+local tree = require "gall.tree"
local chomp = ll.chomp
@@ -62,6 +63,7 @@ end
function repomethod:force_empty_tree()
self:_run(true, "hash-object", "-t", "tree", "-w", "/dev/null")
+ return self:get(tree.empty_sha)
end
function repomethod:hash_object(type, content, inject)
@@ -167,9 +169,10 @@ function repomethod:merge_base(sha_1, sha_2, get_all)
args = { "-a", sha_1, sha_2 }
end
args.repo = self.path
- local ok, out = ll.merge_base(args)
- if not ok then
- return nil, out
+ args.stderr = true
+ local ok, out, err = ll.merge_base(args)
+ if ok ~= 0 and ok ~= 1 then
+ return nil, (out or "") .. "\n" .. (err or "")
end
local ret = {}
for sha in out:gmatch("([a-f0-9]+)") do
@@ -187,8 +190,9 @@ function repomethod:rev_list(oldhead, newhead, firstonly)
table.insert(args, 1, "--first-parent")
end
args.repo = self.path
+ args.stderr = true
local ok, out = ll.rev_list(args)
- if not ok then
+ if ok ~= 0 then
return nil, out
end
local ret = {}
@@ -202,14 +206,21 @@ function repomethod:rev_list(oldhead, newhead, firstonly)
end
function repomethod:symbolic_ref(name, toref)
- if not toref then
- return ll.symbolic_ref { "-q", name,
- stderr=true, repo=self.path }
- else
- return ll.symbolic_ref { "-q", name, toref,
+ if toref then
+ local ok, ref, err = ll.symbolic_ref { "-q", name, toref,
stderr=true, repo=self.path }
+ if ok ~= 0 or err:find("Unable to create") then
+ return nil, "Could not set " .. tostring(name) .. " to " .. tostring(toref)
+ end
+ end
+ local ok, ref, err = ll.symbolic_ref { "-q", name, stderr=true, repo=self.path }
+ if ok == 0 then
+ return true, ref
+ end
+ if ok == 1 then
+ return false
end
- return false, "argh"
+ return nil, (ref or "") .. "\n" .. (err or "")
end
function repomethod:config(confname, value)