<?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>Software and Opinions &#187; git</title>
	<atom:link href="http://ianloic.com/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://ianloic.com</link>
	<description>from Ian McKellar</description>
	<lastBuildDate>Wed, 07 Sep 2011 21:48:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://ianloic.com/?pushpress=hub'/>
		<item>
		<title>Showing git status in my Zsh prompt</title>
		<link>http://ianloic.com/2011/06/25/git-zsh-prompt/</link>
		<comments>http://ianloic.com/2011/06/25/git-zsh-prompt/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 20:24:42 +0000</pubDate>
		<dc:creator>Ian McKellar</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://ianloic.com/?p=352</guid>
		<description><![CDATA[I like Zsh. It&#8217;s a powerful, efficient shell. It&#8217;s better than Bash by just about every metric (better performance, more features, better sh compatibility). I really have no idea why people keep using Bash. Anyway, I put together a little &#8230; <a href="http://ianloic.com/2011/06/25/git-zsh-prompt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://ianloic.com/wp-content/uploads/2011/06/git-prompt.jpg" alt="" title="git-prompt" width="256" height="256" class="alignright size-full wp-image-353" /> I like <a href="http://www.zsh.org/">Zsh</a>. It&#8217;s a powerful, efficient shell. It&#8217;s better than <a href="http://www.gnu.org/software/bash/">Bash</a> by just about every metric (better performance, more features, better sh compatibility). I really have no idea why people keep using Bash.</p>
<p>Anyway, I put together a little piece of <code>zshrc</code> to show my current status in right-hand prompt &#8211; a prompt that&#8217;s shown right-aligned in the shell. Zsh has a couple of features that make this really easy.</p>
<p>First the <code>prompt_subst</code> options instructs the shell to do variable substitution when evaluating prompts. So if you were to set your prompt to <code>'$PWD> '</code> then your prompt would contain your current directory. Of course you wouldn&#8217;t do it that way, <code>%~</code> does that much more nicely, but that takes us to Zsh&#8217;s second feature, <a href="http://manpages.ubuntu.com/manpages/natty/man1/zshexpn.1.html">ridiculously powerful variable substitution and expansion</a>. In my prompt I just use the simple <code>$(shell-command)</code> substitution, but there&#8217;s a full complement of file-io, string manipulation and more to be had.</p>
<div id="gist-1046832" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>setopt prompt_subst</div><div class='line' id='LC2'>autoload colors zsh/terminfo</div><div class='line' id='LC3'>colors</div><div class='line' id='LC4'><br/></div><div class='line' id='LC5'><span class="k">function </span>__git_prompt <span class="o">{</span></div><div class='line' id='LC6'>&nbsp;&nbsp;<span class="nb">local </span><span class="nv">DIRTY</span><span class="o">=</span><span class="s2">&quot;%{$fg[yellow]%}&quot;</span></div><div class='line' id='LC7'>&nbsp;&nbsp;<span class="nb">local </span><span class="nv">CLEAN</span><span class="o">=</span><span class="s2">&quot;%{$fg[green]%}&quot;</span></div><div class='line' id='LC8'>&nbsp;&nbsp;<span class="nb">local </span><span class="nv">UNMERGED</span><span class="o">=</span><span class="s2">&quot;%{$fg[red]%}&quot;</span></div><div class='line' id='LC9'>&nbsp;&nbsp;<span class="nb">local </span><span class="nv">RESET</span><span class="o">=</span><span class="s2">&quot;%{$terminfo[sgr0]%}&quot;</span></div><div class='line' id='LC10'>&nbsp;&nbsp;git rev-parse --git-dir &gt;&amp; /dev/null</div><div class='line' id='LC11'>&nbsp;&nbsp;<span class="k">if</span> <span class="o">[[</span> <span class="nv">$?</span> <span class="o">==</span> 0 <span class="o">]]</span></div><div class='line' id='LC12'>&nbsp;&nbsp;<span class="k">then</span></div><div class='line' id='LC13'><span class="k">    </span><span class="nb">echo</span> -n <span class="s2">&quot;[&quot;</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">[[</span> <span class="sb">`</span>git ls-files -u &gt;&amp; /dev/null<span class="sb">`</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span> <span class="o">]]</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">then</span></div><div class='line' id='LC16'><span class="k">      </span>git diff --quiet &gt;&amp; /dev/null</div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">[[</span> <span class="nv">$?</span> <span class="o">==</span> 1 <span class="o">]]</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">then</span></div><div class='line' id='LC19'><span class="k">        </span><span class="nb">echo</span> -n <span class="nv">$DIRTY</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">else</span></div><div class='line' id='LC21'><span class="k">        </span>git diff --cached --quiet &gt;&amp; /dev/null</div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="o">[[</span> <span class="nv">$?</span> <span class="o">==</span> 1 <span class="o">]]</span></div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">then</span></div><div class='line' id='LC24'><span class="k">          </span><span class="nb">echo</span> -n <span class="nv">$DIRTY</span></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">else</span></div><div class='line' id='LC26'><span class="k">          </span><span class="nb">echo</span> -n <span class="nv">$CLEAN</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">fi</span></div><div class='line' id='LC28'><span class="k">      fi</span></div><div class='line' id='LC29'><span class="k">    else</span></div><div class='line' id='LC30'><span class="k">      </span><span class="nb">echo</span> -n <span class="nv">$UNMERGED</span></div><div class='line' id='LC31'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">fi</span></div><div class='line' id='LC32'><span class="k">    </span><span class="nb">echo</span> -n <span class="sb">`</span>git branch | grep <span class="s1">&#39;* &#39;</span> | sed <span class="s1">&#39;s/..//&#39;</span><span class="sb">`</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">echo</span> -n <span class="nv">$RESET</span></div><div class='line' id='LC34'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">echo</span> -n <span class="s2">&quot;]&quot;</span></div><div class='line' id='LC35'>&nbsp;&nbsp;<span class="k">fi</span></div><div class='line' id='LC36'><span class="o">}</span></div><div class='line' id='LC37'><br/></div><div class='line' id='LC38'><span class="nb">export </span><span class="nv">RPS1</span><span class="o">=</span><span class="s1">&#39;$(__git_prompt)&#39;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1046832/20af2d3f9bafe6ef570b355fef2a4a47c150fe46/git-prompt.zsh" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1046832#file_git_prompt.zsh" style="float:right;margin-right:10px;color:#666">git-prompt.zsh</a>
            <a href="https://gist.github.com/1046832">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://ianloic.com/2011/06/25/git-zsh-prompt/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Give me convenience</title>
		<link>http://ianloic.com/2009/12/29/give-me-convenience/</link>
		<comments>http://ianloic.com/2009/12/29/give-me-convenience/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 12:38:39 +0000</pubDate>
		<dc:creator>Ian McKellar</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[laziness]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://ianloic.com/?p=164</guid>
		<description><![CDATA[I used to track WordPress updates, plugin updates and my own manual site changes using git. I wrote a whole post about it. Either fortunately or unfortunately WordPress launched their update framework which is so much easier than what I &#8230; <a href="http://ianloic.com/2009/12/29/give-me-convenience/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I used to <a href="http://ianloic.com/2008/09/06/tracking-wordpress-using-git/">track</a> WordPress updates, plugin updates and my own manual site changes using git. I wrote a whole post about it. Either fortunately or unfortunately WordPress launched their update framework which is <em>so</em> much easier than what I was doing. I&#8217;ve given up on my old technique and moved to using WordPress&#8217; update mechanisms.</p>
<p>Of course what I really want is to be able to white a WordPress plugin that is notified any time an update occurs or a file update completes so that I can automatically track site changes in a SCM, but I don&#8217;t think that&#8217;s easy right now.</p>
]]></content:encoded>
			<wfw:commentRss>http://ianloic.com/2009/12/29/give-me-convenience/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tracking WordPress using Git</title>
		<link>http://ianloic.com/2008/09/06/tracking-wordpress-using-git/</link>
		<comments>http://ianloic.com/2008/09/06/tracking-wordpress-using-git/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 20:40:38 +0000</pubDate>
		<dc:creator>Ian McKellar</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://ianloic.com/?p=60</guid>
		<description><![CDATA[Update: I don&#8217;t do this anymore. I publish this blog through WordPress, for reasons I&#8217;ve outlined before. I run it with a custom theme and a bunch of plugins though, and I wanted a convenient way to keep my WordPress &#8230; <a href="http://ianloic.com/2008/09/06/tracking-wordpress-using-git/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: <a href="http://ianloic.com/2009/12/29/give-me-convenience/">I don&#8217;t do this anymore</a>.</p>
<p>I publish this blog through <a href="http://www.wordpress.org/">WordPress</a>, for reasons I&#8217;ve <a href="http://ianloic.com/2008/01/12/moving-from-drupal-to-wordpress-for-blogging/">outlined before</a>. I run it with a custom theme and a bunch of plugins though, and I wanted a convenient way to keep my WordPress install up to date without having to reinstall everything all the time. I wanted source control for my blog install.</p>
<p>My first attempt involved mirroring WordPress SVN into a <a href="http://git.or.cz/">Git</a> repository on <a href="http://www.github.com/">github</a> so that I had a Git version of the SVN tree (including branches, tags and every checkin separate) and seperate repository holding the changes I&#8217;d made for my web site. This eventually failed for two reasons, first the script I was using to mirror the SVN into Git had a habit of failing in bizarre ways and secondly having two repositories confused me.</p>
<p>Yesterday I decided to update my fairly outdated WordPress install, it had been missing security fixes for some time and was one minor version behind. Since tracking SVN hadn&#8217;t worked I tried a simpler approach, a single Git repository containing a <em>master</em> branch that tracks releases and an <em>ianloic.com</em> branch to track the state of my site.</p>
<p>I set up <em>master</em> with a fresh download of WordPress 2.5 from wordpress.com, created my <em>ianloic.com</em> branch and applied the differences between my site and the <em>2.5</em> SVN tag (for all it&#8217;s failures my old approach at least let me do this easily). I switched back to the <em>master</em> branch, deleted all the files (leaving my .git directory intact) and unpacked the new WordPress 2.6.1 tarball. I checked that in (to the <em>master</em> branch), tagged it <em>2.6.1</em> and then merged that into my <em>ianloic.com</em> branch. I pushed all that to <a href="http://github.com/ianloic/wordpress/">github</a> and then checked it out on my web server (at <a href="http://www.dreamhost.com/r.cgi?235928">Dreamhost</a>).</p>
<p>Normally with Git you&#8217;re tracking just the <em>master</em> branch, but I want both <a href="http://github.com/ianloic/wordpress/commits/master"><em>master</em></a> and <a href="http://github.com/ianloic/wordpress/commits/ianloic.com"><em>ianloic.com</em></a> branches to be tracked so my .<em>git/config</em> contains:</p>
<pre>[remote "origin"]
	url = git@github.com:ianloic/wordpress.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
[branch "ianloic.com"]
	remote = origin
	merge = refs/heads/ianloic.com</pre>
<p>Now it&#8217;s easy to track changes that I&#8217;m making to my site and update to the latest WordPress without risking losing anything. The process for updating to a new WordPress release is:</p>
<ul>
<li>on my laptop check out the <em>master</em> branch</li>
<li><em>rm</em> all the files except for <em>.git</em> from the directory</li>
<li>unpack the new release into the directory</li>
<li><em>git-add .</em> — now <em>git-status</em> will indicate what has changed, been added or removed</li>
<li><em>git-commit</em> to check in the new version of wordpress</li>
<li><em>git-tag versionnum</em> to tag which version is currently in master</li>
<li><em>git-checkout ianloic.com</em></li>
<li><em>git-merge versionnum</em> to merge the latest version into the site&#8217;s branch</li>
<li><em>git-push &#8211;all &#8211;tags</em> to push all the branches and tags to github</li>
<li>on my web server, <em>git-pull</em> to update to the latest release</li>
</ul>
<p>I end up with a tree that looks like this:</p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_62" class="wp-caption aligncenter" style="width: 433px;">
<dt class="wp-caption-dt"><a href="http://ianloic.com/wp-content/uploads/2008/09/qgit.png"><img class="size-full wp-image-62" title="WordPress in Git" src="http://ianloic.com/wp-content/uploads/2008/09/qgit.png" alt="ianloic.com WordPress in Git" width="423" height="241" /></a></dt>
</dl>
</div>
]]></content:encoded>
			<wfw:commentRss>http://ianloic.com/2008/09/06/tracking-wordpress-using-git/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How I set up gitweb</title>
		<link>http://ianloic.com/2007/09/13/how_i_set_up_gitweb/</link>
		<comments>http://ianloic.com/2007/09/13/how_i_set_up_gitweb/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>Ian McKellar</dc:creator>
				<category><![CDATA[Default]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[There don't seem to be any straight-forward documents on how to set up gitweb, the web interface to git repositories. Or at least I couldn't find any. After failing to get it working a couple of times and then succeeding a couple of times in different ways here's the recipe I came up with to get what you can see on http://git.ianloic.com/. What I have there is a bunch of git trees I'm following or working on. Perhaps not a bunch, but at least a few.
 <a href="http://ianloic.com/2007/09/13/how_i_set_up_gitweb/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There don&#8217;t seem to be any straight-forward documents on how to set up gitweb, the web interface to git repositories. Or at least I couldn&#8217;t find any. After failing to get it working a couple of times and then succeeding a couple of times in different ways here&#8217;s the recipe I came up with to get what you can see on http://git.ianloic.com/. What I have there is a bunch of git trees I&#8217;m following or working on. Perhaps not a bunch, but at least a few.<br />
<!--break--><br />
<strong>What you need:</strong></p>
<ul>
<li>a recent <a href="http://git.or.cz/">git</a> installed</li>
<li><a href="http://httpd.apache.org/">Apache</a></li>
<li>the gitweb files (from your git distribution) somewhere in your web tree</li>
</ul>
<p>Gitweb comes as part of recent git distributions in a <code>gitweb/</code> directory. This needs to be accessible from the web. I just have a git checkout in my web area and use that. When you build git you can supply all kinds of defaults that are applied when <code>gitweb.perl</code> is transformed into <code>gitweb.cgi</code>. Compile-time configuration and since you can override all that in a config file I prefer to just use <code>gitweb.perl</code> directly. My config file <code>gitweb-config.pl</code> looks like this:</p>
<pre class="prettyprint">
# where's the git binary?
$GIT = "/home/yakk/bin/git";
# where's our projects?
$projectroot = "/home/yakk/git.ianloic.com";
# what do we call our projects in the ui?
$home_link_str = "projects";
# where are the files we need for web display?
@stylesheets = ("/git/gitweb/gitweb.css");
$logo = "/git/gitweb/git-logo.png";
$favicon = "/git/gitweb/git-favicon.png";
# what do we call this site
$site_name = "Ian's git trees";
# these variables should be empty
$site_header = "";
$home_text = "";
$site_footer = "";
$projects_list = "";
$export_ok = "";
$strict_export = "";</pre>
<p>Most of that should be fairly straight-forward. <code>$GIT</code> and <code>$projectroot</code> are local filesystem paths for the git binary and the directory that contains your git trees respectively. <code>@stylesheets</code>, <code>$logo</code> and <code>$favicon</code> are URLs. In my case I just use relative URLs. You can customize most of the other variables to tweak the text to display. We have values for all these because <code>gitweb.perl</code> contains junk defaults that need to be cleared.</p>
<p>I wrote a little wrapper CGI, <code>invoke-gitweb.cgi</code> to invoke <code>gitweb.perl</code> with an environment variable to tell it to load <code>gitweb-config.pl</code>:</p>
<pre class="prettyprint">
#!/bin/sh
GITWEB_CONFIG=gitweb-config.pl exec perl git/gitweb/gitweb.perl</pre>
<p>Drop <code>gitweb-config.pl</code> and <code>invoke-gitweb.cgi</code> into the directory that contains your git trees. Make <code>invoke-gitweb.cgi</code> executable and make sure your Apache knows to execute *.cgi as cgi scripts.</p>
<p>If you load <code>invoke-gitweb.cgi</code> in your browser you should see gitweb in action! But your URLs are stupid.</p>
<p>Let&#8217;s fix that with a <code>.htaccess</code> file:</p>
<pre class="prettyprint">
RewriteEngine on
RewriteRule ^$ /invoke-gitweb.cgi
RewriteRule ^([?].*)$ /invoke-gitweb.cgi$1</pre>
<p>This will make any requests for just the directory invoke gitweb and any requests starting with <code>?</code> invoke gitweb with those arguments. It works pretty well for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://ianloic.com/2007/09/13/how_i_set_up_gitweb/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

