Class: Git::Commands::LsTree Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/ls_tree.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

arguments block audited against https://git-scm.com/docs/git-ls-tree/2.53.0

Implements the git ls-tree command

Lists the contents of a tree object, showing the mode, type, object name, and file name of each item. Supports recursive listing, output format control, and path filtering.

Examples:

List the top-level tree of HEAD

ls_tree = Git::Commands::LsTree.new(execution_context)
ls_tree.call('HEAD')

Recursively list all files under HEAD

ls_tree = Git::Commands::LsTree.new(execution_context)
ls_tree.call('HEAD', r: true)

List only file names recursively

ls_tree = Git::Commands::LsTree.new(execution_context)
ls_tree.call('HEAD', r: true, name_only: true)

List entries under a specific path

ls_tree = Git::Commands::LsTree.new(execution_context)
ls_tree.call('HEAD', 'lib/')

See Also:

Instance Method Summary collapse

Methods inherited from Base

allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation

Constructor Details

This class inherits a constructor from Git::Commands::Base

Instance Method Details

#call(tree_ish, *path, **options) ⇒ Git::CommandLineResult

Execute the git ls-tree command

Parameters:

  • tree_ish (String)

    the tree object to list (SHA, branch name, tag, etc.)

  • path (Array<String>)

    optional path(s) to restrict the listing

    When given, only entries matching these paths are shown.

  • options (Hash)

    command options

Options Hash (**options):

  • :d (Boolean, nil) — default: nil

    show only the named tree entry itself, not its children

  • :r (Boolean, nil) — default: nil

    recurse into sub-trees

  • :t (Boolean, nil) — default: nil

    show tree entries even when going to recurse them

    Implies recursive listing (:r) in git.

  • :long (Boolean, nil) — default: nil

    show object size of blob (file) objects

    Cannot be combined with :name_only or :object_only.

    Alias: :l

  • :z (Boolean, nil) — default: nil

    use NUL (\0) as line terminator instead of newline, and do not quote filenames

  • :name_only (Boolean, nil) — default: nil

    list only filenames, one per line

    Cannot be combined with :object_only or :long.

    Alias: :name_status

  • :object_only (Boolean, nil) — default: nil

    list only the object names (SHAs), one per line

    Cannot be combined with :name_only or :long.

  • :full_name (Boolean, nil) — default: nil

    show full path names instead of paths relative to the current working directory

  • :full_tree (Boolean, nil) — default: nil

    do not limit the listing to the current working directory; implies :full_name

  • :abbrev (Boolean, String, nil) — default: nil

    use abbreviated object names

    When true, uses git's default abbreviated name length. When a string (e.g. '8'), uses exactly that many hex digits.

  • :format (String) — default: nil

    a format string that interpolates %(fieldname) placeholders from tree entries

    Cannot be combined with :long, :name_only, or :object_only.

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (ArgumentError)

    if the tree-ish operand is missing

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/ls_tree.rb', line 60