Skip to main content

✂️ Split git patch files ✂️

Project description

✂️ psplit: Split git patch files ✂️

Usage

psplit [-h. --help]
       [-c, --clean]
       [-d, --directory DIRECTORY]
       [-h, --hunks HUNKS]
       [-j, --join-character JOIN_CHARACTER]
       [-p, --parts PARTS]
       [files ...]

Positional arguments

  files                 Files to split (or split stdin if no files)

Optional arguments

  -h, --help            show this help message and exit
  --clean               Clean --directory of patch files
  --directory DIRECTORY, -d DIRECTORY
                        Output to this directory (create if needed)
  --hunks HUNKS, -u HUNKS
                        Split into parts containing this many hunks
  --join-character JOIN_CHARACTER, -j JOIN_CHARACTER
                        The character to replace / in filenames
  --parts PARTS, -p PARTS
                        Split into this many parts

How it works

psplit is a utility to split large git patch files. It is a single file with no dependencies except Python 3.9 or greater.

psplit splits its inputs by file, then each file is split into one or more patches. Each output patch file gets a unique name derived from the underlying file name.

To avoid clutter, use the --directory/-d flag, which creates a subdirectory if needed and puts the new patches in it.

If you set --parts/-p, psplit will split each file into that many parts: each file gets the same number of parts.

If you set --hunks/-u, psplit will split each file into parts containing that many hunks: larger files will get more parts.

(A hunk is a small, self-contained delta for a single text file. A patch contains zero or more files, each file containing one or more hunks.)

If neither flag is set, psplit will use the square root of the number of hunks in the file, the geometric median between all the hunks in one part and one hunk per part.

Example

$ g diff HEAD~ | psplit -d patches
Creating patches/
Writing patches/tools-linter-adapters-_linter.py.patch
Writing patches/tools-linter-adapters-_linter-__init__.py.patch
Writing patches/tools-linter-adapters-_linter-argument_parser.py.patch
Writing patches/tools-linter-adapters-_linter-block.py.patch
Writing patches/tools-linter-adapters-_linter-blocks.py.patch
Writing patches/tools-linter-adapters-_linter-bracket_pairs.py.patch
Writing patches/tools-linter-adapters-_linter-file_linter.py.patch
Writing patches/tools-linter-adapters-_linter-file_summary.py.patch
Writing patches/tools-linter-adapters-_linter-messages.py.patch
Writing patches/tools-linter-adapters-_linter-python_file.py.patch
Writing patches/tools-linter-adapters-_linter-sets.py.patch
Writing patches/tools-linter-adapters-docstring_linter.py-1.patch
Writing patches/tools-linter-adapters-docstring_linter.py-2.patch
Writing patches/tools-linter-adapters-docstring_linter.py-3.patch
Writing patches/tools-linter-adapters-set_linter.py-1.patch
Writing patches/tools-linter-adapters-set_linter.py-2.patch
Writing patches/tools-test-test_docstring_linter.py.patch

How to install

Either use pip: python -m pip install psplit. Or simply download the file psplit.py and put it into your path.

Other alternatives

https://manpages.ubuntu.com/manpages/xenial/man1/splitpatch.1.html didn't work well for large files and isn't available on Mac OS

https://pypi.org/project/splitpatch/ is complicated and very new

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psplit-1.1.0.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

psplit-1.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file psplit-1.1.0.tar.gz.

File metadata

  • Download URL: psplit-1.1.0.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for psplit-1.1.0.tar.gz
Algorithm Hash digest
SHA256 8bbfe6a14bf4807a332334d4f1215696e4ced1b6cb5897500917d6e8a8ca9226
MD5 2bf3d402ea90c5f9747a8b7d28423c2d
BLAKE2b-256 5f64ace51f723777ac7d7932fce9c53aa70f49b8b917c2a636041a0fa6485676

See more details on using hashes here.

File details

Details for the file psplit-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: psplit-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for psplit-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e96a690c1154785d59a34af5341d8f7a4f44c026c840dd405556a9c3f50ff89
MD5 98e1aca5ab24505cdb61a92a79901122
BLAKE2b-256 f6f16d292bb1d26903e37111f9280f8104fe077c875050d84a385dcf7543b223

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page