def commit(message, parents = nil, actor = nil, last_tree = nil, head = 'master')
      commit_tree_sha = nil
      if parents.is_a?(Hash)
        commit_tree_sha = parents[:commit_tree_sha]
        actor          = parents[:actor]
        committer      = parents[:committer]
        author         = parents[:author]
        last_tree      = parents[:last_tree]
        head           = parents[:head]
        committed_date = parents[:committed_date]
        authored_date  = parents[:authored_date]
        parents        = parents[:parents]
      end

      committer ||= actor
      author    ||= committer

      if commit_tree_sha
        tree_sha1 = commit_tree_sha
      else
        tree_sha1 = write_tree(self.tree, self.current_tree)
      end

      # don't write identical commits
      return false if tree_sha1 == last_tree

      contents = []
      contents << ['tree', tree_sha1].join(' ')
      parents.each do |p|
        contents << ['parent', p].join(' ')
      end if parents

      committer      ||= begin
        config = Config.new(self.repo)
        Actor.new(config['user.name'], config['user.email'])
      end
      author         ||= committer
      committed_date ||= Time.now
      authored_date  ||= committed_date

      contents << ['author',    author.output(authored_date)].join(' ')
      contents << ['committer', committer.output(committed_date)].join(' ')
      contents << ''
      contents << message

      contents = contents.join("\n")
      @last_commit_size = contents.size
      commit_sha1 = self.repo.git.put_raw_object(contents, 'commit')

      self.repo.update_ref(head, commit_sha1) if head
      commit_sha1
    end
def commit(message, parents = nil, actor = nil, last_tree = nil, head = 'master')
      commit_tree_sha = nil
      if parents.is_a?(Hash)
        commit_tree_sha = parents[:commit_tree_sha]
        actor          = parents[:actor]
        committer      = parents[:committer]
        author         = parents[:author]
        last_tree      = parents[:last_tree]
        head           = parents[:head]
        committed_date = parents[:committed_date]
        authored_date  = parents[:authored_date]
        parents        = parents[:parents]
      end

      committer ||= actor
      author    ||= committer

      if commit_tree_sha
        tree_sha1 = commit_tree_sha
      else
        tree_sha1 = write_tree(self.tree, self.current_tree)
      end

      # don't write identical commits
      return false if tree_sha1 == last_tree

      contents = []
      contents << ['tree', tree_sha1].join(' ')
      parents.each do |p|
        contents << ['parent', p].join(' ')
      end if parents

      committer      ||= begin
        config = Config.new(self.repo)
        Actor.new(config['user.name'], config['user.email'])
      end
      author         ||= committer
      committed_date ||= Time.now
      authored_date  ||= committed_date

      contents << ['author',    author.output(authored_date)].join(' ')
      contents << ['committer', committer.output(committed_date)].join(' ')
      contents << ''
      contents << message

      contents = contents.join("\n")
      @last_commit_size = contents.size
      commit_sha1 = self.repo.git.put_raw_object(contents, 'commit')

      self.repo.update_ref(head, commit_sha1) if head
      commit_sha1
    end
Public: Commit the contents of the index.  This method supports two
 formats for arguments:

 message - The String commit message.
 options - An optional Hash of index options.
           :parents        - Array of String commit SHA1s or Grit::Commit
                             objects to attach this commit to to form a
                             new head (default: nil).
           :actor          - The Grit::Actor details of the user making
                             the commit (default: nil).
           :last_tree      - The String SHA1 of a tree to compare with
                             in order to avoid making empty commits
                             (default: nil).
           :head           - The String branch name to write this head to
                             (default: nil).
           :committed_date - The Time that the commit was made.
                             (Default: Time.now)
           :authored_date  - The Time that the commit was authored.
                             (Default: committed_date)

 The legacy argument style looks like:

 message   - The String commit message.
 parents   - Array of String commit SHA1s or Grit::Commit objects to
             attach this commit to to form a new head (default: nil).
 actor     - The Grit::Actor details of the user making the commit
             (default: nil).
 last_tree - The String SHA1 of a tree to compare with in order to avoid
             making empty commits (default: nil).
 head      - The String branch name to write this head to
             (default: "master").

 Returns a String of the SHA1 of the new commit.