anchor.diff:            end,
       Name2 = make_dep_name(Name1, Co1),
       RebarFile = rebar_conf_file(dep_path(Name2)),
  -    Acc1 = case deps(RebarFile) of
  -               {ok, Deps} ->
  -                   deps_path(Deps, []);
  -               {error, _} ->
  -                   []
  -           end,
  +    Conf = consult(RebarFile),
  +    Deps = get_value(deps, Conf, []),
  +    %% TODO: handle sub_dirs
  +    Acc1 = deps_path(Deps, []),
       deps_path(T, [dep_path(Name2)|Acc ++ Acc1]).
   
   deps_ebin(Deps) ->
  
positive.code:     filename:join([?DEPS_PATH, X]).
  
  rebar_conf_file(X) ->
      filename:join([X, "rebar.config"]).
  
  ebin(X) ->
      %% X/ebin
  
negative.code: 
  %% read rebar.config file and return the {deps, V}
  deps(RebarFile) ->
      get_value(deps, consult(RebarFile), []).
  
  do_clone_deps([]) ->
      ok;
  do_clone_deps([H|T]) when is_tuple(H) =:= false ->
      do_clone_deps(T);
  do_clone_deps([H|T]) ->
      {Name, Repo} = name_and_repo(H),
      {Cmd, Url, Co} = case Repo of
                           V={_, _, _} ->
                               V;
                           {_Cmd, _Url, _Co, _} ->
                               {_Cmd, _Url, _Co}
                       end,
      Co1 = checkout_to(Co),
      DepName = make_dep_name(Name, Co1),
  
      %% command options: clone url path/to/dep -b Branch/Tag
      DepPath = dep_path(DepName),
      Opts = ["clone", Url, DepPath],
      io:format("dependency: ~s~n", [Name]),
      %% clone
      exec(Cmd, Opts),
  
      %% checkout to Co1
      {ok, Cwd} = file:get_cwd(),
      ok = file:set_cwd(DepPath),
      exec(Cmd, ["checkout", Co1]),
      ok = file:set_cwd(Cwd),
  
      %% check dependencies of the dependency
      RebarFile = rebar_conf_file(dep_path(DepName)),
      do_clone_deps(deps(RebarFile)),
      do_clone_deps(T).
  
  erl_files(Dir) ->
      filelib:wildcard(filename:join([Dir, "*.erl"])).
  
  checkout_to({_, V}) -> V;
  checkout_to(Else) -> Else.
  
  name_and_repo({Name, _, Repo}) ->
      {atom_to_list(Name), Repo};
  name_and_repo({Name, _, Repo, _}) ->
      {atom_to_list(Name), Repo}.
  
  consult(File) ->
      AbsFile = filename:absname(File),
      case file:consult(AbsFile) of
          {ok, V} ->
              V;
          _ ->
              []
      end.
  
  get_value(Key, Opts, Default) ->
      case lists:keyfind(Key, 1, Opts) of
          {Key, Value} ->
              Value;
          _ -> Default
      end.
  
  check_libdirs([], _) ->
      ok;
  check_libdirs([H|T], Fun) ->
      Dir = filename:absname(H),
      Conf = rebar_conf_file(Dir),
      check_libdirs(get_value(sub_dirs, Conf, []), Fun),
      Fun(get_value(deps, Conf, [])),
      check_libdirs(T, Fun).
  
  %% schema_to_git(X) ->
  %%     re:replace(X, "https://", "git://", [{return, list}]).
  
  %% schema_to_https(X) ->
  %%     re:replace(X, "git://", "https://", [{return, list}]).
  