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.0.4.tar.gz (4.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.0.4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: psplit-1.0.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.11 Darwin/23.5.0

File hashes

Hashes for psplit-1.0.4.tar.gz
Algorithm Hash digest
SHA256 54e42d674914751627f56adff439ad0ea54da4a79814141376f6c8f153c99c17
MD5 85fc9de05148d8e319d22b900fffd52b
BLAKE2b-256 8c607f8e373a56606f3535b03cb92534f10cd688b8f9c7ad0abf940f624aea7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psplit-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.11 Darwin/23.5.0

File hashes

Hashes for psplit-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5e0ea06a2128b975d3358e41441cab70119ab53e652a8430240706d85ee5b723
MD5 174bad003fa9ed0864e614cf54ccbfe7
BLAKE2b-256 b838038bc8ecf8e7679d08bd3a1314b0bd1d9c5890783dd97f9af17b135c80aa

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