Method: Git::Lib#ls_tree

Defined in:
lib/git/lib.rb

#ls_tree(sha, opts = {})



588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
# File 'lib/git/lib.rb', line 588

def ls_tree(sha, opts = {})
  data = { 'blob' => {}, 'tree' => {}, 'commit' => {} }

  ls_tree_opts = []
  ls_tree_opts << '-r' if opts[:recursive]
  # path must be last arg
  ls_tree_opts << opts[:path] if opts[:path]

  command_lines('ls-tree', sha, *ls_tree_opts).each do |line|
    (info, filenm) = line.split("\t")
    (mode, type, sha) = info.split
    data[type][filenm] = {:mode => mode, :sha => sha}
  end

  data
end