Merge branch 'revparse'

This commit is contained in:
Carlos Martín Nieto
2013-10-16 13:58:20 +02:00
9 changed files with 103 additions and 8 deletions

View File

@@ -182,6 +182,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.