{"id":118,"date":"2008-11-13T23:37:50","date_gmt":"2008-11-13T14:07:50","guid":{"rendered":"http:\/\/www.clearchain.com\/blog\/?p=118"},"modified":"2013-06-26T13:44:42","modified_gmt":"2013-06-26T04:14:42","slug":"splitting-a-patch","status":"publish","type":"post","link":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch","title":{"rendered":"Splitting A Patch"},"content":{"rendered":"<p>Have you ever been working on code, gone off on a side tangent and then realized you don&#8217;t have a valid patch of the code you&#8217;ve been working on? So you run <code>diff -du, cvs diff, git diff<\/code> or some other diff and suddenly realize you have a mix of old changes and new changes. Some you want to submit, others you don&#8217;t. What you really want to do is break those changes apart and apply only the ones you want.<\/p>\n<p>Sadly, there is no tool to do that.. <em>until now!<\/em><\/p>\n<p><a name=\"SplitPatch.rb\"><\/a><\/p>\n<h2><span class=\"mw-headline\">SplitPatch.rb <\/span><\/h2>\n<p><a class=\"external text\" title=\"http:\/\/www.who-t.net\/\" href=\"http:\/\/www.who-t.net\/\" rel=\"nofollow\">Peter Hutterer<\/a>, whilst working at the <a class=\"external text\" title=\"http:\/\/wearables.unisa.edu.au\" href=\"http:\/\/wearables.unisa.edu.au\/\" rel=\"nofollow\">Wearable Computer Lab<\/a> at <a class=\"external text\" title=\"http:\/\/www.unisa.edu.au\/\" href=\"http:\/\/www.unisa.edu.au\/\" rel=\"nofollow\">University of South Australia<\/a> faced this very problem. So he wrote the program, <code>splitpatch<\/code>.<\/p>\n<p><code>splitpatch<\/code> will allow you to take a diff of a file and either:<\/p>\n<ul>\n<li>Split the patch up into change to the respective patched files<\/li>\n<li>Split the patch up into individual hunks, where each hunk can be applied separately<\/li>\n<\/ul>\n<p><a name=\"Usage\"><\/a><\/p>\n<h2><span class=\"mw-headline\"> Usage <\/span><\/h2>\n<p>To use splitpatch, you&#8217;ll need <a class=\"external text\" title=\"http:\/\/www.ruby-lang.org\" href=\"http:\/\/www.ruby-lang.org\/\" rel=\"nofollow\">ruby<\/a> installed. Then simply use:<\/p>\n<pre>splitpatch.rb YOURPATCHFILE<\/pre>\n<p>To split <code>YOURPATCHFILE<\/code> into a valid patch per file contained within the patch. Or<\/p>\n<pre>splitpatch.rb --hunks YOURPATCHFILE<\/pre>\n<p>To split the patch file into individual chunks which can be applied, using <code>patch<\/code><\/p>\n<p><a name=\"Download\"><\/a><\/p>\n<h2><span class=\"mw-headline\">Download <\/span><\/h2>\n<p>Splitpatch can be downloaded from:<\/p>\n<p><a class=\"external free\" title=\"http:\/\/github.com\/benjsc\/splitpatch\/\" href=\"http:\/\/github.com\/benjsc\/splitpatch\/\" rel=\"nofollow\">http:\/\/github.com\/benjsc\/splitpatch\/<\/a><\/p>\n<p><a name=\"Patch_File_Format\"><\/a><\/p>\n<h2><span class=\"mw-headline\"> Patch File Format <\/span><\/h2>\n<p>For those who don&#8217;t think <code>splitpatch<\/code> will do what they want, here&#8217;s at least some info about the format of a patch file.<\/p>\n<pre>@@ -143,6 +143,13 @@<\/pre>\n<ul>\n<li>the first number is the starting line for this hunk in oldfile<\/li>\n<li>the second number is the number of original source lines in this hunk (this includes lines marked with &#8220;-&#8220;)<\/li>\n<li>the third number is the starting line for this hunk in newfile<\/li>\n<li>the last number is the number of lines after the hunk has been applied.<\/li>\n<\/ul>\n<p>Many thanks to <a class=\"external text\" title=\"http:\/\/www.who-t.net\/\" href=\"http:\/\/www.who-t.net\/\" rel=\"nofollow\">Peter Hutterer<\/a> for this valuable trip into a patch.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever been working on code, gone off on a side tangent and then realized you don&#8217;t have a valid patch of the code you&#8217;ve been working on? So you run diff -du, cvs diff, git diff or some other diff and suddenly realize you have a mix of old changes and new changes.<a href=\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch\"> <font size=-2>[..more..]<\/font><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-other"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Splitting A Patch - ClearChain<\/title>\n<meta name=\"description\" content=\"Have you ever been working on code, gone off on a side tangent and then realized you don&#039;t have a valid patch of the code you&#039;ve been working on? So you\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin Close\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch\"},\"author\":{\"name\":\"Benjamin Close\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\"},\"headline\":\"Splitting A Patch\",\"datePublished\":\"2008-11-13T14:07:50+00:00\",\"dateModified\":\"2013-06-26T04:14:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch\"},\"wordCount\":298,\"commentCount\":8,\"articleSection\":[\"Other\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch\",\"url\":\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch\",\"name\":\"Splitting A Patch - ClearChain\",\"isPartOf\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/#website\"},\"datePublished\":\"2008-11-13T14:07:50+00:00\",\"dateModified\":\"2013-06-26T04:14:42+00:00\",\"author\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\"},\"description\":\"Have you ever been working on code, gone off on a side tangent and then realized you don't have a valid patch of the code you've been working on? So you\",\"breadcrumb\":{\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.clearchain.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Splitting A Patch\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#website\",\"url\":\"https:\/\/www.clearchain.com\/blog\/\",\"name\":\"ClearChain\",\"description\":\"-= Daily Happenings =-\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.clearchain.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98\",\"name\":\"Benjamin Close\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg\",\"caption\":\"Benjamin Close\"},\"sameAs\":[\"http:\/\/www.clearchain.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Splitting A Patch - ClearChain","description":"Have you ever been working on code, gone off on a side tangent and then realized you don't have a valid patch of the code you've been working on? So you","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch","twitter_misc":{"Written by":"Benjamin Close","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch#article","isPartOf":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch"},"author":{"name":"Benjamin Close","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98"},"headline":"Splitting A Patch","datePublished":"2008-11-13T14:07:50+00:00","dateModified":"2013-06-26T04:14:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch"},"wordCount":298,"commentCount":8,"articleSection":["Other"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch","url":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch","name":"Splitting A Patch - ClearChain","isPartOf":{"@id":"https:\/\/www.clearchain.com\/blog\/#website"},"datePublished":"2008-11-13T14:07:50+00:00","dateModified":"2013-06-26T04:14:42+00:00","author":{"@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98"},"description":"Have you ever been working on code, gone off on a side tangent and then realized you don't have a valid patch of the code you've been working on? So you","breadcrumb":{"@id":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.clearchain.com\/blog\/posts\/splitting-a-patch#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.clearchain.com\/blog"},{"@type":"ListItem","position":2,"name":"Splitting A Patch"}]},{"@type":"WebSite","@id":"https:\/\/www.clearchain.com\/blog\/#website","url":"https:\/\/www.clearchain.com\/blog\/","name":"ClearChain","description":"-= Daily Happenings =-","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.clearchain.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/aef6faa2c32188398139db9270ca1c98","name":"Benjamin Close","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.clearchain.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/19dca0aa372edfa901b93c556dfda2e78ad4434558fe4d139598e086315d714a?s=96&d=mm&r=pg","caption":"Benjamin Close"},"sameAs":["http:\/\/www.clearchain.com"]}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":4,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":1128,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/posts\/118\/revisions\/1128"}],"wp:attachment":[{"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clearchain.com\/blog\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}