get_subtree

in lib/grit/git-ruby/repository.rb [557:574]


      def get_subtree(commit_sha, path)
        tree_sha = get_object_by_sha1(commit_sha).tree

        if path && !(path == '' || path == '.' || path == './')
          paths = path.split('/')
          paths.each do |pathname|
            tree = get_object_by_sha1(tree_sha)
            if entry = tree.entry.select { |e| e.name == pathname }.first
              tree_sha = entry.sha1 rescue nil
            else
              return false
            end
          end
        end

        tree_sha
      end