vendor/bundle/ruby/1.8/gems/grit-2.4.1/lib/grit/git.rb
# Checks if the patch of a commit can be applied to the given head.
#
# head_sha    - String SHA or ref to check the patch against.
# applies_sha - String SHA of the patch.  The patch itself is retrieved
#               with #get_patch.
#
# Returns 0 if the patch applies cleanly (according to `git apply`), or
# an Integer that is the sum of the failed exit statuses.
Checks if the patch of a commit can be applied to the given head.
head_sha    - String SHA or ref to check the patch against.
applies_sha - String SHA of the patch.  The patch itself is retrieved
with #get_patch.

Returns 0 if the patch applies cleanly (according to `git apply`), or
an Integer that is the sum of the failed exit statuses.
Checks if the patch of a commit can be applied to the given head . head_sha - String SHA or ref to check the patch against . applies_sha - String SHA of the patch . The patch itself is retrieved with #get_patch . Returns 0 if the patch applies cleanly ( according to ` git apply ` ) or an Integer that is the sum of the failed exit statuses .
def check_applies(head_sha, applies_sha)
      git_index = create_tempfile('index', true)
      options   = {:env => {'GIT_INDEX_FILE' => git_index}, :raise => true}
      status    = 0
      begin
        native(:read_tree, options.dup, head_sha)
        stdin = native(:diff, options.dup, "#{applies_sha}^", applies_sha)
        native(:apply, options.merge(:check => true, :cached => true, :input => stdin))
      rescue CommandFailed => fail
        status += fail.exitstatus
      end
      status
    end
def check_applies ( head_sha , applies_sha ) git_index = create_tempfile ( 'index' , true ) options = { :env => { 'GIT_INDEX_FILE' => git_index } , :raise => true } status = 0 begin native ( :read_tree , options . dup , head_sha ) stdin = native ( :diff , options . dup , "#{applies_sha}^" , applies_sha ) native ( :apply , options . merge ( :check => true , :cached => true , :input => stdin ) ) rescue CommandFailed => fail status += fail . exitstatus end status end
Checks if the patch of a commit can be applied to the given head.
Checks if the patch of a commit can be applied to the given head .
head_sha
applies_sha