<?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>Ciaran&#039;s Random Writings &#187; Git</title>
	<atom:link href="http://ciarang.com/posts/category/software/git/feed" rel="self" type="application/rss+xml" />
	<link>http://ciarang.com</link>
	<description>Random things I&#039;ve written about stuff</description>
	<lastBuildDate>Thu, 02 Feb 2012 17:46:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Commit Visualisation Revisited</title>
		<link>http://ciarang.com/posts/commit-visualisation-revisited</link>
		<comments>http://ciarang.com/posts/commit-visualisation-revisited#comments</comments>
		<pubDate>Thu, 03 Sep 2009 21:08:26 +0000</pubDate>
		<dc:creator>CiaranG</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Laconica]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[StatusNet]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ciarang.com/?p=716</guid>
		<description><![CDATA[I wrote briefly about code_swarm last year &#8211; a tool to generate visualisations of a project&#8217;s commit history. Today, via Brenda Wallace, I found out about a new variation on the same theme &#8211; so new it hasn&#8217;t been released or even named yet. Apparently though the author, Andrew Caudwell, is planning to release the [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote briefly about <a href="http://ciarang.com/posts/apache-commit-visualisation-code_swarm">code_swarm last year</a> &#8211; a tool to generate visualisations of a project&#8217;s commit history. Today, via <a href="http://www.br3nda.com/">Brenda Wallace</a>, I found out about a new variation on the same theme &#8211; so new it hasn&#8217;t been released or even named yet. Apparently though the author, Andrew Caudwell, is planning to release the source in the very near future.</p>
<p>The following video, also courtesy of Brenda Wallace, shows the output generated from the StatusNet (formerly Laconica) git repository:</p>
<p><img src="http://ciarang.com/wp-content/plugins/flash-video-player/default_video_player.gif" /></p>
<p>I think this is really impressive stuff, and not just because I&#8217;m in it. There&#8217;s a better quality version <a href="http://www.youtube.com/watch?v=lP3JaOFy-qM">on YouTube</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ciarang.com/posts/commit-visualisation-revisited/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A Git Gotcha &#8211; Identical Changes</title>
		<link>http://ciarang.com/posts/a-git-gotcha-identical-changes</link>
		<comments>http://ciarang.com/posts/a-git-gotcha-identical-changes#comments</comments>
		<pubDate>Thu, 26 Mar 2009 21:25:39 +0000</pubDate>
		<dc:creator>CiaranG</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://ciarang.com/?p=646</guid>
		<description><![CDATA[Here&#8217;s an interesting side effect of the way git cleverly and silently handles identical changes during a merge, combined with the way history is stored and searched. I&#8217;ll demonstrate by setting up the simplest possible scenario. In an empty directory: git init echo -e &#34;line 1\nline two\nline 3&#34; &#62;test.txt git add test.txt git commit -m [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an interesting side effect of the way git cleverly and silently handles identical changes during a merge, combined with the way history is stored and searched. I&#8217;ll demonstrate by setting up the simplest possible scenario. In an empty directory:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> init
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;line 1<span style="color: #000099; font-weight: bold;">\n</span>line two<span style="color: #000099; font-weight: bold;">\n</span>line 3&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span>test.txt
<span style="color: #c20cb9; font-weight: bold;">git</span> add test.txt
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Initial file&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> checkout <span style="color: #660033;">-b</span> fred
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/two/2/'</span> test.txt
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;line 4&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span>test.txt
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Fixed line 2 and added line 4&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> checkout master
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'s/two/2/'</span> test.txt
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Fix line 2&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> merge fred</pre></div></div>

<p>So just to recap what we&#8217;ve done in English &#8211; we start out with a <i>test.txt</i> that looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">line 1
line two
line 3</pre></div></div>

<p>Then Fred creates a new branch to add some new functionality (a fourth line) and at the same time notices the error in line two and changes &#8216;two&#8217; to &#8217;2&#8242;. Fred&#8217;s commit results in this, which git sees as two changes (hunks) one for line 2 and one for line 4:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">line 1
line 2
line 3
line 4</pre></div></div>

<p>Meanwhile, back on the master branch, Eric has noticed the same error, and changes &#8216;two&#8217; to &#8217;2&#8242; too. So the commit on the master branch results in this, a single change:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">line 1
line 2
line 3</pre></div></div>

<p>Finally, the changes from Fred&#8217;s branch are merged back into master. Note that despite both branches not only having changed the same file, but even the same line of the same file, the merge is completely straightforward and automatic &#8211; no user intervention is required.</p>
<p>So here&#8217;s the gotcha (or at least, it got me). To see why, you probably have to imagine lots more unrelated commits on both branches, and lots of time passing. Eric sees Fred&#8217;s commit and thinks &#8220;Weird, didn&#8217;t I make that change already? I&#8217;ll ask git:&#8221;

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> log test.txt</pre></div></div>

<p>To his surprise, searching the log for commits that changed test.txt produces no mention of the commit labelled &#8220;Fix line 2&#8243;. In fact, it shows all the commits EXCEPT that one. So he finds his commit in a more specific way and has a look at what it changed:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> log <span style="color: #660033;">--name-only</span> <span style="color: #660033;">--grep</span>=<span style="color: #ff0000;">&quot;Fix line 2&quot;</span></pre></div></div>

<p>The commit is there, and it says it changes test.txt, so there is an apparent inconsistency between what the two forms of <i>git log</i> are reporting here.</p>
<p>In fact, <i>git log</i> is deliberately simplifying the history here. In the default mode, commits from side branches that don&#8217;t contribute anything to the final state of the tree are pruned from the output. The way to get the full output is:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> log <span style="color: #660033;">--full-history</span> test.txt</pre></div></div>

<p>With the <i>&#8211;full-history</i> option added, the output contains all the commits. Worth remembering.</p>
]]></content:encoded>
			<wfw:commentRss>http://ciarang.com/posts/a-git-gotcha-identical-changes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

