<?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>Keep It With Mine &#187; bruno</title>
	<atom:link href="http://bruno.defraine.net/techtips/author/bruno/feed/" rel="self" type="application/rss+xml" />
	<link>http://bruno.defraine.net/techtips</link>
	<description>Collection of assorted technology tips</description>
	<lastBuildDate>Wed, 03 May 2017 09:10:09 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.19</generator>
	<item>
		<title>Continue SVN history in a git repository</title>
		<link>http://bruno.defraine.net/techtips/continue-svn-in-git/</link>
		<comments>http://bruno.defraine.net/techtips/continue-svn-in-git/#comments</comments>
		<pubDate>Mon, 02 Sep 2013 19:00:26 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=122</guid>
		<description><![CDATA[The following is a basic command to continue (part of) a Subversion repository as a git repository. git svn clone -A authors --no-metadata --localtime $URL The file authors can be initially empty. The process will be interrupted when an unknown author is encountered. The format is: username = Firstname Lastname &#60;email&#62; Alternatively, if you want [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>The following is a basic command to continue (part of) a Subversion repository as a git repository.<br />
<span id="more-122"></span></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> clone <span style="color: #660033;">-A</span> authors <span style="color: #660033;">--no-metadata</span> <span style="color: #660033;">--localtime</span> <span style="color: #007800;">$URL</span></pre></td></tr></table></div>

<p>The file <tt>authors</tt> can be initially empty. The process will be interrupted when an unknown author is encountered. The format is:</p>
<pre>
username = Firstname Lastname &lt;email&gt;
</pre>
<p>Alternatively, if you want to recover the author information from Unix user accounts:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git filter-branch</span> <span style="color: #660033;">--env-filter</span> <span style="color: #ff0000;">&quot;. ~/filter.sh&quot;</span> HEAD</pre></td></tr></table></div>

<p>Where <tt>filter.sh</tt> is something like:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">mail</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(cat /etc/mailname)</span>&quot;</span>
&nbsp;
<span style="color: #007800;">user</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$GIT_AUTHOR_NAME</span>&quot;</span>
<span style="color: #007800;">full</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(getent passwd &quot;$user&quot; | cut -d ':' -f 5 | cut -d ',' -f 1)</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$full</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">GIT_AUTHOR_NAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$full</span>&quot;</span>
        <span style="color: #007800;">GIT_AUTHOR_EMAIL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$user</span>@<span style="color: #007800;">$mail</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">user</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$GIT_COMMITTER_NAME</span>&quot;</span>
<span style="color: #007800;">full</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(getent passwd &quot;$user&quot; | cut -d ':' -f 5 | cut -d ',' -f 1)</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$full</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #007800;">GIT_COMMITTER_NAME</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$full</span>&quot;</span>
        <span style="color: #007800;">GIT_COMMITTER_EMAIL</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$user</span>@<span style="color: #007800;">$mail</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/continue-svn-in-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Abridged git repository history</title>
		<link>http://bruno.defraine.net/techtips/abridged-git-repository-history/</link>
		<comments>http://bruno.defraine.net/techtips/abridged-git-repository-history/#comments</comments>
		<pubDate>Fri, 15 Mar 2013 11:56:27 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=106</guid>
		<description><![CDATA[It is sometimes useful to have a repository for a project that shows only the main points in history. It is possible to start from git repository with full history and create such an abridged history in a separate branch. You can do this efficiently in git by reusing the original tree objects. This post [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>It is sometimes useful to have a repository for a project that shows only the main points in history. It is possible to start from git repository with full history and create such an abridged history in a separate branch. You can do this efficiently in git by reusing the original tree objects. This post will do a walkthrough for the Mediawiki repository.<br />
<span id="more-106"></span></p>
<p>We start with a full repository:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git clone</span> git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>wikimedia<span style="color: #000000; font-weight: bold;">/</span>mediawiki-core.git
<span style="color: #7a0874; font-weight: bold;">cd</span> mediawiki-core
<span style="color: #c20cb9; font-weight: bold;">git config</span> user.name <span style="color: #ff0000;">&quot;Bruno De Fraine&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">git config</span> user.email <span style="color: #ff0000;">&quot;...&quot;</span></pre></td></tr></table></div>

<p>This is a bash function for the main import logic:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> import_mw <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">tag</span>=<span style="color: #007800;">$1</span>
        <span style="color: #007800;">tree</span>=
        <span style="color: #007800;">adate</span>=
        <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> key val; <span style="color: #000000; font-weight: bold;">do</span>
                <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$key</span> <span style="color: #000000; font-weight: bold;">in</span>
                        <span style="color: #c20cb9; font-weight: bold;">tree</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">tree</span>=<span style="color: #007800;">$val</span> <span style="color: #000000; font-weight: bold;">;;</span>
                        author<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">adate</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${val#*&gt; }</span>&quot;</span> <span style="color: #000000; font-weight: bold;">;;</span>
                        <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">break</span> <span style="color: #000000; font-weight: bold;">;;</span>
                <span style="color: #000000; font-weight: bold;">esac</span>
        <span style="color: #000000; font-weight: bold;">done</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git cat-file</span> commit <span style="color: #007800;">$tag</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$tree</span>&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$adate</span>&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> <span style="color: #ff0000;">&quot;Could not read tag commit info&quot;</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
                <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #007800;">head</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git symbolic-ref</span> HEAD<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #007800;">parent</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git rev-parse</span> <span style="color: #660033;">--verify</span> <span style="color: #007800;">$head</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null<span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #007800;">arg</span>=<span style="color: #ff0000;">&quot;-p <span style="color: #007800;">$parent</span>&quot;</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #007800;">arg</span>=
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #007800;">commit</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">GIT_AUTHOR_NAME</span>=<span style="color: #ff0000;">&quot;Wikimedia Foundation&quot;</span> \
           <span style="color: #007800;">GIT_AUTHOR_EMAIL</span>=<span style="color: #ff0000;">&quot;&lt;wikimedia@github.com&gt;&quot;</span> \
           <span style="color: #007800;">GIT_AUTHOR_DATE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$adate</span>&quot;</span> \
           <span style="color: #c20cb9; font-weight: bold;">git commit-tree</span> <span style="color: #007800;">$tree</span> <span style="color: #007800;">$arg</span> <span style="color: #000000; font-weight: bold;">&lt;&lt;&lt;</span><span style="color: #ff0000;">&quot;MediaWiki <span style="color: #007800;">$tag</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                <span style="color: #c20cb9; font-weight: bold;">git update-ref</span> <span style="color: #007800;">$head</span> <span style="color: #007800;">$commit</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #c20cb9; font-weight: bold;">git tag</span> <span style="color: #007800;">$tag</span> <span style="color: #007800;">$commit</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>mw-tags
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$commit</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Commit failed&quot;</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
                <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p>We start a completely independent branch for abridged history and create commit objects for relevant trees in the history:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git symbolic-ref</span> HEAD refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>ABR1_17
<span style="color: #666666; font-style: italic;"># Note: head ABR1_17 does not exist yet</span>
import_mw 1.17.0
<span style="color: #000000; font-weight: bold;">for</span> tag <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000;">1.17</span>.<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">4</span>,<span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>; <span style="color: #000000; font-weight: bold;">do</span> import_mw <span style="color: #007800;">$tag</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>To see the result so far:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git reset</span> <span style="color: #660033;">--hard</span>
<span style="color: #c20cb9; font-weight: bold;">git log</span> <span style="color: #660033;">--format</span>=fuller</pre></td></tr></table></div>

<p>We can fork another branch in our abridged history for a different major version:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Our commit object for 1.17.0 is 35d4f10</span>
<span style="color: #c20cb9; font-weight: bold;">git update-ref</span> refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>ABR1_18 35d4f1055b9254b3b3d915ec782d0c16230516e5
<span style="color: #c20cb9; font-weight: bold;">git symbolic-ref</span> HEAD refs<span style="color: #000000; font-weight: bold;">/</span>heads<span style="color: #000000; font-weight: bold;">/</span>ABR1_18
<span style="color: #000000; font-weight: bold;">for</span> tag <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000;">1.18</span>.<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">0</span>,<span style="color: #000000;">1</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">4</span>,<span style="color: #000000;">5</span>,<span style="color: #000000;">6</span>,<span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>; <span style="color: #000000; font-weight: bold;">do</span> import_mw <span style="color: #007800;">$tag</span>; <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #c20cb9; font-weight: bold;">git reset</span> <span style="color: #660033;">--hard</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> hist ABR1_17 ABR1_18</pre></td></tr></table></div>

<p>And so on for branches ABR1_19 and ABR1_20.</p>
<p>We can then export the abridged repository history to a separate repository:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git remote</span> add abr ..<span style="color: #000000; font-weight: bold;">/</span>mediawiki-core-abridged 
<span style="color: #c20cb9; font-weight: bold;">git push</span> abr ABR1_17
<span style="color: #c20cb9; font-weight: bold;">git push</span> abr ABR1_18
<span style="color: #c20cb9; font-weight: bold;">git push</span> abr ABR1_19
<span style="color: #c20cb9; font-weight: bold;">git push</span> abr ABR1_20
<span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>mediawiki-core-abridged
<span style="color: #7a0874; font-weight: bold;">source</span> ~<span style="color: #000000; font-weight: bold;">/</span>mw-tags
<span style="color: #c20cb9; font-weight: bold;">git gc</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/abridged-git-repository-history/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling merge conflicts with git</title>
		<link>http://bruno.defraine.net/techtips/handling-merge-conflicts-with-git/</link>
		<comments>http://bruno.defraine.net/techtips/handling-merge-conflicts-with-git/#comments</comments>
		<pubDate>Wed, 23 Jan 2013 15:31:09 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=87</guid>
		<description><![CDATA[Like a similar post for Mercurial, this tip tries to document a list of systematic steps to handle merge conflicts with git. List the conflict status (first column = ours, second column = theirs): git status -s Or more detailed (stage 1 = ancestor, stage 2 = ours, stage 3 = theirs): git ls-files -u [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Like a <a href="http://bruno.defraine.net/techtips/handling-merge-conflicts-with-mercurial/" title="Handling merge conflicts with Mercurial">similar post for Mercurial</a>, this tip tries to document a list of systematic steps to handle merge conflicts with git.<br />
<span id="more-87"></span></p>
<ol>
<li>
<div>List the conflict status (first column = ours, second column = theirs):</div>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git status</span> <span style="color: #660033;">-s</span></pre></td></tr></table></div>

<div>Or more detailed (stage 1 = ancestor, stage 2 = ours, stage 3 = theirs):</div>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git ls-files</span> <span style="color: #660033;">-u</span></pre></td></tr></table></div>

</li>
<li>
<div>In case of a <code>git-merge</code>, you can check the history of both heads:</div>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git log</span> <span style="color: #660033;">--graph</span> <span style="color: #660033;">--left-right</span> <span style="color: #660033;">--boundary</span> HEAD...MERGE_HEAD</pre></td></tr></table></div>

<div>Or, to list only the commits that contribute to conflicts:</div>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git log</span> <span style="color: #660033;">--left-right</span> <span style="color: #660033;">--merge</span></pre></td></tr></table></div>

<div>In case of <code>git-rebase</code>, you can investigate the history and the commit that is being applied:</div>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git log</span>
<span style="color: #c20cb9; font-weight: bold;">git show</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> .git<span style="color: #000000; font-weight: bold;">/</span>rebase-apply<span style="color: #000000; font-weight: bold;">/</span>original-commit<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>

</li>
<li>Resolve the conflict:
<ol>
<li>Manual resolution and mark as resolved:

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">git diff</span> <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">git add</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

</li>
<li>Resolution using a tool:

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git mergetool</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

</li>
<li>Resolve by selecting local/other version:

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git checkout</span> <span style="color: #660033;">--ours</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">git checkout</span> <span style="color: #660033;">--theirs</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">git diff</span> <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #c20cb9; font-weight: bold;">git add</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

</li>
<p>Note that <code>git-diff</code> can be used to inspect changes against both parents at the same time. The default is <code>--cc</code> (combined/condensed) which omits those hunks from <code>-c</code> (combined) that are identical to the hunk from either parent (see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-diff-tree.html">git-diff-tree(1)</a>).
</ol>
</li>
<li>
(If the resolution went wrong) You can still redo the merge if it is not yet staged:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git merge-index</span> <span style="color: #c20cb9; font-weight: bold;">git-merge-one-file</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

</li>
<li>
(If you decide the merge was a bad idea, or want to start over) Abort the merge:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git merge</span> <span style="color: #660033;">--abort</span></pre></td></tr></table></div>

<div>Or the rebase:</div>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git rebase</span> <span style="color: #660033;">--abort</span></pre></td></tr></table></div>

</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/handling-merge-conflicts-with-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash Arrays</title>
		<link>http://bruno.defraine.net/techtips/bash-arrays/</link>
		<comments>http://bruno.defraine.net/techtips/bash-arrays/#comments</comments>
		<pubDate>Thu, 10 Jan 2013 09:23:21 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=81</guid>
		<description><![CDATA[Arrays are the main advanced data structure in Bash, but the syntax can be hard to remember. The following list summarizes the main operations. Assigning an entire array: nodes=&#40;a b c d&#41; nodes=&#40;foo*&#41; Copying an entire array: nodes=&#40;&#34;$@&#34;&#41; nodes=&#40;&#34;${values[@]}&#34;&#41; Getting individual elements (zero-based indexing) or the element count: echo ${nodes[i]} echo ${#nodes[@]} Iterating an array: [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Arrays are the main advanced data structure in Bash, but the syntax can be hard to remember. The following list summarizes the main operations.<br />
<span id="more-81"></span></p>
<p>Assigning an entire array:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">nodes</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span>a b c d<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">nodes</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span>foo<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>

<p>Copying an entire array:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">nodes</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;$@&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">nodes</span>=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #007800;">${values[@]}</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>

<p>Getting individual elements (zero-based indexing) or the element count:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${nodes[i]}</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #800000;">${#nodes[@]}</span></pre></td></tr></table></div>

<p>Iterating an array:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> node <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${nodes[@]}</span>&quot;</span>; <span style="color: #000000; font-weight: bold;">do</span> ... <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>; i<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #800000;">${#nodes[@]}</span>; i++<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #007800;">node</span>=<span style="color: #800000;">${nodes[i]}</span>; ... <span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>Appending to an array:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">nodes<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #800000;">${#nodes[@]}</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>=foo</pre></td></tr></table></div>

<p>If you need the last form regularly, it can be simplified with the following shorthand:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> push_back <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;$1[<span style="color: #000099; font-weight: bold;">\$</span>{#$1[@]}]=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\$</span>2<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
push_back nodes foo</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/bash-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Makefile auto dependencies with GCC</title>
		<link>http://bruno.defraine.net/techtips/makefile-auto-dependencies-with-gcc/</link>
		<comments>http://bruno.defraine.net/techtips/makefile-auto-dependencies-with-gcc/#comments</comments>
		<pubDate>Fri, 12 Oct 2012 11:53:06 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=74</guid>
		<description><![CDATA[There are many ways of having automatic dependencies in a Makefile. The following, however, is the most clean and complete solution that I know of for modern compilers. GNU Make has a number of builtin rules and variables for building programs, for example, for C: COMPILE.c = $&#40;CC&#41; $&#40;CFLAGS&#41; $&#40;CPPFLAGS&#41; $&#40;TARGET_ARCH&#41; -c LINK.o = $&#40;CC&#41; [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>There are <a href="http://mad-scientist.net/make/autodep.html" title="Autodependencies with GNU make">many ways</a> of having automatic dependencies in a <code>Makefile</code>. The following, however, is the most clean and complete solution that I know of for modern compilers.<br />
<span id="more-74"></span></p>
<p>GNU Make has a number of builtin rules and variables for building programs, for example, for C:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="make" style="font-family:monospace;">COMPILE<span style="color: #004400;">.</span>c <span style="color: #004400;">=</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">CC</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">CFLAGS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">CPPFLAGS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">TARGET_ARCH</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">-</span>c
LINK<span style="color: #004400;">.</span>o <span style="color: #004400;">=</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">CC</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">LDFLAGS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">TARGET_ARCH</span><span style="color: #004400;">&#41;</span>
OUTPUT_OPTION <span style="color: #004400;">=</span> <span style="color: #004400;">-</span>o <span style="color: #000088; font-weight: bold;">$@</span>
&nbsp;
<span style="color: #004400;">%.</span>o<span style="color: #004400;">:</span> <span style="color: #004400;">%.</span>c
	<span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span>COMPILE<span style="color: #004400;">.</span>c<span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">OUTPUT_OPTION</span><span style="color: #004400;">&#41;</span> <span style="color: #000088; font-weight: bold;">$&lt;</span>
&nbsp;
<span style="color: #004400;">%:</span> <span style="color: #004400;">%.</span>o
	<span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span>LINK<span style="color: #004400;">.</span>o<span style="color: #004400;">&#41;</span> <span style="color: #000088; font-weight: bold;">$^</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">LOADLIBES</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">LDLIBS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">-</span>o <span style="color: #000088; font-weight: bold;">$@</span></pre></td></tr></table></div>

<p>Because of these builtins, a basic <code>Makefile</code> for a C project with <code>gcc</code> can be quite simple:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="make" style="font-family:monospace;">CC<span style="color: #004400;">=</span>gcc
LDLIBS<span style="color: #004400;">=-</span>lm
&nbsp;
SRC<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>c<span style="color: #004400;">&#41;</span>
OBJ<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span>SRC<span style="color: #004400;">:.</span>c<span style="color: #004400;">=.</span>o<span style="color: #004400;">&#41;</span>
&nbsp;
<span style="color: #990000;">.PHONY</span><span style="color: #004400;">:</span> clean
&nbsp;
foo<span style="color: #004400;">:</span> foo<span style="color: #004400;">.</span>o bar<span style="color: #004400;">.</span>o
&nbsp;
clean<span style="color: #004400;">:</span>
        rm <span style="color: #004400;">-</span>f <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">OBJ</span><span style="color: #004400;">&#41;</span> foo</pre></td></tr></table></div>

<p>This will not track dependencies on headers and other include files, so this will not properly rebuild when these files are updated. With not too much modification, we can ask <code>gcc</code> to output a dependency file next to each object file that is produced. We ask <code>make</code> to include these dependency files where available:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="make" style="font-family:monospace;">CC<span style="color: #004400;">=</span>gcc
OUTPUT_OPTION<span style="color: #004400;">=-</span>MMD <span style="color: #004400;">-</span>MP <span style="color: #004400;">-</span>o <span style="color: #000088; font-weight: bold;">$@</span>
LDLIBS<span style="color: #004400;">=-</span>lm
&nbsp;
SRC<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>c<span style="color: #004400;">&#41;</span>
OBJ<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span>SRC<span style="color: #004400;">:.</span>c<span style="color: #004400;">=.</span>o<span style="color: #004400;">&#41;</span>
DEP<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span>SRC<span style="color: #004400;">:.</span>c<span style="color: #004400;">=.</span>d<span style="color: #004400;">&#41;</span>
&nbsp;
<span style="color: #990000;">.PHONY</span><span style="color: #004400;">:</span> clean
&nbsp;
foo<span style="color: #004400;">:</span> foo<span style="color: #004400;">.</span>o bar<span style="color: #004400;">.</span>o
&nbsp;
<span style="color: #004400;">-</span><span style="color: #666622; font-weight: bold;">include</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">DEP</span><span style="color: #004400;">&#41;</span>
&nbsp;
clean<span style="color: #004400;">:</span>
        rm <span style="color: #004400;">-</span>f <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">OBJ</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">DEP</span><span style="color: #004400;">&#41;</span> foo</pre></td></tr></table></div>

<p>The options will generate dependency files alongside compilation (<code>-MMD</code> instead of <code>-MM</code>), and with phony targets (<code>-MP</code>) for dependencies. The rationale for doing this is described in <a href="http://scottmcpeak.com/autodepend/autodepend.html" title="Autodependencies with GNU make">Autodependencies with GNU make</a>, although this article dates from a time when apparently only <code>-MM</code> was available. The options <code>-MMD -MP</code> are a modern way of implementing what is proposed in the article.</p>
<p>Besides GCC, also Clang 3.0 and ICC 12.1 seem to support these options.</p>
]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/makefile-auto-dependencies-with-gcc/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Makefile for LaTeX documents</title>
		<link>http://bruno.defraine.net/techtips/makefile-for-latex/</link>
		<comments>http://bruno.defraine.net/techtips/makefile-for-latex/#comments</comments>
		<pubDate>Thu, 04 Oct 2012 07:53:52 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=68</guid>
		<description><![CDATA[This is a Makefile that I&#8217;ve perfected over the years for rendering typical LaTeX articles or presentations (e.g. for scientific papers). It handles almost all LaTeX documents, except for large documents that use the \include feature (this is for another tip). It assumes your document has a bibtex bibliography. The Makefile works out of the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This is a <code>Makefile</code> that I&#8217;ve perfected over the years for rendering typical LaTeX articles or presentations (e.g. for scientific papers). It handles almost all LaTeX documents, except for large documents that use the <a href="http://www.giss.nasa.gov/tools/latex/ltx-245.html"><tt>\include</tt> feature</a> (this is for another tip). It assumes your document has a <code>bibtex</code> bibliography.<br />
<span id="more-68"></span></p>
<p>The <code>Makefile</code> works out of the box, you only have to configure the jobname (=name of the main <tt>.tex</tt>-file). Most common prerequisites are automatically detected:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="make" style="font-family:monospace;">LATEXFLAGS?<span style="color: #004400;">=-</span>interaction<span style="color: #004400;">=</span>nonstopmode <span style="color: #004400;">-</span>file<span style="color: #004400;">-</span>line<span style="color: #004400;">-</span><span style="color: #666622; font-weight: bold;">error</span>
PDFLATEX<span style="color: #004400;">=</span>pdflatex
BIBTEX<span style="color: #004400;">=</span>bibtex
&nbsp;
JOB<span style="color: #004400;">=</span>paper
TEXS<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>tex<span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>sty<span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>cls<span style="color: #004400;">&#41;</span>
PICS<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>png<span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">filter-out</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>pdf<span style="color: #004400;">,$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>pdf<span style="color: #004400;">&#41;</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>jpg<span style="color: #004400;">&#41;</span>
BIBS<span style="color: #004400;">=$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>bib<span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #0000CC; font-weight: bold;">wildcard</span> <span style="color: #004400;">*.</span>bst<span style="color: #004400;">&#41;</span>
&nbsp;
<span style="color: #990000;">.DEFAULT</span><span style="color: #004400;">:</span> all
<span style="color: #990000;">.PHONY</span><span style="color: #004400;">:</span> all clean
&nbsp;
all<span style="color: #004400;">:</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>pdf
&nbsp;
<span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux<span style="color: #004400;">:</span> <span style="color: #004400;">|</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">TEXS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">PICS</span><span style="color: #004400;">&#41;</span>
        <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">PDFLATEX</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">LATEXFLAGS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span>
&nbsp;
<span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>bbl<span style="color: #004400;">:</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">BIBS</span><span style="color: #004400;">&#41;</span>
        <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">BIBTEX</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span>
&nbsp;
<span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>pdf<span style="color: #004400;">:</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">TEXS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">PICS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>bbl
        <span style="color: #004400;">@</span>cp <span style="color: #004400;">-</span>p <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux<span style="color: #004400;">.</span>bak
        <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">PDFLATEX</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">LATEXFLAGS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span>
        <span style="color: #004400;">@</span>if cmp <span style="color: #004400;">-</span>s <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux<span style="color: #004400;">.</span>bak<span style="color: #004400;">;</span> \
        then touch <span style="color: #004400;">-</span>r <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux<span style="color: #004400;">.</span>bak <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux<span style="color: #004400;">;</span> \
        <span style="color: #666622; font-weight: bold;">else</span> NEWS<span style="color: #004400;">=</span><span style="color: #CC2200;">&quot;$$NEWS -W $(JOB).aux&quot;</span><span style="color: #004400;">;</span> fi<span style="color: #004400;">;</span> rm <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux<span style="color: #004400;">.</span>bak<span style="color: #004400;">;</span> \
        if <span style="color: #004400;">&#91;</span> <span style="color: #004400;">-</span>n <span style="color: #CC2200;">&quot;$$NEWS&quot;</span> <span style="color: #004400;">&#93;</span><span style="color: #004400;">;</span> then <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">MAKE</span><span style="color: #004400;">&#41;</span> <span style="color: #000088; font-weight: bold;">$$</span>NEWS <span style="color: #000088; font-weight: bold;">$@</span><span style="color: #004400;">;</span> fi
&nbsp;
clean<span style="color: #004400;">:</span>
        rm <span style="color: #004400;">-</span>f <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>aux <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>log <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>blg <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>bbl <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>out <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">JOB</span><span style="color: #004400;">&#41;</span><span style="color: #004400;">.</span>pdf</pre></td></tr></table></div>

<p>LaTeX documents have a circular dependency: a <code>latex</code> run produces a <code>.aux</code>-file, which is read as the input for a following run. You have to keep running <code>latex</code> until this process reaches a <a href="http://en.wikipedia.org/wiki/Fixed-point_combinator" title="Fixed-point combinator">fixpoint</a>. This is handled as follows:</p>
<ol>
<li value="0">An <a href="http://www.gnu.org/software/make/manual/make.html#Prerequisite-Types" title="Types of Prerequisites">order-only prerequisite</a> is used to produce a <code>.aux</code>-file if none exists.</li>
<li>A backup copy of the <code>.aux</code>-file is preserved.</li>
<li><code>latex</code> is ran to produce a new <code>.aux</code>-file.</li>
<li>If the <code>.aux</code>-file differs from the backup copy, <code>make</code> is restarted to go back to step #1.</li>
</ol>
<p>The commands take special care to ensure that <code>make</code> considers the <code>.aux</code>-file as new if (and only if) it has changed.</p>
]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/makefile-for-latex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>H.264/AAC encoding using FFmpeg</title>
		<link>http://bruno.defraine.net/techtips/h264-aac-encoding-using-ffmpeg/</link>
		<comments>http://bruno.defraine.net/techtips/h264-aac-encoding-using-ffmpeg/#comments</comments>
		<pubDate>Tue, 11 Sep 2012 09:49:12 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=63</guid>
		<description><![CDATA[The x264 encoding guide gives a nice explanation of the different options for H.264 encoding. Normally: ffmpeg -i in.avi -strict experimental -crf 23 -preset medium out.m4v Where you can deviate from the above defaults: -crf [18-28] perceived output quality (lower crf is better quality) -preset [ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow] compression effort (slower preset is better compression)]]></description>
				<content:encoded><![CDATA[<p>The <a href="http://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide">x264 encoding guide</a> gives a nice explanation of the different options for H.264 encoding. Normally:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> in.avi <span style="color: #660033;">-strict</span> experimental <span style="color: #660033;">-crf</span> <span style="color: #000000;">23</span> <span style="color: #660033;">-preset</span> medium out.m4v</pre></td></tr></table></div>

<p>Where you can deviate from the above defaults:</p>
<dl>
<dt>-crf [18-28]</dt>
<dd>perceived output quality (lower crf is better quality)</dd>
<dt>-preset [ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow]</dt>
<dd>compression effort (slower preset is better compression)</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/h264-aac-encoding-using-ffmpeg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joining H.264/AAC video files</title>
		<link>http://bruno.defraine.net/techtips/joining-h264-aac-video-files/</link>
		<comments>http://bruno.defraine.net/techtips/joining-h264-aac-video-files/#comments</comments>
		<pubDate>Tue, 11 Sep 2012 09:19:37 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=60</guid>
		<description><![CDATA[It is possible to join H.264/AAC video files without re-enconding, if you convert them to an MPEG transport stream (TS). This format supports concatenation. Of course, the video files need to have the same height and width, aspect ratio,&#8230; Using ffmpeg: ffmpeg -i 01.m4v -c copy -bsf:v h264_mp4toannexb 01.ts ffmpeg -i 02.m4v -c copy -bsf:v [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>It is possible to join H.264/AAC video files without re-enconding, if you convert them to an MPEG transport stream (TS). This format supports concatenation. Of course, the video files need to have the same height and width, aspect ratio,&#8230;<br />
<span id="more-60"></span></p>
<p>Using <code>ffmpeg</code>:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> 01.m4v <span style="color: #660033;">-c</span> copy -bsf:v h264_mp4toannexb 01.ts
<span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> 02.m4v <span style="color: #660033;">-c</span> copy -bsf:v h264_mp4toannexb 02.ts
<span style="color: #c20cb9; font-weight: bold;">ffmpeg</span> <span style="color: #660033;">-i</span> concat:<span style="color: #ff0000;">&quot;01.ts|02.ts&quot;</span> <span style="color: #660033;">-c</span> copy -bsf:a aac_adtstoasc join.m4v
<span style="color: #c20cb9; font-weight: bold;">rm</span> 01.ts 02.ts</pre></td></tr></table></div>

<p>The bitstream filters take care of container requirements.</p>
]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/joining-h264-aac-video-files/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Decoding UTF-8 streams</title>
		<link>http://bruno.defraine.net/techtips/decoding-utf-8-streams/</link>
		<comments>http://bruno.defraine.net/techtips/decoding-utf-8-streams/#comments</comments>
		<pubDate>Thu, 06 Sep 2012 15:10:43 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=56</guid>
		<description><![CDATA[UTF-8 is one of the most commonly used methods to encode unicode characters into byte values. It has some interesting properties, for example, characters from the ASCII codeset retain their encoding. This is an implementation of UTF-8 decoding in OCaml. The interface of the decoder is: val utf8_decode : char Stream.t -&#62; int Stream.t The [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> is one of the most commonly used methods to encode unicode characters into byte values. It has some interesting properties, for example, characters from the ASCII codeset retain their encoding. This is an implementation of UTF-8 decoding in OCaml.<br />
<span id="more-56"></span></p>
<p>The interface of the decoder is:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">val</span> utf8_decode <span style="color: #a52a2a;">:</span> <span style="color: #06c; font-weight: bold;">char</span> <span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>t <span style="color: #a52a2a;">-&gt;</span> <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>t</pre></td></tr></table></div>

<p>The decoding works lazily on streams, i.e. the resulting stream will decode characters as they are requested. In case of illegal input, the code will raise stream errors.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="ocaml" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">type</span> byte <span style="color: #a52a2a;">=</span> Single <span style="color: #06c; font-weight: bold;">of</span> <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #a52a2a;">|</span> Cont <span style="color: #06c; font-weight: bold;">of</span> <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #a52a2a;">|</span> Leading <span style="color: #06c; font-weight: bold;">of</span> <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #a52a2a;">*</span> <span style="color: #06c; font-weight: bold;">int</span> <span style="color: #a52a2a;">|</span> Invalid
&nbsp;
<span style="color: #5d478b; font-style: italic;">(** [classify chr] returns the {!byte} corresponding to [chr] *)</span>
<span style="color: #06c; font-weight: bold;">let</span> classify chr <span style="color: #a52a2a;">=</span>
    <span style="color: #06c; font-weight: bold;">let</span> c <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">int_of_char</span> chr <span style="color: #06c; font-weight: bold;">in</span>
    <span style="color: #5d478b; font-style: italic;">(* Classify byte according to leftmost 0 bit *)</span>
    <span style="color: #06c; font-weight: bold;">if</span> c <span style="color: #06c; font-weight: bold;">land</span> 0x80 <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> Single c
    <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> c <span style="color: #06c; font-weight: bold;">land</span> 0x40 <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> Cont <span style="color: #a52a2a;">&#40;</span>c <span style="color: #06c; font-weight: bold;">land</span> 0x3f<span style="color: #a52a2a;">&#41;</span>
    <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> c <span style="color: #06c; font-weight: bold;">land</span> 0x20 <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> Leading <span style="color: #a52a2a;">&#40;</span><span style="color: #c6c;">1</span>, c <span style="color: #06c; font-weight: bold;">land</span> 0x1f<span style="color: #a52a2a;">&#41;</span>
    <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> c <span style="color: #06c; font-weight: bold;">land</span> 0x10 <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> Leading <span style="color: #a52a2a;">&#40;</span><span style="color: #c6c;">2</span>, c <span style="color: #06c; font-weight: bold;">land</span> 0x0f<span style="color: #a52a2a;">&#41;</span>
    <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> c <span style="color: #06c; font-weight: bold;">land</span> 0x08 <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> Leading <span style="color: #a52a2a;">&#40;</span><span style="color: #c6c;">3</span>, c <span style="color: #06c; font-weight: bold;">land</span> 0x07<span style="color: #a52a2a;">&#41;</span>
    <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> c <span style="color: #06c; font-weight: bold;">land</span> 0x04 <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> Leading <span style="color: #a52a2a;">&#40;</span><span style="color: #c6c;">4</span>, c <span style="color: #06c; font-weight: bold;">land</span> 0x03<span style="color: #a52a2a;">&#41;</span>
    <span style="color: #06c; font-weight: bold;">else</span> <span style="color: #06c; font-weight: bold;">if</span> c <span style="color: #06c; font-weight: bold;">land</span> 0x02 <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> Leading <span style="color: #a52a2a;">&#40;</span><span style="color: #c6c;">5</span>, c <span style="color: #06c; font-weight: bold;">land</span> 0x01<span style="color: #a52a2a;">&#41;</span>
    <span style="color: #06c; font-weight: bold;">else</span> Invalid
&nbsp;
<span style="color: #5d478b; font-style: italic;">(** [follow strm n c] returns the code point based on [c] plus [n] continuation
    bytes taken from [strm] *)</span>
<span style="color: #06c; font-weight: bold;">let</span> <span style="color: #06c; font-weight: bold;">rec</span> follow strm n c <span style="color: #a52a2a;">=</span>
    <span style="color: #06c; font-weight: bold;">if</span> n <span style="color: #a52a2a;">=</span> <span style="color: #c6c;">0</span> <span style="color: #06c; font-weight: bold;">then</span> c
    <span style="color: #06c; font-weight: bold;">else</span>
        <span style="color: #a52a2a;">&#40;</span><span style="color: #06c; font-weight: bold;">match</span> classify <span style="color: #a52a2a;">&#40;</span><span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>next strm<span style="color: #a52a2a;">&#41;</span> <span style="color: #06c; font-weight: bold;">with</span>
        <span style="color: #a52a2a;">|</span> Cont cc <span style="color: #a52a2a;">-&gt;</span> follow strm <span style="color: #a52a2a;">&#40;</span>n<span style="color: #a52a2a;">-</span><span style="color: #c6c;">1</span><span style="color: #a52a2a;">&#41;</span> <span style="color: #a52a2a;">&#40;</span><span style="color: #a52a2a;">&#40;</span>c <span style="color: #06c; font-weight: bold;">lsl</span> <span style="color: #c6c;">6</span><span style="color: #a52a2a;">&#41;</span> lor <span style="color: #a52a2a;">&#40;</span>cc <span style="color: #06c; font-weight: bold;">land</span> 0x3f<span style="color: #a52a2a;">&#41;</span><span style="color: #a52a2a;">&#41;</span>
        <span style="color: #a52a2a;">|</span> _ <span style="color: #a52a2a;">-&gt;</span> <span style="color: #06c; font-weight: bold;">raise</span> <span style="color: #a52a2a;">&#40;</span><span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>Error <span style="color: #3cb371;">&quot;Continuation byte expected&quot;</span><span style="color: #a52a2a;">&#41;</span><span style="color: #a52a2a;">&#41;</span>
&nbsp;
<span style="color: #5d478b; font-style: italic;">(** [utf8_decode strm] returns a code point stream that will lazily decode
    the byte stream [strm] *)</span>
<span style="color: #06c; font-weight: bold;">let</span> <span style="color: #06c; font-weight: bold;">rec</span> utf8_decode strm <span style="color: #a52a2a;">=</span>
    <span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>slazy <span style="color: #a52a2a;">&#40;</span><span style="color: #06c; font-weight: bold;">fun</span> <span style="color: #a52a2a;">&#40;</span><span style="color: #a52a2a;">&#41;</span> <span style="color: #a52a2a;">-&gt;</span>
        <span style="color: #06c; font-weight: bold;">match</span> <span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>peek strm <span style="color: #06c; font-weight: bold;">with</span>
        <span style="color: #a52a2a;">|</span> Some chr <span style="color: #a52a2a;">-&gt;</span>
            <span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>junk strm<span style="color: #a52a2a;">;</span>
            <span style="color: #a52a2a;">&#40;</span><span style="color: #06c; font-weight: bold;">match</span> classify chr <span style="color: #06c; font-weight: bold;">with</span>
            <span style="color: #a52a2a;">|</span> Single c <span style="color: #a52a2a;">-&gt;</span> <span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>icons c <span style="color: #a52a2a;">&#40;</span>utf8_decode strm<span style="color: #a52a2a;">&#41;</span>
            <span style="color: #a52a2a;">|</span> Cont _ <span style="color: #a52a2a;">-&gt;</span> <span style="color: #06c; font-weight: bold;">raise</span> <span style="color: #a52a2a;">&#40;</span><span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>Error <span style="color: #3cb371;">&quot;Unexpected continuation byte&quot;</span><span style="color: #a52a2a;">&#41;</span>
            <span style="color: #a52a2a;">|</span> Leading <span style="color: #a52a2a;">&#40;</span>n, c<span style="color: #a52a2a;">&#41;</span> <span style="color: #a52a2a;">-&gt;</span>
                <span style="color: #06c; font-weight: bold;">let</span> c <span style="color: #a52a2a;">=</span> follow strm n c <span style="color: #06c; font-weight: bold;">in</span>
                <span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>icons c <span style="color: #a52a2a;">&#40;</span>utf8_decode strm<span style="color: #a52a2a;">&#41;</span>
            <span style="color: #a52a2a;">|</span> Invalid <span style="color: #a52a2a;">-&gt;</span> <span style="color: #06c; font-weight: bold;">raise</span> <span style="color: #a52a2a;">&#40;</span><span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>Error <span style="color: #3cb371;">&quot;Invalid byte&quot;</span><span style="color: #a52a2a;">&#41;</span><span style="color: #a52a2a;">&#41;</span>
        <span style="color: #a52a2a;">|</span> None <span style="color: #a52a2a;">-&gt;</span> <span style="color: #06c; font-weight: bold;">Stream</span><span style="color: #a52a2a;">.</span>sempty<span style="color: #a52a2a;">&#41;</span></pre></td></tr></table></div>

<p>Posted at the occassion of <a href="https://plus.google.com/u/0/101960720994009339267/posts/Rz1udTvtiMg">20 years of UTF-8</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/decoding-utf-8-streams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using wget to mirror entire website folder</title>
		<link>http://bruno.defraine.net/techtips/using-wget-to-mirror-entire-website-folder/</link>
		<comments>http://bruno.defraine.net/techtips/using-wget-to-mirror-entire-website-folder/#comments</comments>
		<pubDate>Fri, 31 Aug 2012 07:08:34 +0000</pubDate>
		<dc:creator><![CDATA[bruno]]></dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://bruno.defraine.net/techtips/?p=45</guid>
		<description><![CDATA[GNU wget can create a very usable local or offline mirror of an entire folder of a website using the following combination of options. From the output directory, use this invocation: URL=http://www.emsl.pnl.gov/docs/global/index.shtml wget -r -l inf -k -N -np -p -E $URL You can play around with the options: -r recursive -l inf follow link [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.gnu.org/software/wget/" title="Wget">GNU wget</a> can create a very usable local or offline mirror of an entire folder of a website using the following combination of options.<br />
<span id="more-45"></span></p>
<p>From the output directory, use this invocation:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">URL</span>=http:<span style="color: #000000; font-weight: bold;">//</span>www.emsl.pnl.gov<span style="color: #000000; font-weight: bold;">/</span>docs<span style="color: #000000; font-weight: bold;">/</span>global<span style="color: #000000; font-weight: bold;">/</span>index.shtml
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-r</span> <span style="color: #660033;">-l</span> inf <span style="color: #660033;">-k</span> <span style="color: #660033;">-N</span> <span style="color: #660033;">-np</span> <span style="color: #660033;">-p</span> <span style="color: #660033;">-E</span> <span style="color: #007800;">$URL</span></pre></td></tr></table></div>

<p>You can play around with the options:</p>
<dl>
<dt>-r</dt>
<dd>recursive</dd>
<dt>-l inf</dt>
<dd>follow link infinitely</dd>
<dt>-k</dt>
<dd>convert links after downloading</dd>
<dt>-N</dt>
<dd>time-stamping</dd>
<dt>-np</dt>
<dd>no parent</dd>
<dt>-p</dt>
<dd>retrieve prerequisites of pages</dd>
<dt>-E</dt>
<dd>page extensions according to MIME type</dd>
</dl>
<p>The files will be stored under <code>hostname/path/to/file</code>. If you know up front that the origin of the files is restricted to a particular host or even subpath, you can additionally use:</p>
<dl>
<dt>-nH</dt>
<dd>no subdir for host</dd>
<dt>&#8211;cut-dirs=<em>N</em></dt>
<dd>strip <em>N</em> path components</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://bruno.defraine.net/techtips/using-wget-to-mirror-entire-website-folder/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
