Skip to content

repack: write filtered-out objects as loose objects - #2312

Closed
achakilam-nv wants to merge 2 commits into
gitgitgadget:masterfrom
achakilam-nv:patch-preview
Closed

achakilam-nv wants to merge 2 commits into
gitgitgadget:masterfrom
achakilam-nv:patch-preview

Conversation

@achakilam-nv

@achakilam-nv achakilam-nv commented Nov 13, 2026 •

Copy link
Copy Markdown

Some key-value object stores manage and retrieve Git objects
individually. The existing --filter-to option writes filtered-out
objects into packs, so using it with such stores requires unpacking
the resulting packs before importing the objects.

This series adds --filter-to-loose=dir to git repack, allowing
filtered-out objects to be written directly as loose objects into
another object directory.

With --filter-to-loose, repack streams the filtered pack into
unpack-objects, avoiding that extra step and the intermediate pack
file. For example:

git repack -a --filter=blob=1m --filter-to-loose=/path/to/objects

The destination is treated as a Git object directory.

The first patch adds the option for objects already stored in packs.
The second extends it to include loose objects excluded by the
filter, so the destination also receives those objects. Objects
already present in the destination are not rewritten. With -d,
the source copies of those loose objects are removed after all
objects have been written successfully.

cc: Martin Fick mfick@nvidia.com

@achakilam-nv

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 13, 2026

Copy link
Copy Markdown

Error: User achakilam-nv is not yet permitted to use GitGitGadget

@achakilam-nv

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 13, 2026

Copy link
Copy Markdown

Error: User achakilam-nv is not yet permitted to use GitGitGadget

@sluongng

Copy link
Copy Markdown

/allow

@gitgitgadget

gitgitgadget Bot commented Nov 13, 2026

Copy link
Copy Markdown

User achakilam-nv is now allowed to use GitGitGadget.

WARNING: achakilam-nv has no public email address set on GitHub; GitGitGadget needs an email address to Cc: you on your contribution, so that you receive any feedback on the Git mailing list. Go to https://github.com/settings/profile to make your preferred email public to let GitGitGadget know which email address to use.

@achakilam-nv

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 13, 2026

Copy link
Copy Markdown

Error: Could not determine full name of achakilam-nv

@achakilam-nv

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 13, 2026

Copy link
Copy Markdown

Preview email sent as pull.2312.git.1794530326.gitgitgadget@gmail.com

@achakilam-nv

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 13, 2026

Copy link
Copy Markdown

Preview email sent as pull.2312.git.1794532793.gitgitgadget@gmail.com

@achakilam-nv

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 13, 2026

Copy link
Copy Markdown

Preview email sent as pull.2312.git.1794533604.gitgitgadget@gmail.com

@achakilam-nv

Copy link
Copy Markdown
Author

/preview

@gitgitgadget

gitgitgadget Bot commented Nov 13, 2026

Copy link
Copy Markdown

Preview email sent as pull.2312.git.1794604618.gitgitgadget@gmail.com

…objects

Some external object stores (like key-value) manage and retrieve git
objects individually. Although repack's --filter-to option can separate
objects from the main object store, it writes them into packs. Using
those objects individually then requires an additional unpacking step.

Add --filter-to-loose=<dir> to write filtered-out objects directly as
loose objects into <dir>, treating it as an object directory. Stream
the filtered pack into unpack-objects instead of writing an intermediate
pack file to disk.

The filtered pack is built with --stdin-packs, so this initially handles
only objects already stored in packs. Loose objects in the source
repository are left in place.

Signed-off-by: Adithya Chakilam <achakilam@nvidia.com>
--filter-to-loose only writes objects that were in an existing pack,
because the filtered pack is built with --stdin-packs. Loose objects
that the filter excludes stay behind in the source repository, so the
destination does not get the complete set of filtered-out objects.

Copy such loose objects to the destination as well. An object already
present in the destination is not rewritten. With -d, the source copies
are removed once everything is written.

Signed-off-by: Adithya Chakilam <achakilam@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants