debian/0000755000000000000000000000000012203063746007171 5ustar debian/clean0000644000000000000000000000001312203063746010170 0ustar debian/*.1 debian/pod2man.mk0000644000000000000000000000332112203063746011061 0ustar # pod2man.mk -- Makefile portion to convert *.pod files to manual pages # # Copyright information # # Copyright (C) 2008-2013 Jari Aalto # # License # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Description # # Convert *.pod files to manual pages. Write this to 'install' # target: # # install: build $(MANPAGE) ifneq (,) This makefile requires GNU Make. endif # This variable *must* be set when calling PACKAGE ?= package RELEASE ?= $(PACKAGE) # Optional variables to set MANSECT ?= 1 PODCENTER ?= $$(date "+%Y-%m-%d") # Directories MANSRC = MANDEST = $(MANSRC) MANPOD = $(MANSRC)$(PACKAGE).$(MANSECT).pod MANPAGE = $(MANDEST)$(PACKAGE).$(MANSECT) POD2MAN = pod2man POD2MAN_FLAGS = --utf8 makeman: $(MANPAGE) $(MANPAGE): $(MANPOD) # make target - create manual page from a *.pod page podchecker $(MANPOD) LC_ALL=C $(POD2MAN) $(POD2MAN_FLAGS) \ --center="$(PODCENTER)" \ --name="$(PACKAGE)" \ --section="$(MANSECT)" \ --release="$(RELEASE)" \ $(MANPOD) \ > $(MANPAGE) && \ rm -f pod*.tmp # End of of Makefile part debian/watch0000644000000000000000000000015312203063746010221 0ustar version=3 # There is no version "tag". Just plain code. See debian/copyright and # Download code manually. debian/rules0000755000000000000000000000041112203063746010245 0ustar #!/usr/bin/make -f PACKAGE = splitpatch man: $(MAKE) -C debian -f pod2man.mk PACKAGE=$(PACKAGE) makeman override_dh_installman: man dh_installman override_dh_auto_install: install -D -m 755 *.rb debian/$(PACKAGE)/usr/bin/splitpatch %: dh $@ # End of file debian/changelog0000644000000000000000000000025512203063746011045 0ustar splitpatch (0.0+20130626+gitbd6a83d-1) unstable; urgency=low * Initial release (Closes: #711935). -- Jari Aalto Sun, 11 Aug 2013 10:56:37 +0300 debian/patches/0000755000000000000000000000000012203063746010620 5ustar debian/patches/10-zero-filename.patch0000644000000000000000000000422512203063746014617 0ustar From: Jari Aalto Subject: Use 3 digit NNN in output files Use dash(-), not dot(.) in file names. Use zero based file names. Format: FILENAME-NNN.patch for hunks and FILENAME.patch-NNN for regular files (if file already exists). --- splitpatch.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) --- a/splitpatch.rb +++ b/splitpatch.rb @@ -1,4 +1,4 @@ -#!/usr/local/bin/ruby +#!/usr/bin/env ruby # # splitpatch is a simple script to split a patch up into multiple patch files. # if the --hunks option is provided on the command line, each hunk gets its @@ -51,10 +51,11 @@ if File.exists?(filename) puts "File #{filename} already exists. Renaming patch." appendix = 0 - while File.exists?("#{filename}.#{appendix}") + zero = appendix.to_s.rjust(3, '0') + while File.exists?("#{filename}-#{zero}") appendix += 1 end - filename << ".#{appendix}" + filename << "-#{zero}" end outfile = open(filename, "w") outfile.write(line) @@ -91,14 +92,16 @@ if (outfile) outfile.close_write end - hunkfilename = "#{filename}.#{counter}.patch" + zero = counter.to_s.rjust(3, '0') + hunkfilename = "#{filename}-#{zero}.patch" if File.exists?(hunkfilename) puts "File #{hunkfilename} already exists. Renaming patch." appendix = 0 - while File.exists?("#{hunkfilename}.#{appendix}") + zero = appendix.to_s.rjust(3, '0') + while File.exists?("#{hunkfilename}-#{zero}") appendix += 1 end - hunkfilename << ".#{appendix}" + hunkfilename << "-#{zero}" end outfile = open(hunkfilename, "w") counter += 1 @@ -141,5 +144,4 @@ end end - - +# End of file debian/patches/series0000644000000000000000000000005012203063746012030 0ustar 10-zero-filename.patch 20-options.patch debian/patches/20-options.patch0000644000000000000000000000500112203063746013547 0ustar From: Jari Aalto Subject: Add options --help, --version and short option -H for hunks --- splitpatch.rb | 61 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 11 deletions(-) --- a/splitpatch.rb +++ b/splitpatch.rb @@ -21,6 +21,12 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # + +PROGRAM = "splitpatch" +VERSION = 0.0 +LICENSE = "GPL-2+" # See official acronyms: https://spdx.org/licenses/ +AUTHOR = "Peter Hutterer " + class Splitter def initialize(file) @filename = file @@ -118,29 +124,62 @@ end +def help + puts < 2 - puts "Wrong parameter. Usage: splitpatch.rb [--hunks] " - exit 1 -elsif ARGV[0] == "--help" - puts "splitpatch splits a patch that is supposed to patch multiple files" - puts "into a set of patches." - puts "Currently splits unified diff patches." - puts "If the --hunk option is given, a new file is created for each hunk." + puts "ERROR: missing argument. See --help." exit 1 else - s = Splitter.new(ARGV[-1]) + opt = ARGV[0] + if /^-h$|--help/.match(opt) + help + exit 0 + elsif /^-H$|--hunks?/.match(opt) + hunk = 1 + elsif /^-V$|--version/.match(opt) + version + exit 0 + elsif /^-/.match(opt) + puts "ERROR: Unknonw option: #{opt}. See --help." + exit 1 + end + file = ARGV[-1] + s = Splitter.new(file) if s.validFile? - if ARGV[0] == "--hunks" + if hunk s.splitByHunk else s.splitByFile end else - puts "File does not exist or is not readable" + puts "File does not exist or is not readable: #{file}" end end debian/docs0000644000000000000000000000001212203063746010035 0ustar README.md debian/source/0000755000000000000000000000000012203063746010471 5ustar debian/source/format0000644000000000000000000000001412203063746011677 0ustar 3.0 (quilt) debian/compat0000644000000000000000000000000212203063746010367 0ustar 9 debian/copyright0000644000000000000000000000240512203063746011125 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0 Upstream-Name: splitpatch Upstream-Contact: Source: http://www.clearchain.com/blog/posts/splitting-a-patch X-Upstream-Vcs: https://github.com/benjsc/splitpatch Comment: The maintainer of homepage and Git repo is Files: * Copyright: 2007 Peter Hutterer License: GPL-2+ Files: debian/* Copyright: 2013 Jari Aalto License: GPL-2+ License: GPL-2+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see . . On Debian systems, the complete text of the GNU General Public License can be found in "/usr/share/common-licenses/GPL-2". debian/splitpatch.1.pod0000644000000000000000000000665712203063746012225 0ustar # Copyright # # Copyright (C) 2013 Jari Aalto # # License # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Description # # To learn what TOP LEVEL sections to use in manual page, # see POSIX/Susv standard about "Utility Description Defaults" at # http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap01.html#tag_01_11 # # This manual page in Perl POD format. Read more at # http://perldoc.perl.org/perlpod.html or run command: # # perldoc perlpod | less # # To check the syntax: # # podchecker *.pod # # To create manual: # # pod2man PROGRAM.N.pod > PROGRAM.N =pod =head1 NAME splitpatch - split a patch up into files or hunks =head1 SYNOPSIS splitpatch [options] =head1 DESCRIPTION Divide a patch or diff file into pieces. The split can made by file or by hunk basis. This makes is possible to separate changes that might not be desirable, or assemble a patch into more coherent set of changes. The hunk option makes it possible to compare similar patches on a hunk-by-hunk basis using a tool like interdiff(1) from the patchutils package. =head1 OPTIONS =over 4 =item B<-H, --hunk, --hunks> Split patch by hunks instead of the default: by file. =item B<-h, --help> Display help and exit =item B<-V, --version> Output version information and exit. =back =head1 EXAMPLES Have you ever been working on code, gone off on a side tangent and then realized you don't have a patch for the original issue you set out to address? When you run C or some other diff command, you discover that you have made multiple sets of changes; some you want to submit, others you don't. What you really want to do is break those changes apart and apply only the ones you want. This is where splitpatch comes into play, breaking up the patch by source file: splitpatch changes.patch Or to split the patch file into individual hunks which can later be applied using the patch(1) command: splitpatch --hunks changes.patch =head1 ENVIRONMENT None. =head1 FILES The B<--hunk> option writes sequentially numbered files in the current directory named for the source file to be patched followed by the sequence number: C<*-NNN.patch>. Otherwise, the split patch files are named by the source file being patched. =head1 STANDARDS None. =head1 AVAILABILITY https://github.com/benjsc/splitpatch =head1 SEE ALSO dehtmldiff(1) editdiff(1) filterdiff(1) fixcvsdiff(1) flipdiff(1) grepdiff(1) interdiff(1) lsdiff(1) patch(1) recountdiff(1) rediff(1) splitdiff(1) unwrapdiff(1) wiggle(1) =head1 AUTHORS Program was written by Peter Hutterer . This manual page was written by Jari Aalto . Released under license GNU GPL version 2 or (at your option) any later version. For more information about the license, visit . =cut debian/manpages0000644000000000000000000000001312203063746010701 0ustar debian/*.1 debian/control0000644000000000000000000000170312203063746010575 0ustar Source: splitpatch Section: text Priority: optional Maintainer: Jari Aalto Build-Depends: debhelper (>= 9) Standards-Version: 3.9.4 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/debian.git Vcs-Git: git://anonscm.debian.org/collab-maint/debian.git Homepage: http://www.clearchain.com/blog/posts/splitting-a-patch Package: splitpatch Architecture: all Depends: ${misc:Depends}, ruby Description: split the patch up into files or hunks Divide a patch or diff file into pieces. The split can made by file or by hunk basis. This makes is possible to separate changes that might not be desireable or assemble the patch into more coherent set of changes. . The hunk option opens up possibility to compare similar patches hunk-by-hunk using tool like interdiff(1) from patchutils package. Operating on hunk level also gives more control, smilar to Git, to selectively shelve in changes e.g. to Version Control repository.