pax_global_header00006660000000000000000000000064127543766120014527gustar00rootroot0000000000000052 comment=13c59419db16c9413f7e339608903fd95589c3af splitpatch-1.0+20160815+git13c5941/000077500000000000000000000000001275437661200160555ustar00rootroot00000000000000splitpatch-1.0+20160815+git13c5941/.gitignore000066400000000000000000000000111275437661200200350ustar00rootroot00000000000000*.patch* splitpatch-1.0+20160815+git13c5941/Makefile000077500000000000000000000035561275437661200175310ustar00rootroot00000000000000#!/usr/bin/make -f # # Copyright # # Copyright (C) 2014 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 # # A Ruby program. Nothing to compile ifneq (,) This makefile requires GNU Make. endif PACKAGE = splitpatch VERSION = DESTDIR = prefix = /usr exec_prefix = $(prefix) man_prefix = $(prefix)/share mandir = $(man_prefix)/man bindir = $(exec_prefix)/bin sharedir = $(prefix)/share BINDIR = $(DESTDIR)$(bindir) DOCDIR = $(DESTDIR)$(sharedir)/doc # 1 = regular, 5 = conf, 6 = games, 8 = daemons MANDIR = $(DESTDIR)$(mandir) MANDIR1 = $(MANDIR)/man1 INSTALL = /usr/bin/install INSTALL_BIN = $(INSTALL) -m 755 INSTALL_DATA = $(INSTALL) -m 644 INSTALL_SUID = $(INSTALL) -m 4755 SRCS = $(PACKAGE).rb all: doc clean: # clean -rm -f *[#~] *.\#* $(MAKE) -C man $@ distclean: clean realclean: clean doc: $(MAKE) -C man all install-man: doc # install-man $(INSTALL_BIN) -d $(MANDIR1) $(INSTALL_DATA) man/*.1 $(MANDIR1) install-bin: # install-bin $(INSTALL_BIN) -d $(BINDIR) $(INSTALL_BIN) $(PACKAGE).rb $(BINDIR)/$(PACKAGE) install: install-bin install-man .PHONY: all doc .PHONY: clean distclean realclean install install-bin install-man # End of file splitpatch-1.0+20160815+git13c5941/README.md000066400000000000000000000006171275437661200173400ustar00rootroot00000000000000splitpatch ========== A utility to split a diff patch into separate sections For full details on how to use the utility see: http://www.clearchain.com/blog/posts/splitting-a-patch Upstream sources maintained at: https://github.com/jaalto/splitpatch Team upstream: Maintainer Original Developer Original Developer splitpatch-1.0+20160815+git13c5941/man/000077500000000000000000000000001275437661200166305ustar00rootroot00000000000000splitpatch-1.0+20160815+git13c5941/man/Makefile000077500000000000000000000017421275437661200202770ustar00rootroot00000000000000#!/usr/bin/make -f # # Copyright # # Copyright (C) 2014 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 # # Generate manual page form Perl POD file. PACKAGE = splitpatch all: $(MAKE) -f pod2man.mk PACKAGE=$(PACKAGE) makeman clean: rm -f *.1 .PHONY: all # End of file splitpatch-1.0+20160815+git13c5941/man/pod2man.mk000066400000000000000000000033211275437661200205200ustar00rootroot00000000000000# 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 splitpatch-1.0+20160815+git13c5941/man/splitpatch.1.pod000066400000000000000000000070321275437661200216500ustar00rootroot00000000000000# Copyright # # Copyright (C) 2013-2014 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 , Benjamin Close . Enhancements by Jari Aalto . 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 splitpatch-1.0+20160815+git13c5941/splitpatch.rb000077500000000000000000000150021275437661200205560ustar00rootroot00000000000000#!/usr/bin/env ruby # # Copyright # # Copyright (C) 2014 Jari Aalto # Copyright (C) 2007-2014 Peter Hutterer # Copyright (C) 2007-2014 Benjamin Close # # 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 # PROGRAM = "splitpatch" MYVERSION = 1.0 LICENSE = "GPL-2+" # See official acronyms: https://spdx.org/licenses/ HOMEPAGE = "https://github.com/jaalto/splitpatch" # 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 own patchfile. class Splitter def initialize(file) @filename = file @fullname = false end def fullname(opt) @fullname = opt end def validFile? return File.exist?(@filename) && File.readable?(@filename) end def createFile(filename) if File.exists?(filename) puts "File #{filename} already exists. Renaming patch." appendix = 0 zero = appendix.to_s.rjust(3, '0') while File.exists?("#{filename}.#{zero}") appendix += 1 zero = appendix.to_s.rjust(3, '0') end filename << ".#{zero}" end return open(filename, "w") end def getFilename(line) tokens = line.split(" ") tokens = tokens[1].split(":") tokens = tokens[0].split("/") if @fullname return tokens.join('-') else return tokens[-1] end end # Split the patchfile by files def splitByFile legacy = false outfile = nil stream = open(@filename, 'rb') until (stream.eof?) line = stream.readline # we need to create a new file if (line =~ /^Index: .*/) == 0 # patch includes Index lines # drop into "legacy mode" legacy = true if (outfile) outfile.close_write end filename = getFilename(line) filename << ".patch" outfile = createFile(filename) outfile.write(line) elsif (line =~ /--- .*/) == 0 and not legacy if (outfile) outfile.close_write end #find filename filename = getFilename(line) filename << ".patch" outfile = createFile(filename) outfile.write(line) else if outfile outfile.write(line) end end end end def splitByHunk legacy = false outfile = nil stream = open(@filename, 'rb') filename = "" counter = 0 header = "" until (stream.eof?) line = stream.readline # we need to create a new file if (line =~ /^Index: .*/) == 0 # patch includes Index lines # drop into "legacy mode" legacy = true filename = getFilename(line) header = line # remaining 3 lines of header for i in 0..2 line = stream.readline header << line end counter = 0 elsif (line =~ /--- .*/) == 0 and not legacy #find filename filename = getFilename(line) header = line # next line is header too line = stream.readline header << line counter = 0 elsif (line =~ /@@ .* @@/) == 0 if (outfile) outfile.close_write end zero = counter.to_s.rjust(3, '0') hunkfilename = "#{filename}.#{zero}.patch" outfile = createFile(hunkfilename) counter += 1 outfile.write(header) outfile.write(line) else if outfile outfile.write(line) end end end end end def help puts < Benjamin Close (orig. Author) Jari Aalto (Maintainer) " Homepage: #{HOMEPAGE} EOF end def version puts "#{MYVERSION} #{LICENSE} #{HOMEPAGE}" end def parsedOptions if ARGV.length < 1 or ARGV.length > 2 puts "ERROR: missing argument. See --help." exit 1 end opts = {} opt = ARGV[0] case opt when /^-h$/, /--help/ opts[:help] = true when /^-H$/, /--hunks?/ opts[:hunk] = true when /^-V$/, /--version/ opts[:version] = true when /^-/ puts "ERROR: Unknown option: #{opt}. See --help." exit 1 end opts[:file] = ARGV[-1] return opts end def main opts = parsedOptions if opts[:help] help exit end if opts[:version] version exit end s = Splitter.new(opts[:file]) if !s.validFile? puts "File does not exist or is not readable: #{opts[:file]}" end if opts[:hunk] s.splitByHunk else s.splitByFile end end main # End of file