diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb
index e4a84f80787027fd899169e30557556e6cdbd01c..9832495c64fb3a1d177b37434d37225d59272d90 100644
--- a/app/controllers/projects/network_controller.rb
+++ b/app/controllers/projects/network_controller.rb
@@ -8,10 +8,6 @@ class Projects::NetworkController < Projects::ApplicationController
   before_filter :require_non_empty_project
 
   def show
-    if @options[:q]
-      @commit = @project.repository.commit(@options[:q]) || @commit
-    end
-
     respond_to do |format|
       format.html
 
diff --git a/features/project/network.feature b/features/project/network.feature
index f98e19b60d322822ffe60e43ea35f78ad6ccd5b1..ceae08c10743c661d8499fde50e263be00b79fa5 100644
--- a/features/project/network.feature
+++ b/features/project/network.feature
@@ -34,3 +34,7 @@ Feature: Project Network Graph
     Then page should not have content not cotaining "v2.1.0"
     When click "Show only selected branch" checkbox
     Then page should have content not cotaining "v2.1.0"
+
+  Scenario: I should fail to look for a commit
+    When I look for a commit by ";"
+    Then page status code should be 404
diff --git a/features/steps/project/project_network_graph.rb b/features/steps/project/project_network_graph.rb
index c883479ffd3a791ec10392e3e7a8a0819b1bf507..b3be2a48eccfee094e0b910c9b116fe33b053402 100644
--- a/features/steps/project/project_network_graph.rb
+++ b/features/steps/project/project_network_graph.rb
@@ -87,4 +87,11 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
       page.should have_content 'v2.1.0'
     end
   end
+
+  When 'I look for a commit by ";"' do
+    within ".content .search" do
+      fill_in 'q', with: ';'
+      find('button').click
+    end
+  end
 end
diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb
index 66553e1e089564967bdee828ee0e88c6018d6a69..c5d8b62bfe7d61c438d49109b1ae3ac6a2060fa8 100644
--- a/features/steps/shared/project.rb
+++ b/features/steps/shared/project.rb
@@ -51,6 +51,10 @@ module SharedProject
     page.should have_content("Features:")
   end
 
+  Then 'page status code should be 404' do
+    page.status_code.should == 404
+  end
+
   def current_project
     @project ||= Project.first
   end
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index d1035240cb62b255c1088b2a942e668b476540c3..f9843d503b4519ed53e423c521a685647379745e 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -94,19 +94,23 @@ module ExtractsPath
   # Automatically renders `not_found!` if a valid tree path could not be
   # resolved (e.g., when a user inserts an invalid path or ref).
   def assign_ref_vars
+    # assign allowed options
+    allowed_options = ["filter_ref", "q"]
+    @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? }
+    @options = HashWithIndifferentAccess.new(@options)
+
     @id = get_id
     @ref, @path = extract_ref(@id)
     @repo = @project.repository
-    @commit = @repo.commit(@ref)
+    if @options[:q].blank?
+      @commit = @repo.commit(@ref)
+    else
+      @commit = @repo.commit(@options[:q])
+    end
     @tree = Tree.new(@repo, @commit.id, @ref, @path)
     @hex_path = Digest::SHA1.hexdigest(@path)
     @logs_path = logs_file_project_ref_path(@project, @ref, @path)
 
-    # assign allowed options
-    allowed_options = ["filter_ref", "q"]
-    @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? }
-    @options = HashWithIndifferentAccess.new(@options)
-
     raise InvalidPathError unless @tree.exists?
   rescue RuntimeError, NoMethodError, InvalidPathError
     not_found!