anchor.diff:  
   get_branches(_State, Package) ->
       GetBranches = format("GIT_DIR=~s git branch", [Package]),
  -    case os:cmd(GetBranches) of
  -        "fatal:" ++ Error ->
  -            {error, Error};
  -        Result ->
  -            {ok, [string:strip(Branch, both, $ ) || Branch <- string:tokens(Result, "\n")]}
  +    case command(GetBranches) of
  +        {error, _}=Error -> Error;
  +        {ok, <<>>} -> {ok, []};
  +        {ok, Result} -> 
  +            {ok, [Branch || Branch <- binary:split(Result, <<"\n">>, [global]), Branch /= <<>>]}
       end.
   
   
   get_diff(_State, Package, _Branch, Revno, NewRevno) when Revno == none; Revno == error ->
  -    Revisions = os:cmd(format("GIT_DIR=~s git rev-list --all", [Package])),
  +    Revisions = command(format("GIT_DIR=~s git rev-list --all", [Package])),
       First = lists:last(string:tokens(Revisions, "\n")),
       DiffCmd = format("GIT_DIR=~s git diff ~s ~s", [Package, First, NewRevno]),
  -    case os:cmd(DiffCmd) of
  -        "error" ++ _ = Error -> {error, Error};
  -        Result ->
  -            Len = length(Result),
  +    case command(DiffCmd) of
  +        {error, _} = Error -> Error; 
  +        {ok, Diff} ->
  +            Size = size(Diff),
               if
  -                Len > 10240 -> {ok, list_to_binary(string:sub_string(Result, 1, 10240))};
  -                true -> {ok, list_to_binary(Result)}
  +                Size > 10240 -> {ok, binary:part(Diff, 0, 10239)};
  +                true -> {ok, Diff}
               end
       end;
   
   
   get_diff(_State, Package, _Branch, OldRevno, NewRevno) ->
       DiffCmd = format("GIT_DIR=~s git diff ~s ~s", [Package, OldRevno, NewRevno]),
  -    case os:cmd(DiffCmd) of 
  -        "error" ++ _ = Error -> {error, Error};
  -        Diff ->
  -            Len = length(Diff),
  +    case command(DiffCmd) of 
  +        {error, _} = Error -> Error;
  +        {ok, Diff} ->
  +            Size = size(Diff),
               if
  -                Len > 10240 -> {ok, list_to_binary(string:sub_string(Diff, 1, 10240))};
  -                true -> {ok, list_to_binary(Diff)}
  +                Size > 10240 -> {ok, binary:part(Diff, 0, 10239)};
  +                true -> {ok, Diff}
               end
       end.
   
   
   get_changelog(_State, Package, _Branch, Revno, NewRevno) when Revno == none; Revno == error ->
       LogCmd = format("GIT_DIR=~s git log ~s", [Package, NewRevno]),
  -    case os:cmd(LogCmd) of
  -        Log when Log > 10240 -> {ok, list_to_binary(string:sub_string(Log, 1, 10240))};
  -        Log -> {ok, list_to_binary(Log)}
  +    case command(LogCmd) of
  +        {error, _} = Error -> Error;
  +        {ok, Log} ->
  +            Size = size(Log),
  +            if
  +                Size > 10240 -> {ok, binary:part(Log, 0, 10239)};
  +                true -> {ok, Log}
  +            end
       end;
   
   get_changelog(_State, Package, _Branch, OldRevno, NewRevno) ->
       LogCmd = format("GIT_DIR=~s git log ~s..~s", [Package, OldRevno, NewRevno]),
  -    case os:cmd(LogCmd) of
  -        Log when Log > 10240 -> {ok, list_to_binary(string:sub_string(Log, 1, 10240))};
  -        Log -> {ok, list_to_binary(Log)}
  +    case command(LogCmd) of
  +        {error, _} = Error -> Error;
  +        {ok, Log} ->
  +            Size = size(Log),
  +            if
  +                Size > 10240 -> {ok, binary:part(Log, 0, 10239)};
  +                true -> {ok, Log}
  +            end
       end.
   
   
   get_tag(_State, Package, _Branch, NewRevno) ->
       TagCmd = format("GIT_DIR=~s git describe --exact-match ~s 2> /dev/null", [Package, NewRevno]),
  -    case os:cmd(TagCmd) of
  +    case command(TagCmd) of
           [] -> {ok, none};
           Tag -> {ok, string:strip(Tag, right, $\n)}
       end.
  
positive.code: 
  is_branch(_State, Package, Branch) ->
      IsBranch = format("GIT_DIR=~s git rev-parse heads/~s 1> /dev/null", [Package, Branch]),
      case os:cmd(IsBranch) of
          [] -> true;
          Error ->
              error_logger:info_msg("not a branch: ~s~n", [Error]),
              false
      end.
  
negative.code: 
  get_revno(_State, Package, Branch) ->
      GetRevno = format("GIT_DIR=~s git rev-parse heads/~s", [Package, Branch]),
      case command(GetRevno) of
          {error, Error} -> {error, Error};
          {ok, Revno} -> {ok, binary:replace(Revno, <<"\n">>, <<>>)}
      end.
  
  
  is_repository(_State, Package) ->
      IsRepo = format("GIT_DIR=~s git rev-parse", [Package]),
      case command(IsRepo) of
          {ok, <<>>} -> true;
          {error, _} -> 
              error_logger:info_msg("~s is not repository~n", [Package]),
              false
      end.
  