def merge(commit_one, commit_two)
      common_ancestor  = commit_one.common_ancestor(commit_two, object_store)
      commit_one_files = Hash[get_object(commit_one.tree).all_files(object_store).to_a]
      commit_two_files = Hash[get_object(commit_two.tree).all_files(object_store).to_a]

      if common_ancestor.nil?
        ancestor_files = {}
      else
        ancestor_files = Hash[get_object(common_ancestor.tree).all_files(object_store).to_a]
      end

      all_files = commit_one_files.keys | commit_two_files.keys | ancestor_files.keys

      merged     = []
      conflicted = []

      all_files.each do |file|
        ancestor = ancestor_files.key?(file)   ? get_object(ancestor_files[file]).content.lines   : []
        file_one = commit_one_files.key?(file) ? get_object(commit_one_files[file]).content.lines : []
        file_two = commit_two_files.key?(file) ? get_object(commit_two_files[file]).content.lines : []

        diff = VCSToolkit::Merge.three_way ancestor, file_one, file_two

        if diff.has_conflicts?
          conflicted << file
        elsif diff.has_changes?
          merged << file
        end

        content = diff.new_content("<<<<< #{commit_one.id}\n", ">>>>> #{commit_two.id}\n", "=====\n")

        if content.empty?
          staging_area.delete_file file if staging_area.file? file
        else
          staging_area.store file, content.join('')
        end
      end

      {merged: merged, conflicted: conflicted}
    end
def merge(commit_one, commit_two)
      common_ancestor  = commit_one.common_ancestor(commit_two, object_store)
      commit_one_files = Hash[get_object(commit_one.tree).all_files(object_store).to_a]
      commit_two_files = Hash[get_object(commit_two.tree).all_files(object_store).to_a]

      if common_ancestor.nil?
        ancestor_files = {}
      else
        ancestor_files = Hash[get_object(common_ancestor.tree).all_files(object_store).to_a]
      end

      all_files = commit_one_files.keys | commit_two_files.keys | ancestor_files.keys

      merged     = []
      conflicted = []

      all_files.each do |file|
        ancestor = ancestor_files.key?(file)   ? get_object(ancestor_files[file]).content.lines   : []
        file_one = commit_one_files.key?(file) ? get_object(commit_one_files[file]).content.lines : []
        file_two = commit_two_files.key?(file) ? get_object(commit_two_files[file]).content.lines : []

        diff = VCSToolkit::Merge.three_way ancestor, file_one, file_two

        if diff.has_conflicts?
          conflicted << file
        elsif diff.has_changes?
          merged << file
        end

        content = diff.new_content("<<<<< #{commit_one.id}\n", ">>>>> #{commit_two.id}\n", "=====\n")

        if content.empty?
          staging_area.delete_file file if staging_area.file? file
        else
          staging_area.store file, content.join('')
        end
      end

      {merged: merged, conflicted: conflicted}
    end
Merge two commits and save the changes to the staging area.