Class: Git::Commands::Repack Private

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

Wrapper for the git repack command

Packs unpacked objects in a repository into pack files, and can reorganize existing packs into a single, more efficient pack. Running git repack -a -d is the most common usage: pack all objects and delete redundant packs.

Examples:

Pack all objects and delete redundant packs

repack = Git::Commands::Repack.new(execution_context)
repack.call(a: true, d: true)

Pack all objects with bitmap index

repack = Git::Commands::Repack.new(execution_context)
repack.call(a: true, d: true, write_bitmap_index: true)

Control delta compression performance

repack = Git::Commands::Repack.new(execution_context)
repack.call(a: true, d: true, window: 250, depth: 50)

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 repack command

Parameters:

  • options (Hash)

    command options

Options Hash (**options):

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

    pack all objects into a single pack

    When true, passes -a. Especially useful when packing a repository used for private development. Use with :d to clean up objects.

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

    pack all objects, loosening unreachable objects when combined with :d

    When true, passes -A. Like :a, but any unreachable objects in a previous pack become loose unpacked objects instead of being removed. The loose unreachable objects are pruned by the next git gc invocation.

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

    delete redundant packs after repacking

    When true, passes -d. After packing, removes any existing packs that are made redundant by the newly created pack. Also runs git prune-packed.

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

    pack unreachable objects into a separate cruft pack when combined with :d

    When true, passes --cruft. Like :a, but any unreachable objects are packed into a separate cruft pack instead of being removed. Incompatible with :keep_unreachable.

  • :cruft_expiration (String) — default: nil

    expire cruft objects older than the given date immediately

    Passed as --cruft-expiration=<approxidate>. Only useful with --cruft -d.

  • :max_cruft_size (Integer, String) — default: nil

    override --max-pack-size for cruft packs

    Passed as --max-cruft-size=<n>. Accepts size suffixes (k, m, g). Inherits the value of :max_pack_size by default.

  • :combine_cruft_below_size (Integer, String) — default: nil

    only repack cruft packs strictly smaller than this size

    Passed as --combine-cruft-below-size=<n>. Accepts size suffixes (k, m, g). Useful to avoid repacking large cruft packs.

  • :expire_to (String) — default: nil

    write pruned cruft objects to a directory

    Passed as --expire-to=<dir>. Only useful with --cruft -d.

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

    pass --local to git pack-objects

    When true, passes -l. Ignores objects that come from an alternates object store.

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

    pass --no-reuse-delta to git pack-objects

    When true, passes -f. Forces reconstruction of all pack deltas.

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

    pass --no-reuse-object to git pack-objects

    When true, passes -F. Forces reconstruction of all object data, not just deltas.

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

    suppress progress reporting

    When true, passes --quiet.

    Alias: :q

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

    do not update server information

    When true, passes -n. Skips running git update-server-info, which updates local catalog files needed to publish the repository over HTTP or FTP.

  • :window (Integer, String) — default: nil

    number of previous objects used to generate delta compressions

    Passed as --window=<n> to git pack-objects.

  • :depth (Integer, String) — default: nil

    maximum delta depth

    Passed as --depth=<n> to git pack-objects.

  • :threads (Integer, String) — default: nil

    number of threads for delta search

    Passed as --threads=<n> to git pack-objects.

  • :window_memory (Integer, String) — default: nil

    maximum memory usage for delta window

    Passed as --window-memory=<n> to git pack-objects. Accepts size suffixes (k, m, g).

  • :max_pack_size (Integer, String) — default: nil

    maximum size of each output pack file

    Passed as --max-pack-size=<n>. Accepts size suffixes (k, m, g).

  • :filter (String) — default: nil

    remove objects matching the filter specification from the resulting packfile

    Passed as --filter=<filter-spec>. Filtered objects are placed in a separate packfile. Best used with -a -d and in a bare repository.

  • :filter_to (String) — default: nil

    write the pack containing filtered objects to a directory

    Passed as --filter-to=<dir>. Only useful with :filter.

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

    write a reachability bitmap index as part of the repack

    When true, passes --write-bitmap-index. Only meaningful when used with :a, :A, or :write_midx. Overrides repack.writeBitmaps.

    Alias: :b

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

    include objects in .keep files when repacking

    When true, passes --pack-kept-objects. Generally only useful when writing bitmaps with :write_bitmap_index.

  • :keep_pack (String, Array<String>) — default: nil

    exclude named pack(s) from repacking

    Pass a pack file name (without leading directory, e.g. 'pack-abc123.pack') or an array of pack file names. Each value is passed as a separate --keep-pack=<name> argument.

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

    write a multi-pack index containing the non-redundant packs

    When true, passes --write-midx.

    Alias: :m

  • :unpack_unreachable (String) — default: nil

    do not loosen unreachable objects older than the given date

    Passed as --unpack-unreachable=<when>. Objects older than the given date are not loosened, since they would be immediately pruned by a follow-up git prune.

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

    keep unreachable objects in the new packfile rather than removing them

    When true, passes --keep-unreachable. Appends unreachable objects from existing packs to the end of the new packfile. For use with -ad.

    Alias: :k

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

    pass --delta-islands to git pack-objects

    When true, passes --delta-islands.

    Alias: :i

  • :geometric (Integer, String) — default: nil

    arrange pack structure so each successive pack contains at least this many times the objects of the next-largest pack

    Passed as --geometric=<factor>.

    Alias: :g

  • :name_hash_version (Integer, String) — default: nil

    pass --name-hash-version=<n> to git pack-objects

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

    pass --path-walk to git pack-objects

Returns:

Raises:

  • (ArgumentError)

    if unsupported options are provided

  • (Git::FailedError)

    if git exits with a non-zero exit status



# File 'lib/git/commands/repack.rb', line 87