anchor.diff:    {ok, Git2, NewTreeSha}.
   
   
  +walk_tree(Git, undefined) ->
  +  {ok, Git, []};
  +walk_tree(Git, SHA1) ->
  +  {ok, Git2, tree, Tree} = read_object(Git, SHA1), {ok, Git2, Tree}.
  +
  +
   walk_down_tree(Git1, OldTreeSha, [Path], Mode, BlobSha) ->
  -  {ok, Git2, tree, OldTree} = read_object(Git1, OldTreeSha),
  +  {ok, Git2, OldTree} = walk_tree(Git1, OldTreeSha),
     NewTree = lists:keystore(Path, 1, OldTree, {Path, Mode, BlobSha}),
     {ok, Git3, NewTreeSha} = put_raw_object(Git2, tree, write_tree(NewTree)),
     {ok, Git3, NewTreeSha};
   
   walk_down_tree(Git1, OldTreeSha, [Path|Parts], Mode, BlobSha) ->
  -  {ok, Git2, tree, OldTree} = read_object(Git1, OldTreeSha),
  -  io:format("Content: ~p ~p~n", [Path, [A || {A,_,_} <- OldTree]]),
  -  case lists:keyfind(Path, 1, OldTree) of
  -    {Path, <<"40000">> = DirMode, NextSha} ->
  -      {ok, Git3, NewSha} = walk_down_tree(Git2, NextSha, Parts, Mode, BlobSha),
  -      NewTree = lists:keystore(Path, 1, OldTree, {Path, DirMode, NewSha}),
  -      {ok, Git4, NewTreeSha} = put_raw_object(Git3, tree, write_tree(NewTree)),
  -      {ok, Git4, NewTreeSha};
  +  {ok, Git2, OldTree} = walk_tree(Git1, OldTreeSha),
  +  NextSha = case lists:keyfind(Path, 1, OldTree) of
  +    {Path, <<"40000">>, NextSha_} ->
  +      NextSha_;
       {Path, BadMode, _} ->
         throw({cant_add,Path, BadMode, Parts});
       false ->
  -      throw({not_implemented_adding_new_dir,Path})
  -  end.
  +      undefined
  +  end,
  +  {ok, Git3, NewSha} = walk_down_tree(Git2, NextSha, Parts, Mode, BlobSha),
  +  NewTree = lists:keystore(Path, 1, OldTree, {Path, <<"40000">>, NewSha}),
  +  {ok, Git4, NewTreeSha} = put_raw_object(Git3, tree, write_tree(NewTree)),
  +  {ok, Git4, NewTreeSha}.
  +
  +
   
   to_b(List) when is_list(List) -> list_to_binary(List);
   to_b(Binary) when is_binary(Binary) -> Binary;
  
positive.code:   ?assertMatch({<<"lib">>, <<"40000">>, _}, lists:keyfind(<<"lib">>, 1, Tree)),
    ok.
  
  
  test_raw_commit_files(Tempdir) ->
    {ok, Git1, BlobSha} = put_raw_object(Tempdir, blob, "simple blob"),
  
negative.code: test_commit_files(Tempdir) ->
    ?assertMatch({ok, _}, commit_files(Tempdir, "master", [
      {"lib/grit/git-ruby/file.txt", "100644", "simple blob"},
      {"lib/grit/file5.txt", "100644", "another blob"},
      {"new1/new2/file2.txt", "100644", "new blob"}
    ], [{message, "test commit"},{author,"test@commiter"}])),
    ?assertMatch({ok, _, blob, <<"simple blob">>}, gitty:show(Tempdir, "master:lib/grit/git-ruby/file.txt")),
    ?assertMatch({ok, _, blob, <<"another blob">>}, gitty:show(Tempdir, "master:lib/grit/file5.txt")),
    ?assertMatch({ok, _, blob, <<"new blob">>}, gitty:show(Tempdir, "master:new1/new2/file2.txt")),
    ok.
  
  
  