{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "chem-bla-ics",
  "description": "Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.",
  "home_page_url": "https://chem-bla-ics.linkedchemistry.info/",
  "feed_url": "https://chem-bla-ics.linkedchemistry.info/2020/07/03/bioclipse-git-experiences-2-create.json",
  "icon": "https://chem-bla-ics.linkedchemistry.info/assets/images/chem-bla-ics_logo.png",
  "language": "en",
  "authors": [
    {
      "name": "Egon Willighagen",
      "url": "https://orcid.org/0000-0001-7542-0286",
      "_orcid": "0000-0001-7542-0286"
    }
  ],
  "items": [

    {
      "id": "https://doi.org/10.59350/7ts20-k7s71",
      "url": "https://chem-bla-ics.linkedchemistry.info/2020/07/03/bioclipse-git-experiences-2-create.html",
      "title": "Bioclipse git experiences #2: Create patches for individual plugins/features",
      "content_html": "<p>This is a series of two posts repeating some content I <a href=\"https://web.archive.org/web/20180821111520/http://wiki.bioclipse.net/index.php?title=Git_Development\">wrote up back in the Bioclipse days</a>\n(see also <a href=\"https://scholia.toolforge.org/topic/Q1769726\">this Scholia page</a>). They both deal with something\nwe were facing: restructuring of version control repositories, while actually keeping the history. For\nexample, you may want to copy or move code from one repository to another. A second use case can be a file\nthat must be removed (there are valid reasons for that). Because these posts are based on Bioclipse work,\nthere will be some specific terminology, but the approach I regularly apply in other situations.</p>\n\n<p>This second post talks about how to migrate code from one repository to another.</p>\n\n<h2 id=\"create-patches-for-individual-pluginsfeatures\">Create patches for individual plugins/features</h2>\n\n<p>While the above works pretty well, a good alternative in situations where you only need to get a\nrepository-with-history for a few plugins, is to use patch sets.</p>\n\n<p>First, initialize a new git repository, e.g. bioclipse.rdf:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nb\">mkdir </span>bioclipse.rdf\n<span class=\"nb\">cd </span>bioclipse.rdf\ngit init\nnano README\ngit commit <span class=\"nt\">-m</span> <span class=\"s2\">\"Added README with some basic info about the new repository\"</span> README\n</code></pre></div></div>\n\n<p>Then, for each plugin discover you need what the commit was where the plugins was first commited, using the git-svn repository created earlier:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nb\">cd </span>your.gitsvn.checkout\ngit log <span class=\"nt\">--pretty</span><span class=\"o\">=</span>oneline externals/com.hp.hpl.jena/ | <span class=\"nb\">tail</span> <span class=\"nt\">-1</span>\n</code></pre></div></div>\n\n<p>Then create patches for the last tree before that last patch by appending <code class=\"language-plaintext highlighter-rouge\">^1</code> to the commit hash. For example, the first patch of the Jena libraries was 06d0eb0542377f958d06892860ea3363e3316389, so I type:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nb\">rm </span>00<span class=\"k\">*</span>.patch\ngit format-patch 06d0eb0542377f958d06892860ea3363e3316389^1 <span class=\"nt\">--</span> externals/com.hp.hpl.jena\n</code></pre></div></div>\n\n<p>(tune the filter when removing old patches if there are more than 99!)</p>\n\n<p>The previous two steps can be combined into a Perl script:</p>\n\n<div class=\"language-perl highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"c1\">#!/usr/bin/perl</span>\n<span class=\"k\">use</span> <span class=\"nv\">diagnostics</span><span class=\"p\">;</span>\n<span class=\"k\">use</span> <span class=\"nv\">strict</span><span class=\"p\">;</span>\n\n<span class=\"k\">my</span> <span class=\"nv\">$plugin</span> <span class=\"o\">=</span> <span class=\"nv\">$ARGV</span><span class=\"p\">[</span><span class=\"mi\">0</span><span class=\"p\">];</span>\n\n<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"nv\">$plugin</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n  <span class=\"k\">print</span> <span class=\"p\">\"</span><span class=\"s2\">Syntax: gfp &lt;plugin|feature&gt;</span><span class=\"se\">\\n</span><span class=\"p\">\";</span>\n  <span class=\"nb\">exit</span><span class=\"p\">(</span><span class=\"mi\">0</span><span class=\"p\">);</span>\n<span class=\"p\">}</span>\n\n<span class=\"nb\">die</span> <span class=\"p\">\"</span><span class=\"s2\">Cannot find plugin or feature </span><span class=\"si\">$plugin</span><span class=\"s2\"> !</span><span class=\"p\">\"</span> <span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"o\">-</span><span class=\"nv\">e</span> <span class=\"nv\">$plugin</span><span class=\"p\">));</span>\n\n<span class=\"p\">`</span><span class=\"sb\">rm -f *.patch</span><span class=\"p\">`;</span>\n<span class=\"k\">my</span> <span class=\"nv\">$hash</span> <span class=\"o\">=</span> <span class=\"p\">`</span><span class=\"sb\">git log --follow --pretty=oneline </span><span class=\"si\">$plugin</span><span class=\"sb\"> | tail -1 | cut -d' ' -f1</span><span class=\"p\">`;</span>\n<span class=\"nv\">$hash</span> <span class=\"o\">=~</span> <span class=\"sr\">s/\\n|\\r//g</span><span class=\"p\">;</span>\n\n<span class=\"k\">print</span> <span class=\"p\">\"</span><span class=\"s2\">Plugin: </span><span class=\"si\">$plugin</span><span class=\"s2\"> </span><span class=\"se\">\\n</span><span class=\"p\">\";</span>\n<span class=\"k\">print</span> <span class=\"p\">\"</span><span class=\"s2\">Hash: </span><span class=\"si\">$hash</span><span class=\"s2\"> </span><span class=\"se\">\\n</span><span class=\"p\">\";</span>\n<span class=\"p\">`</span><span class=\"sb\">git format-patch </span><span class=\"si\">$hash</span><span class=\"sb\">^1 -- </span><span class=\"si\">$plugin</span><span class=\"p\">`;</span>\n</code></pre></div></div>\n\n<p>Move these patches into your new repository:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nb\">mv </span>00<span class=\"k\">*</span>.patch ../bioclipse.rdf\n</code></pre></div></div>\n\n<p>(tune the filter when moving the patches if there are more than 99! Also customize the target folder name to match your situation)</p>\n\n<p>Apply the new patches in your new git repository:</p>\n\n<div class=\"language-shell highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"nb\">cd</span> ../bioclipse.rdf\ngit am 00<span class=\"k\">*</span>.patch\n</code></pre></div></div>\n\n<p>(You’re on your own if that fails… and you may have to default to the other alternative then)</p>\n\n<p>Repeat those two steps for all plugins you want in your new repository</p>",
      "summary": "This is a series of two posts repeating some content I wrote up back in the Bioclipse days (see also this Scholia page). They both deal with something we were facing: restructuring of version control repositories, while actually keeping the history. For example, you may want to copy or move code from one repository to another. A second use case can be a file that must be removed (there are valid reasons for that). Because these posts are based on Bioclipse work, there will be some specific terminology, but the approach I regularly apply in other situations.",
      
      "date_published": "2020-07-03T00:00:00+00:00",
      "date_modified": "2025-02-15T00:00:00+00:00",
      "tags": ["bioclipse","git"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
