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.2.0.tar.gz (36.9 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.2.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: psplit-1.2.0.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.2.0.tar.gz
Algorithm Hash digest
SHA256 30ce3f877a54704349a6ae6d94610d6cf4dc325199a2fd9efcbbe2799868d0f2
MD5 d33db8275f1f566f1507af73702e5d63
BLAKE2b-256 091df14fb63cb76710bc9a198e16c36113ac155670d93e00cc5252c202ed58c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psplit-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4efd3e6b0d962f786d938818f068d2a5804bab19be5cd031dd70a96b577e0b1
MD5 10c623ae9c8360440b4eccea50f5d7de
BLAKE2b-256 742664c144fc34850d683a2aa9811bf870b740734daa8abe6f962717c191af45

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