diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb
index 7ca5e3bf7cac3bbc1857d70d030ca43b3e0026d9..376527394ca7a22dc3ff46502e7a5559d83748a2 100644
--- a/app/controllers/commits_controller.rb
+++ b/app/controllers/commits_controller.rb
@@ -12,12 +12,12 @@ class CommitsController < ApplicationController
 
   def index
     @repo = project.repo
-    limit, offset = (params[:limit] || 20), (params[:offset] || 0)
+    @limit, @offset = (params[:limit] || 20), (params[:offset] || 0)
 
     @commits = if params[:path]
-                 @repo.log(@ref, params[:path], :max_count => limit, :skip => offset)
+                 @repo.log(@ref, params[:path], :max_count => @limit, :skip => @offset)
                else
-                 @repo.commits(@ref, limit, offset)
+                 @repo.commits(@ref, @limit, @offset)
                end
 
     respond_to do |format|
diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml
index 14317b4cb28a2c4a0c13ca852529abf3eb81f22e..fb8d039052bf3ebc7c627457597630700b7cee0a 100644
--- a/app/views/commits/index.html.haml
+++ b/app/views/commits/index.html.haml
@@ -20,7 +20,8 @@
 .loading{ :style => "display:none;"}
   %center= image_tag "ajax-loader.gif"
 
-:javascript
-  $(function(){
-    CommitsList.init("#{@ref}", 20);
-  });
+- if @commits.count == @limit
+  :javascript
+    $(function(){
+      CommitsList.init("#{@ref}", 20);
+    });