Skip to content

Add opt-in UPX clean/smudge filters - #69

Merged
dscho merged 1 commit into
mainfrom
upx-filter
Nov 4, 2026
Merged

dscho merged 1 commit into
mainfrom
upx-filter

Conversation

@mjcheetham

@mjcheetham mjcheetham commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Add opt-in clean/smudge filtering for large DLLs. Git stores UPX-packed binaries, while users can choose unpacked working-tree files to avoid decompression at startup.

Packed binaries remain runnable, so ordinary clones work without filter configuration or special checkout steps.

Usage

After checkout:

bash ./.large-dll-filter.sh setup

For configuration only, without unpacking existing files:

bash ./.large-dll-filter.sh setup --no-refresh

Help is available with --help, -h, or -?.

Revised design

Following review, filtering and setup share one hidden script, .large-dll-filter.sh, with clean, smudge, and setup modes.

The script prepends the checkout's UCRT64 and clangarm64 bin directories to PATH. Setup configures repository-local filters and directly unpacks existing attributed files. It does not replace files from the index or require transactional conversion: partially unpacked checkouts work too.

Clean/smudge retain private temporary files to bridge Git's streams to UPX's file interface. Packing uses --exact to preserve original bytes. The local driver is required so failed clean operations cannot silently stage unpacked binaries.

No filter attributes are introduced here. Selecting Rust's LLVM DLLs and configuring package-update automation are separate follow-ups.

Validation

Tested with packaged x64 UPX in both SDK directory layouts: lossless round trips, stable staging, repeated setup, configuration-only setup, Unicode and spaced paths, missing files, preservation of local working-file edits, and filter failure handling.

The script is identical across both SDK repositories. Native ARM64 execution has not been tested locally.

@mjcheetham

Copy link
Copy Markdown
Member Author

x86_64 counterpart PR: git-for-windows#136

Large DLLs can exceed remote file-size limits. UPX-packed binaries
remain runnable without filter configuration, at the cost of startup
decompression. Provide opt-in local filtering so users can trade disk
space for avoiding that repeated cost while Git keeps compressed blobs.

Provide clean, smudge, and setup modes in .large-dll-filter.sh. Prefer
the checkout's ucrt64/bin and clangarm64/bin on PATH so the same script
works in both SDKs and from a regular Git Bash.

After checkout, enable filtering and unpack existing attributed files:

    bash ./.large-dll-filter.sh setup

Use setup --no-refresh in package-update automation to configure the
driver without rewriting working-tree files. Setup installs these
repository-local values:

    filter.upx.clean = bash ./.large-dll-filter.sh clean
    filter.upx.smudge = bash ./.large-dll-filter.sh smudge
    filter.upx.required = true

Require successful filtering to avoid silently staging unpacked blobs
when clean fails. Attribute selection remains separate from setup.

Unpack existing packed files directly in the working tree, leaving the
index unchanged. Partial optimization is harmless, since both forms
work. Skip absent files, symlinks, and files not recognized as packed.
Disable Git's filename quoting when enumerating Windows paths so
spaces and Unicode names are preserved.

Use private temporary files for stream conversion, where UPX's file
interface requires them, and --exact to preserve original bytes.
Help is available with --help, -h, or -?.

Assisted-by: GPT-6.1 Sol
Signed-off-by: Matthew John Cheetham <[email protected]>

@dscho dscho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@dscho
dscho merged commit fbe0a2a into main Nov 4, 2026
22 checks passed
@dscho
dscho deleted the upx-filter branch November 4, 2026 14:05
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