title: Rugged and Grack: Finding commit before push
body: <p>I am using <a href="https://github.com/libgit2/rugged" rel="nofollow">rugged</a> for git related operations (initializing repo with web interface) and <a href="https://github.com/gitlabhq/grack" rel="nofollow">gitlab-grack</a> for implementation of http-backend CGI. It is working fine and I am able to make push, pull etc. However, I want to find blobs which changed after every push (I have to do some processing on those objects). One way of doing this can be:</p>
  
  <ul>
  <li>Read head from refs/head/<strong>brach_name</strong> file before a push is made</li>
  <li>Do the push</li>
  <li>Find all the files changed between commit before push and one after push by diff</li>
  </ul>
  
  <p>I am unable to find the branch_name from the request made. Following push:</p>
  
  <pre><code>git push http://localhost:3000/addie/cards.git master:newone
  </code></pre>
  
  <p>generated following rack request:</p>
  
  <pre><code>#&lt;Rack::Request:0x007fb1881e24b8 @env={"CONTENT_LENGTH"=&gt;"449", "CONTENT_TYPE"=&gt;"application/x-git-receive-pack-request", "GATEWAY_INTERFACE"=&gt;"CGI/1.1", "PATH_INFO"=&gt;"/addie/cards.git/git-receive-pack", "QUERY_STRING"=&gt;"", "REMOTE_ADDR"=&gt;"127.0.0.1", "REMOTE_HOST"=&gt;"127.0.0.1", "REQUEST_METHOD"=&gt;"POST", "REQUEST_URI"=&gt;"http://localhost:3000/addie/cards.git/git-receive-pack", "SCRIPT_NAME"=&gt;"", "SERVER_NAME"=&gt;"localhost", "SERVER_PORT"=&gt;"3000", "SERVER_PROTOCOL"=&gt;"HTTP/1.1", "SERVER_SOFTWARE"=&gt;"WEBrick/1.3.1 (Ruby/2.2.1/2015-02-26)", "HTTP_AUTHORIZATION"=&gt;"Basic YWRkaWU6c2VjcmV0cGFzc3dvcmQ=", "HTTP_USER_AGENT"=&gt;"git/2.1.0", "HTTP_HOST"=&gt;"localhost:3000", "HTTP_ACCEPT_ENCODING"=&gt;"gzip", "HTTP_ACCEPT"=&gt;"application/x-git-receive-pack-result", "rack.version"=&gt;[1, 2], "rack.input"=&gt;#&lt;StringIO:0x007fb18819e128&gt;, "rack.errors"=&gt;#&lt;IO:&lt;STDERR&gt;&gt;, "rack.multithread"=&gt;false, "rack.multiprocess"=&gt;false, "rack.run_once"=&gt;false, "rack.url_scheme"=&gt;"http", "HTTP_VERSION"=&gt;"HTTP/1.1", "REQUEST_PATH"=&gt;"/addie/cards.git/git-receive-pack", "ORIGINAL_FULLPATH"=&gt;"/addie/cards.git/git-receive-pack", "ORIGINAL_SCRIPT_NAME"=&gt;"", "action_dispatch.routes"=&gt;#&lt;ActionDispatch::Routing::RouteSet:0x000000008285e8&gt;, "action_dispatch.parameter_filter"=&gt;[:password], "action_dispatch.redirect_filter"=&gt;[], "action_dispatch.secret_token"=&gt;nil, "action_dispatch.secret_key_base"=&gt;"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "action_dispatch.show_exceptions"=&gt;true, "action_dispatch.show_detailed_exceptions"=&gt;true, "action_dispatch.logger"=&gt;#&lt;ActiveSupport::Logger:0x00000004746298 @progname="omniauth", @level=0, @default_formatter=#&lt;Logger::Formatter:0x00000004746220 @datetime_format=nil&gt;, @formatter=#&lt;ActiveSupport::Logger::SimpleFormatter:0x00000003db90e0 @datetime_format=nil&gt;, @logdev=#&lt;Logger::LogDevice:0x000000047461d0 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#&lt;File:/home/addie/GlitterGallery/log/development.log&gt;, @mutex=#&lt;Logger::LogDevice::LogDeviceMutex:0x00000004746180 @mon_owner=nil, @mon_count=0, @mon_mutex=#&lt;Mutex:0x00000004746130&gt;&gt;&gt;, @thread_hash_level_key=:"ThreadSafeLogger#37368140@level"&gt;, "action_dispatch.backtrace_cleaner"=&gt;#&lt;Rails::BacktraceCleaner:0x007fb19002b770 @filters=[#&lt;Proc:0x007fb19002b6a8@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:10&gt;, #&lt;Proc:0x007fb19002b680@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:11&gt;, #&lt;Proc:0x007fb19002b658@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:12&gt;, #&lt;Proc:0x007fb19002b310@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:24&gt;], @silencers=[#&lt;Proc:0x007fb19002b2e8@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/railties-4.1.9/lib/rails/backtrace_cleaner.rb:15&gt;]&gt;, "action_dispatch.key_generator"=&gt;#&lt;ActiveSupport::CachingKeyGenerator:0x007fb19002b180 @key_generator=#&lt;ActiveSupport::KeyGenerator:0x007fb19002b1a8 @secret="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", @iterations=1000&gt;, @cache_keys=#&lt;ThreadSafe::Cache:0x007fb19002b158 @backend={}, @default_proc=nil&gt;&gt;, "action_dispatch.http_auth_salt"=&gt;"http authentication", "action_dispatch.signed_cookie_salt"=&gt;"signed cookie", "action_dispatch.encrypted_cookie_salt"=&gt;"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=&gt;"signed encrypted cookie", "action_dispatch.cookies_serializer"=&gt;nil, "ROUTES_4276980_SCRIPT_NAME"=&gt;"", "action_dispatch.request_id"=&gt;"3e2cf532-80d7-4d28-9714-d920105e16bb", "action_dispatch.remote_ip"=&gt;#&lt;ActionDispatch::RemoteIp::GetIp:0x007fb18819c300 @env={...}, @check_ip=true, @proxies=/
        ^127\.0\.0\.1$                | # localhost IPv4
        ^::1$                         | # localhost IPv6
        ^fc00:                        | # private IPv6 range fc00
        ^10\.                         | # private IPv4 range 10.x.x.x
        ^172\.(1[6-9]|2[0-9]|3[0-1])\.| # private IPv4 range 172.16.0.0 .. 172.31.255.255
        ^192\.168\.                     # private IPv4 range 192.168.x.x
      /x&gt;, "rack.session"=&gt;#&lt;ActionDispatch::Request::Session:0x7fb1881cc4b0 not yet loaded&gt;, "rack.session.options"=&gt;#&lt;ActionDispatch::Request::Session::Options:0x007fb1881cc460 @by=#&lt;ActionDispatch::Session::ActiveRecordStore:0x000000047b0990 @app=#&lt;ActionDispatch::Flash:0x000000047b09e0 @app=#&lt;ActionDispatch::ParamsParser:0x000000047b0b70 @app=#&lt;Rack::Head:0x000000047b0b98 @app=#&lt;Rack::ConditionalGet:0x000000047b0bc0 @app=#&lt;Rack::ETag:0x000000047b0be8 @app=#&lt;Warden::Manager:0x000000047b0d00 @config={:default_scope=&gt;:user, :scope_defaults=&gt;{}, :default_strategies=&gt;{:user=&gt;[:rememberable, :database_authenticatable]}, :intercept_401=&gt;false, :failure_app=&gt;#&lt;Devise::Delegator:0x00000004224710&gt;}, @app=#&lt;OmniAuth::Builder:0x00000005454688 @options=nil, @run=#&lt;ActionDispatch::Static:0x00000005454908 @app=#&lt;ActionDispatch::Routing::RouteSet:0x000000008285e8&gt;, @file_handler=#&lt;ActionDispatch::FileHandler:0x000000054548e0 @root="/home/addie/GlitterGallery/vendor/ruby/2.2.0/bundler/gems/ratyrate-b705610b3c6f/vendor", @compiled_root=/^\/home\/addie\/GlitterGallery\/vendor\/ruby\/2\.2\.0\/bundler\/gems\/ratyrate\-b705610b3c6f\/vendor/, @file_server=#&lt;Rack::File:0x000000054546d8 @root="/home/addie/GlitterGallery/vendor/ruby/2.2.0/bundler/gems/ratyrate-b705610b3c6f/vendor", @headers=nil, @default_mime="text/plain"&gt;, @ext="{,.html,/index.html}"&gt;&gt;, @map=nil, @use=[#&lt;Proc:0x00000005454160@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86&gt;, #&lt;Proc:0x000000047cbab0@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86&gt;, #&lt;Proc:0x000000047cb6c8@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86&gt;, #&lt;Proc:0x000000047cadb8@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86&gt;, #&lt;Proc:0x000000047b0d28@/home/addie/GlitterGallery/vendor/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:86&gt;]&gt;&gt;, @cache_control="max-age=0, private, must-revalidate", @no_cache_control="no-cache"&gt;&gt;&gt;, @parsers={#&lt;Mime::Type:0x000000020d9f60 @synonyms=["text/x-json", "application/jsonrequest"], @symbol=:json, @string="application/json"&gt;=&gt;:json}&gt;&gt;, @default_options={:path=&gt;"/", :domain=&gt;nil, :expire_after=&gt;nil, :secure=&gt;false, :httponly=&gt;true, :defer=&gt;false, :renew=&gt;false}, @key="_session_id", @cookie_only=true&gt;, @env={...}, @delegate={:path=&gt;"/", :domain=&gt;nil, :expire_after=&gt;nil, :secure=&gt;false, :httponly=&gt;true, :defer=&gt;false, :renew=&gt;false}&gt;, "action_dispatch.request.content_type"=&gt;#&lt;Mime::Type:0x007fb1881cc258 @synonyms=[], @symbol=nil, @string="application/x-git-receive-pack-request"&gt;, "warden"=&gt;Warden::Proxy:70200234762460 @config={:default_scope=&gt;:user, :scope_defaults=&gt;{}, :default_strategies=&gt;{:user=&gt;[:rememberable, :database_authenticatable]}, :intercept_401=&gt;false, :failure_app=&gt;#&lt;Devise::Delegator:0x00000004224710&gt;}, "action_dispatch.request.path_parameters"=&gt;{}}&gt;
  </code></pre>
  
  <p>I am not sure what am I suppose to look at. How is <code>master:newone</code> part is being transferred in all that mess? Any other way to find files changed after every push can work for me too.</p>