Class: Git::Commands::ShowRef::List Private

Inherits:
Base
  • Object
show all
Defined in:
lib/git/commands/show_ref/list.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-show-ref/2.53.0

Standard ref listing command via git show-ref

Lists refs stored in the local repository together with their associated commit IDs. When no filters are given, all refs are listed. Filters can narrow output to heads, tags, or refs matching a given pattern.

An exit status of 1 is not an error — it indicates that no matching refs were found. Exit status 0 means at least one match was found.

For strict per-ref verification, use Verify. For stdin-based filtering, use ExcludeExisting. For a simple boolean existence check (git >= 2.43), use Exists.

Examples:

List all refs

cmd = Git::Commands::ShowRef::List.new(execution_context)
result = cmd.call
result.stdout  # => "abc1234 refs/heads/main\n..."

List only tags

cmd = Git::Commands::ShowRef::List.new(execution_context)
result = cmd.call(tags: true)

List with abbreviated SHA hashes

cmd = Git::Commands::ShowRef::List.new(execution_context)
result = cmd.call(hash: 7)

Match a pattern

cmd = Git::Commands::ShowRef::List.new(execution_context)
result = cmd.call('v1.0', 'v2.0', tags: true)

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(*pattern, **options) ⇒ Git::CommandLineResult

Execute git show-ref to list matching refs

Parameters:

  • pattern (Array<String>)

    zero or more patterns to filter refs

    When empty, all refs are listed.

  • options (Hash)

    command options

Options Hash (**options):

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

    show the HEAD ref even when filtered

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

    dereference annotated tags, emitting an extra line per tag whose SHA points to the tagged object

    Alias: :d

  • :hash (Boolean, Integer, nil) — default: nil

    show only the SHA part of each ref

    Pass true for full-length SHAs or an integer for the abbreviation length (e.g. hash: 7).

    Alias: :s

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

    abbreviate object names

    Pass true for the default length or an integer for a specific length.

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

    limit output to local branches (refs/heads/)

    Prefer :branches over :heads on git >= 2.46; :heads emits the deprecated --heads flag.

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

    limit output to refs under refs/heads/

    Deprecated at the git level in git 2.46. Use :branches instead.

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

    limit output to refs under refs/tags/

  • :timeout (Numeric) — default: nil

    abort the command after this many seconds

Returns:

Raises:



# File 'lib/git/commands/show_ref/list.rb', line 95