diff --git a/app/assets/stylesheets/gitlab_bootstrap/files.scss b/app/assets/stylesheets/gitlab_bootstrap/files.scss
index 8ba8c93e3d6affb0412c67ca0a4201cfb9d115e8..a286e530cd6025a1b958c7c24ba98d0cd887c52a 100644
--- a/app/assets/stylesheets/gitlab_bootstrap/files.scss
+++ b/app/assets/stylesheets/gitlab_bootstrap/files.scss
@@ -69,6 +69,12 @@
 
     }
 
+    &.blob-no-preview {
+      background: #eee;
+      text-shadow: 0 1px 2px #FFF;
+      padding: 100px 0;
+    }
+
     /**
      *  Blame file
      */
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 33dbc8699965ee1997f2bd5f391e6a0bd5767fa4..878f25c7c03da2532bb960722ba9c8b777fdb9b6 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -9,5 +9,7 @@ class Projects::BlobController < Projects::ApplicationController
 
   def show
     @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path)
+
+    not_found! unless @blob
   end
 end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 734d060095edbd91947cd8fe5c580eec8a7697bf..145bd51ffd378f00a17e83031407882e3098f522 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -5,7 +5,7 @@ class Repository
 
   def initialize(path_with_namespace, default_branch)
     @path_with_namespace = path_with_namespace
-    @raw_repository = Gitlab::Git::Repository.new(path_to_repo)
+    @raw_repository = Gitlab::Git::Repository.new(path_to_repo) if path_with_namespace
   rescue Gitlab::Git::Repository::NoRepository
     nil
   end
diff --git a/app/views/projects/blob/_download.html.haml b/app/views/projects/blob/_download.html.haml
index f3da1a2a2196609e2f0f9f406b50f89b83259334..ff317f9020967e356bb81d4e773d411220b2c3ef 100644
--- a/app/views/projects/blob/_download.html.haml
+++ b/app/views/projects/blob/_download.html.haml
@@ -1,8 +1,7 @@
-.file-content.blob_file
+.file-content.blob_file.blob-no-preview
   %center
     = link_to project_raw_path(@project, @id) do
-      %div.padded
-        %h4
-          %i.icon-download-alt
-          %br
-          Download (#{number_to_human_size blob.size})
+      %h1.light
+        %i.icon-download-alt
+      %h4
+        Download (#{number_to_human_size blob.size})
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index c2b229b0172525a7cd78cb1170e542c02c359e73..1a911eae2bb13c8cbcb082d216498cadb6337f8e 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -139,7 +139,7 @@ module API
         path = params[:path] || nil
 
         commit = user_project.repository.commit(ref)
-        tree = Tree.new(user_project.repository, commit.id, ref, path)
+        tree = Tree.new(user_project.repository, commit.id, path)
 
         trees = []
 
@@ -168,8 +168,8 @@ module API
         commit = repo.commit(ref)
         not_found! "Commit" unless commit
 
-        blob = Gitlab::Git::Blob.new(repo, commit.id, ref, params[:filepath])
-        not_found! "File" unless blob.exists?
+        blob = Gitlab::Git::Blob.find(repo, commit.id, params[:filepath])
+        not_found! "File" unless blob
 
         env['api.format'] = :txt
 
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index 5f28d62440282a9b033c7da3251fd13a3676419c..6e7872dcd033655dfe70ab1cb0f9a309f8ca3d3e 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -107,6 +107,8 @@ module ExtractsPath
       @commit = @repo.commit(@options[:extended_sha1])
     end
 
+    raise InvalidPathError unless @commit
+
     @hex_path = Digest::SHA1.hexdigest(@path)
     @logs_path = logs_file_project_ref_path(@project, @ref, @path)