Add a minimum of config

This lets us revive the reflog test by letting us set
core.logallrefupdates to true.
This commit is contained in:
Carlos Martín Nieto
2014-05-18 12:03:53 +02:00
parent 688c052f6d
commit 98b176c925
6 changed files with 62 additions and 3 deletions

View File

@@ -29,6 +29,10 @@ repository_get_workdir(_Handle) ->
repository_get_odb(_Val) ->
nif_error(?LINE).
-spec repository_get_config(term()) -> {ok, term()} | {error, term()}.
repository_get_config(_Val) ->
nif_error(?LINE).
-spec repository_init(iolist(), boolean()) -> term().
repository_init(_Path, _Bare) ->
nif_error(?LINE).
@@ -201,6 +205,10 @@ signature_new(_Name, _Email, _Time) ->
revparse_single(_Handle, _Str) ->
?NIF_FN.
-spec config_set_bool(term(), iolist(), boolean()) -> ok | {error, term()}.
config_set_bool(_Handle, _Name, _Val) ->
?NIF_FN.
nif_error(Line) ->
erlang:nif_error({nif_not_loaded,module,?MODULE,line,Line}).

View File

@@ -15,6 +15,7 @@
reference_dwim/2, handle/1, iterator/2]).
-export([reference_has_log/2]).
-export([reflog_read/2, reflog_delete/2]).
-export([config/1]).
-include("geef_records.hrl").
-record(state, {handle}).
@@ -79,6 +80,10 @@ references(Pid) ->
lookup_object(Pid, Oid) ->
gen_server:call(Pid, {lookup_object, Oid}).
%% @doc Get the repository's configuration
config(Pid) ->
gen_server:call(Pid, config).
%% @private
-spec iterator(pid(), iolist() | undefined) -> {ok, geef_ref:iterator()} | {error, term()}.
iterator(Pid, Regexp) ->
@@ -158,6 +163,11 @@ handle_call({reflog_delete, Name}, _From, State = #state{handle=Handle}) ->
Reply = geef_nif:reflog_delete(Handle, Name),
{reply, Reply, State};
handle_call(config, _From, State = #state{handle=Handle}) ->
Reply = handle_config(Handle),
{reply, Reply, State};
handle_call(stop, _From, State) ->
{stop, normal, ok, State};
handle_call(revwalk, _From, State = #state{handle=Handle}) ->
@@ -212,3 +222,11 @@ handle_revwalk(Handle) ->
Error ->
Error
end.
handle_config(Handle) ->
case geef_nif:repository_get_config(Handle) of
{ok, ConfigHandle} ->
geef_config:start_link(ConfigHandle);
Error ->
Error
end.