Wrap git_revparse_single

This commit is contained in:
Carlos Martín Nieto
2013-09-05 15:11:32 +02:00
parent 72078cb099
commit 21464aeece
8 changed files with 101 additions and 2 deletions

View File

@@ -178,6 +178,10 @@ signature_new(_Name, _Email) ->
signature_new(_Name, _Email, _Time) ->
?NIF_FN.
-spec revparse_single(term(), iolist()) -> {ok, term(), atom(), geef_oid:oid()} | {error, term()}.
revparse_single(_Handle, _Str) ->
?NIF_FN.
nif_error(Line) ->
erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).

15
src/geef_revparse.erl Normal file
View File

@@ -0,0 +1,15 @@
-module(geef_revparse).
-include("geef_records.hrl").
-export([single/2]).
-spec single(pid(), iolist()) -> {ok, geef_obj:object()} | {error, term()}.
single(Repo, Str) ->
RepoHandle = geef_repo:handle(Repo),
case geef_nif:revparse_single(RepoHandle, Str) of
{ok, ObjHandle, Type, Id} ->
{ok, #geef_object{type=Type, id=Id, handle=ObjHandle}};
Error = {error, _} ->
Error
end.