Method: Gitgo::Git::Tree#subtree

Defined in:
lib/gitgo/git/tree.rb

#subtree(segments, force = false) ⇒ Object

Returns the subtree indicated by the specified segments (an array of paths), or nil if no such subtree exists. If force is true then missing subtrees will be created.



188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/gitgo/git/tree.rb', line 188

def subtree(segments, force=false)
  return self if segments.empty?
  
  key = segments.shift
  tree = self[key]

  if !tree.kind_of?(Tree)
    return nil unless force
    self[key] = tree = Tree.new(nil)
  end
  
  tree.subtree(segments, force)
end