diff --git a/lib/kmxgit_web/templates/repository/show_actions.html.heex b/lib/kmxgit_web/templates/repository/show_actions.html.heex
index 995396e..e2cd3c9 100644
--- a/lib/kmxgit_web/templates/repository/show_actions.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_actions.html.heex
@@ -6,6 +6,6 @@
<%= if @current_user do %>
<%= link gettext("Fork"), to: Routes.repository_path(@conn, :fork, Repository.owner_slug(@repo), Repository.splat(@repo)), class: "btn btn-primary" %>
<% end %>
-<%= if (@tree != "master") do %>
+<%= if (@tree && @tree != "master") do %>
<%= link gettext("Diff"), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_diff", @tree, "master"])), class: "btn btn-primary" %>
<% end %>