<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Roundtrip to Shanghai via Tokyo &#187; git</title>
	<atom:link href="http://kohei.us/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://kohei.us</link>
	<description>Kohei Yoshida&#039;s Webspace</description>
	<lastBuildDate>Wed, 14 Dec 2011 04:17:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>mdds moves to git</title>
		<link>http://kohei.us/2011/07/15/mdds-moves-to-git/</link>
		<comments>http://kohei.us/2011/07/15/mdds-moves-to-git/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 01:57:40 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mdds]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=1184</guid>
		<description><![CDATA[Following the announcement that Google Code finally gets git support, I&#8217;ve migrated my mdds source code repository from the old mercurial one to a new git one. For anyone who has the old mercurial repository of mdds checked out, please &#8230; <a href="http://kohei.us/2011/07/15/mdds-moves-to-git/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following the announcement that <a href="http://www.infoq.com/news/2011/07/google-git">Google Code finally gets git support</a>, I&#8217;ve migrated my <a href="http://code.google.com/p/multidimalgorithm/">mdds</a> source code repository from the old mercurial one to a new git one.  For anyone who has the old mercurial repository of mdds checked out, please switch to the new git repo.  Refer to <a href="http://code.google.com/p/multidimalgorithm/source/checkout">this page</a> on how to check out the new git-based mdds repository.</p>
<p>As for doing the actual migration, <a href="http://hivelogic.com/articles/converting-from-mercurial-to-git/">this blog post</a> was very helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2011/07/15/mdds-moves-to-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extracting a sub project into a new repository (and how mso-dumper got its new home).</title>
		<link>http://kohei.us/2011/02/17/extracting-a-sub-project-into-a-new-repository-and-how-mso-dumper-got-its-new-home/</link>
		<comments>http://kohei.us/2011/02/17/extracting-a-sub-project-into-a-new-repository-and-how-mso-dumper-got-its-new-home/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 03:32:50 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mso-dumper]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=915</guid>
		<description><![CDATA[Background Just a short while ago I worked on extracting our mso-dumper project from LibreOffice&#8217;s build repository, into a brand new repository created just for this. The new repository was to be located in libreoffice/contrib/mso-dumper. Originally, this project started out &#8230; <a href="http://kohei.us/2011/02/17/extracting-a-sub-project-into-a-new-repository-and-how-mso-dumper-got-its-new-home/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Background</h3>
<p>Just a short while ago I worked on extracting our mso-dumper project from <a href="http://cgit.freedesktop.org/libreoffice/build/">LibreOffice&#8217;s build repository</a>, into a brand new repository created just for this.  The new repository was to be located in <a href="http://cgit.freedesktop.org/libreoffice/contrib/mso-dumper/">libreoffice/contrib/mso-dumper</a>.</p>
<p>Originally, this project started out just as a simple sub directory of a much larger parent repository.  But because it grew so much, and because its scope is not entirely in line with that of the parent repository, I decided it was best to move this project into a repository of its own.  Now, it&#8217;s easy to transfer a subset of files from one repository to another if you don&#8217;t mind losing its history, but I wanted to preserve the history of those files even after the transition.</p>
<p>It turns out that there is a way to do this with git.  Kendy suggested that I look into <code>git filter-branch</code>, so I did.  After a few hours of researching and trials &#038; errors (and some bash script writing which was later thrown away), I&#8217;ve come to realize that all of this can be achieved in the following simple steps.</p>
<h3>Steps</h3>
<p>First, clone the whole build repository which contains the sub project to be extracted</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>libo<span style="color: #000000; font-weight: bold;">/</span>build mso-dumper-temp</pre></div></div>

<p>Once done, cd into that cloned repository, and run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> filter-branch <span style="color: #660033;">--subdirectory-filter</span> scratch<span style="color: #000000; font-weight: bold;">/</span>mso-dumper<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--</span> <span style="color: #660033;">--all</span></pre></div></div>

<p>which will remove all files from the git history except for those under the scratch/mso-dumper directory, and re-locate those files under that directory into the top-level directory.  You may also want to run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> remote <span style="color: #c20cb9; font-weight: bold;">rm</span> origin</pre></div></div>

<p>to prevent accidental pushing of this to the remote origin during these steps.  Anyway, once the filtering is done, remove all tags by</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> tag <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">git</span> tag <span style="color: #660033;">-d</span></pre></div></div>

<p>And that&#8217;s all.  Now, you have only the files you want to keep, they are sitting happily at the top level like they should, all of their commit records are preserved, and you don&#8217;t have any old tags you don&#8217;t need for the new repository.</p>
<p>This is not over yet.  At this point, this git repo still stores the objects of the removed files.  In fact, the size of the .git directory of this new repo was more than twice the size of the .git directory of the original build repo!  To completely prune this unnecessary info in order to shrink the size of the repository, run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>mso-dumper-temp mso-dumper</pre></div></div>

<p>to further clone this into another repo locally to strip all the unnecessary blob.  Note that I used the file:///&#8230; style file path, as opposed to the usual /path/to/foo style file path.  <em>When using the file:///&#8230; style path to clone a local repo, git will <strong>not</strong> clone the objects of the removed files, thereby reducing the size of the objects significantly (and clone is faster too).</em>  Using the regular /path/to/foo style path, git will hard-link all the object files, so the size will stay the same.</p>
<p>After the second cloning, the size of my .git directory shrank from 280MB to 384k!  So it does make a big difference.  Now all that&#8217;s left to do is to push this repository to the new remote location.  Easy huh? :-)</p>
<h3>But there was a gotcha&#8230;.</h3>
<p>There was one caveat, however.  This method apparently does not preserve the whole history of the relocated files if the parent sub-directory had been renamed.  The mso-dumper directory was renamed from its original name sc-xlsutil in order to accommodate the <a href="http://blog.thebehrens.net/2009/01/08/python-binary-ppt-fun/">ppt dumper that Thorsten wrote</a>.  Unfortunately <code>git filter-branch --subdirectory-filter</code> did not preserve the history before the directory rename occurred, but that was just a minor issue, and something I was not too concerned about for this particular transition.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2011/02/17/extracting-a-sub-project-into-a-new-repository-and-how-mso-dumper-got-its-new-home/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Working with a branch using git-new-workdir</title>
		<link>http://kohei.us/2010/11/16/working-with-a-branch-using-git-new-workdir/</link>
		<comments>http://kohei.us/2010/11/16/working-with-a-branch-using-git-new-workdir/#comments</comments>
		<pubDate>Tue, 16 Nov 2010 17:48:17 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[code snippet]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[libreoffice]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=875</guid>
		<description><![CDATA[Introduction Git package contains a script named git-new-workdir, which allows you to work in a branch in a separate directory on the file system. This differs from cloning a repository in that git-new-workdir doesn&#8217;t duplicate the git history from the &#8230; <a href="http://kohei.us/2010/11/16/working-with-a-branch-using-git-new-workdir/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Git package contains a script named <code>git-new-workdir</code>, which allows you to work in a branch in a separate directory on the file system.  This differs from cloning a repository in that git-new-workdir doesn&#8217;t duplicate the git history from the original repository and shares it instead, and that when you commit something to the branch that commit goes directly into the history of the original repository without explicitly pushing to the original repository.  On top of that, creating a new branch work directory happens very much instantly.  It&#8217;s fast, and it&#8217;s efficient.  It&#8217;s an absolute time saver for those of us who work on many branches at any given moment without bloating the disk space.</p>
<p>As wonderful as this script can be, not all distros package this script with their git package.  If your distro doesn&#8217;t package it, you can always download the <a href="http://git-scm.com/download">source packages of git</a> and find the script there, under the contrib directory.  Also, if you have the <a href="http://cgit.freedesktop.org/libreoffice/build/">build repository of libreoffice</a> cloned, you can find it in <code>bin/git-new-workdir</code> too.</p>
<p>Now, I&#8217;m going to talk about how I make use of this script to work on the 3.3 branch of LibreOffice.</p>
<h3>Creating a branch work directory</h3>
<p>If you&#8217;ve followed <a href="http://wiki.documentfoundation.org/Development/How_to_build">this page</a> to build the master branch of libreoffice, then you should have in your clone of the build repository a directory named <code>clone</code>.  Under this directory are your local clones of the 19 repositories comprising the whole libreoffice source tree.  If you are like me, you have followed the above page and built your libreoffice build in the rawbuild directory.</p>
<p>The next step is to create a separate directory just for the 3.3 branch which named <code>libreoffice-3-3</code> and set things up so that you can build it normally as you did in the rawbuild.  I&#8217;ve written the following bash script (named <code>create-branch-build.sh</code>) to do this in one single step.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env bash</span>
&nbsp;
<span style="color: #007800;">GIT_NEW_WORKDIR</span>=~<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>git-new-workdir
<span style="color: #007800;">REPOS</span>=clone
&nbsp;
print_help<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> Usage: <span style="color: #007800;">$1</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>bootstrap <span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>dest <span style="color: #c20cb9; font-weight: bold;">dir</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>branch name<span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
die<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$1</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">BOOTSTRAP_DIR</span>=<span style="color: #ff0000;">&quot;$1&quot;</span>
<span style="color: #007800;">DEST_DIR</span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
<span style="color: #007800;">BRANCH</span>=<span style="color: #ff0000;">&quot;$3&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BOOTSTRAP_DIR</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> bootstrap repo is missing.
    print_help <span style="color: #007800;">$0</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DEST_DIR</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> destination directory is missing.
    print_help <span style="color: #007800;">$0</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BRANCH</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> branch name is missing.
    print_help <span style="color: #007800;">$0</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DEST_DIR</span>/<span style="color: #007800;">$BRANCH</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    die <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DEST_DIR</span>/<span style="color: #007800;">$BRANCH</span> already exists.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Clone bootstrap first.</span>
<span style="color: #007800;">$GIT_NEW_WORKDIR</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BOOTSTRAP_DIR</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DEST_DIR</span>/<span style="color: #007800;">$BRANCH</span>&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BRANCH</span>&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> die <span style="color: #ff0000;">&quot;failed to clone bootstrap repo.&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># First, check out the branches.</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;creating directory <span style="color: #007800;">$DEST_DIR</span>/<span style="color: #007800;">$BRANCH</span>/<span style="color: #007800;">$REPOS</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DEST_DIR</span>/<span style="color: #007800;">$BRANCH</span>/<span style="color: #007800;">$REPOS</span>&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> die <span style="color: #ff0000;">&quot;failed to create <span style="color: #007800;">$DEST_DIR</span>/<span style="color: #007800;">$BRANCH</span>/<span style="color: #007800;">$REPOS</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> repo <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$BOOTSTRAP_DIR</span>/clone&quot;</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">repo_path</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$BOOTSTRAP_DIR</span>/clone/<span style="color: #007800;">$repo</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$repo_path</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #666666; font-style: italic;"># we only care about directories.</span>
        <span style="color: #7a0874; font-weight: bold;">continue</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> ===== <span style="color: #007800;">$repo</span> =====
    <span style="color: #007800;">$GIT_NEW_WORKDIR</span> <span style="color: #007800;">$repo_path</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DEST_DIR</span>/<span style="color: #007800;">$BRANCH</span>/<span style="color: #007800;">$REPOS</span>/<span style="color: #007800;">$repo</span>&quot;</span> <span style="color: #007800;">$BRANCH</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Set symbolic links to the root directory.</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$DEST_DIR</span>/<span style="color: #007800;">$BRANCH</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> repo <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #007800;">$REPOS</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">repo_path</span>=<span style="color: #007800;">$REPOS</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$repo</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$repo_path</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #666666; font-style: italic;"># skip if not directory.</span>
        <span style="color: #7a0874; font-weight: bold;">continue</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-t</span> . <span style="color: #007800;">$repo_path</span><span style="color: #000000; font-weight: bold;">/*</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>The only thing you need to do before running this script is to set the <code>GIT_NEW_WORKDIR</code> variable to point to the location of the git-new-workdir script on your file system.</p>
<p>With this script in place, you can simply</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ..  <span style="color: #666666; font-style: italic;"># move out of the build directory</span>
create-branch-build.sh .<span style="color: #000000; font-weight: bold;">/</span>build<span style="color: #000000; font-weight: bold;">/</span>clone . libreoffice-<span style="color: #000000;">3</span>-<span style="color: #000000;">3</span></pre></div></div>

<p>and you now have a new directory named <code>libreoffice-3-3</code> (same as the branch name), where all modules and top-level files are properly symlinked to their original locations, while the actual repo branches are under the <code>_repos</code> directory.  All you have left to do is to start building. :-)</p>
<p>Note that there is no need to manually create a local branch named libreoffice-3-3 that tracks the remote libreoffice-3-3 branch in the original repository before running this script; git-new-workdir takes care of that for you provided that the remote branch of the same name exists.</p>
<h3>Updating the branch work directory</h3>
<p>In general, when you are in a branch work directory (I call it this because it sounds about right), updating the branch from the branch in the remote repo consists of two steps.  First, fetch the latest history in the original repository by <code>git fetch</code>, move back to the branch work directory and run <code>git pull -r</code>.</p>
<p>But doing this manually in all the 19 repositories can be very tedious.  So I wrote another script (named <code>g.sh</code>) to ease this pain a little.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env bash</span>
&nbsp;
<span style="color: #007800;">REPOS</span>=clone
&nbsp;
die<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$1</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$REPOS</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    die <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REPOS</span> directory not found in cwd.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> ===== main repository =====
<span style="color: #c20cb9; font-weight: bold;">git</span> $<span style="color: #000000; font-weight: bold;">@</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> repo <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #007800;">$REPOS</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> ===== <span style="color: #007800;">$repo</span> =====
    <span style="color: #007800;">repo_path</span>=<span style="color: #007800;">$REPOS</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$repo</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$repo_path</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #666666; font-style: italic;"># Not a directory.  Skip it.</span>
        <span style="color: #7a0874; font-weight: bold;">continue</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #7a0874; font-weight: bold;">pushd</span> . <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
    <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$repo_path</span>
    <span style="color: #c20cb9; font-weight: bold;">git</span> $<span style="color: #000000; font-weight: bold;">@</span>
    <span style="color: #7a0874; font-weight: bold;">popd</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>With this, updating the branch build directory is done:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">g.sh pull <span style="color: #660033;">-r</span></pre></div></div>

<p>That&#8217;s all there is to it.</p>
<h3>A few more words&#8230;</h3>
<p>As with any methods in life, this method has limitations.  If you build libreoffice with the old-fashioned way of applying patches on top of the raw source tree, this method doesn&#8217;t help you; you would still need to clone the repo, and manually switch to the branch in the cloned repo.</p>
<p>But if you build, hack and debug in rawbuild almost exclusively (like me), then this method will help you save time and disk space.  You can also adopt this method for any feature branches, as long as all the 19 repos (20 if you count l10n repo) have the same branch name.  So, it&#8217;s worth a look! :-)</p>
<p>Thank you, ladies and gentlemen.</p>
<p><strong>P.S. I&#8217;ve updated the scripts to adopt to the new bootstrap based build scheme.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2010/11/16/working-with-a-branch-using-git-new-workdir/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Git on Windows</title>
		<link>http://kohei.us/2010/01/20/git-on-windows/</link>
		<comments>http://kohei.us/2010/01/20/git-on-windows/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 01:54:37 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[cygwin]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[mingw]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=619</guid>
		<description><![CDATA[I guess I don&#8217;t really have to tell the world about this, since if you type the title of this blog post in Google it will come back as the top hit. But it&#8217;s still worth mentioning msysgit, a pretty &#8230; <a href="http://kohei.us/2010/01/20/git-on-windows/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I guess I don&#8217;t really have to tell the world about this, since if you type the title of this blog post in Google it will come back as the top hit.  But it&#8217;s still worth mentioning <a href="http://code.google.com/p/msysgit/">msysgit</a>, a pretty darn good <a href="http://git-scm.com/">git</a> client on Windows.  It&#8217;s small, it&#8217;s efficient, and it&#8217;s git. :-)  You could of course use git in <a href="http://www.cygwin.com/">cygwin</a>, but git in cygwin feels a little &#8220;heavy&#8221; and by no means small, since you have to get the whole cygwin environment to even use git.  So, if you don&#8217;t already have cygwin, and want to use git on Windows, msysgit is a pretty good choice.  It comes with a minimal bash shell, and while I&#8217;m happy to see <a href="http://www.openssh.com/">ssh</a> included with its shell, I was a little disappointed that they left out <a href="http://samba.anu.edu.au/rsync/">rsync</a>.  But that&#8217;s just one minor downside.</p>
<p>For me, msysgit is my git client of choice on Windows, especially in a virtual machine setting where the disk space is tight.  On a build machine, though, I still use git in cygwin since I already have to use cygwin to build OOo.</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2010/01/20/git-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ooo-build git repository browser</title>
		<link>http://kohei.us/2009/04/10/ooo-build-git-repository-browser/</link>
		<comments>http://kohei.us/2009/04/10/ooo-build-git-repository-browser/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 18:43:00 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[freedesktop.org]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[go-oo]]></category>

		<guid isPermaLink="false">http://kohei.us/?p=405</guid>
		<description><![CDATA[Looks like the web interface of our new git repository is finally on-line. You can browse it from here: http://cgit.freedesktop.org/ooo-build/ooo-build Very nice!]]></description>
			<content:encoded><![CDATA[<p>Looks like the web interface of our new git repository is finally on-line.  You can browse it from here:</p>
<p><a href="http://cgit.freedesktop.org/ooo-build/ooo-build">http://cgit.freedesktop.org/ooo-build/ooo-build</a></p>
<p>Very nice!</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2009/04/10/ooo-build-git-repository-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cognitive Dissonance</title>
		<link>http://kohei.us/2007/07/03/cognitive-dissonance/</link>
		<comments>http://kohei.us/2007/07/03/cognitive-dissonance/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 23:36:01 +0000</pubDate>
		<dc:creator>Kohei Yoshida</dc:creator>
				<category><![CDATA[]]></category>
		<category><![CDATA[cognitive dissonance]]></category>
		<category><![CDATA[cvs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://kohei.us/2007/07/03/cognitive-dissonance/</guid>
		<description><![CDATA[There are certain words I can never type right for the first time. One is &#8216;formula&#8217;. My finger always wants to type it as &#8216;formular&#8217;, thinking that there is a missing &#8216;r&#8217; at the end. Another one is &#8216;cvs&#8217;. I &#8230; <a href="http://kohei.us/2007/07/03/cognitive-dissonance/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are certain words I can never type right for the first time.  One is &#8216;formula&#8217;.  My finger always wants to type it as &#8216;formular&#8217;, thinking that there is a missing &#8216;r&#8217; at the end.  Another one is &#8216;cvs&#8217;.  I always end up typing &#8216;svn&#8217;, then backspacing it three times to retype &#8216;cvs&#8217;.  However, I have no problem typing &#8216;git&#8217; (I&#8217;m not kidding!).</p>
]]></content:encoded>
			<wfw:commentRss>http://kohei.us/2007/07/03/cognitive-dissonance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

