Class: Git::Commands::Gc Private

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

Implements the git gc command

Runs a number of housekeeping tasks within the current repository, such as compressing file revisions (to reduce disk space and increase performance), removing unreachable objects, packing refs, pruning reflog, rerere metadata or stale working trees.

Examples:

Typical usage

gc = Git::Commands::Gc.new(execution_context)
gc.call
gc.call(auto: true)
gc.call(aggressive: true, prune: 'now')

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

Execute the git gc command

Parameters:

  • options (Hash)

    command options

Options Hash (**options):

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

    be more thorough at the expense of increased runtime

    When true, git gc runs more aggressively to optimize the repository. The effects are mostly persistent.

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

    check whether housekeeping is required before performing any work

    When true, git gc checks whether housekeeping is needed; if not, it exits without doing anything.

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

    run in the background if the system supports it (--detach)

    Overrides the gc.autoDetach configuration.

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

    run in the foreground (--no-detach)

    Overrides the gc.autoDetach configuration.

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

    pack unreachable objects into a cruft pack instead of storing them as loose objects (--cruft)

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

    do not create a cruft pack; store unreachable objects as loose objects (--no-cruft)

  • :max_cruft_size (String) — default: nil

    limit the size of new cruft packs to at most <n> bytes when packing unreachable objects

    Overrides any value specified via gc.maxCruftSize configuration. Maps to --max-cruft-size=<n>.

  • :expire_to (String) — default: nil

    write a cruft pack containing pruned objects (if any) to the given directory

    Only has an effect when used together with :cruft. Maps to --expire-to=<dir>.

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

    prune loose objects older than the given date (--prune, --prune=<date>)

    When true, passes --prune (uses git's default expiry of 2 weeks ago). When a String, passes --prune=<date>.

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

    do not prune any loose objects (--no-prune)

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

    suppress all progress reports

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

    force running gc even if another gc instance may be running on this repository

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

    repack all packs except the largest non-cruft pack and those marked with a .keep file

    When true, gc.bigPackThreshold is ignored.

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/gc.rb', line 56