If commit is a RESTful controller that uses :sha instead of an id to find records. You could do this instead:
map.resource :commits, :path_prefix => :user/:repo , :as => commit
It will create the standard RESTful routes that look like http://yoursite.tld/:user/:repo/commit/:id
Again, if you ll never be translating the id portion in the url to a commit id, then there s no reason you can t use it as a :sha value.
example:
class CommitController < ApplicationController
def show
@commit = Commit.find(:first, :conditions => {:sha => params[:id]})
end
...
end
You may also want to over ride to_param in the commit model to return the sha value.
class Commt < ActiveRecord::Base
...
def to_param
sha
end
end
So that now link_to commit_url(@commit, :user => current_user, :repo => @repo)
will provide a url that matches your scheme.