diff --git a/lib/kmxgit/git_manager.ex b/lib/kmxgit/git_manager.ex
index 7829128..ba86a1d 100644
--- a/lib/kmxgit/git_manager.ex
+++ b/lib/kmxgit/git_manager.ex
@@ -198,7 +198,8 @@ defmodule Kmxgit.GitManager do
end
end
- defp ok_hd({:ok, list}), do: {:ok, hd(list)}
+ defp ok_hd({:ok, [first | _]}), do: {:ok, first}
+ defp ok_hd({:ok, []}), do: {:ok, nil}
defp ok_hd(x), do: x
def log1(repo, tree \\ nil) do