-- @param remote Name of the "remote" repository for listing refs.
-- Network connection! Use generic_git.NO_REMOTE for
-- local refs (including remotes/...)
+-- @param ref if given request only the matching ref
-- @return Error object on failure, otherwise nil
-- @return Table containing tables of "id", "ref" pairs, or false on error.
-function generic_git.list_refs(git_dir, remote)
+function generic_git.list_refs(git_dir, remote, ref)
assertIsStringN(git_dir)
assert(remote == generic_git.NO_REMOTE or assertIsStringN(remote))
table.insert(argv, "show-ref")
table.insert(argv, "--head") -- ls-remote does this by default
end
+ if ref then
+ table.insert(argv, ref)
+ end
rc, re, out = generic_git.git(argv)
if not rc then
assertIsStringN(ref)
local rc, re, t
- rc, re, t = generic_git.list_refs(git_dir, remote)
+ rc, re, t = generic_git.list_refs(git_dir, remote, ref)
if not rc then
return false, re
end
local rc, re, t
- rc, re, t = generic_git.list_refs(git_dir, remote)
+ rc, re, t = generic_git.list_refs(git_dir, remote, nil)
if not rc then
return false, re
end