<?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>apt-get install debian-wizard&#187; Git</title>
	<atom:link href="http://raphaelhertzog.com/tag/git/feed/" rel="self" type="application/rss+xml" />
	<link>http://raphaelhertzog.com</link>
	<description>Insider infos, master your Debian/Ubuntu distribution</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:16:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>3-way merge of Debian changelog files</title>
		<link>http://raphaelhertzog.com/2009/10/08/3-way-merge-of-debian-changelog-files/</link>
		<comments>http://raphaelhertzog.com/2009/10/08/3-way-merge-of-debian-changelog-files/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 19:39:22 +0000</pubDate>
		<dc:creator>Raphaël Hertzog</dc:creator>
				<category><![CDATA[Debian News]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[dpkg]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[vcs-pkg]]></category>

		<guid isPermaLink="false">http://raphaelhertzog.com/?p=223</guid>
		<description><![CDATA[I&#8217;ve been considering for some time now to create a merge tool specifically suited for debian/changelog files. My goal was to let Git use it automatically thanks to gitattributes. I&#8217;ve just gone ahead, so let me introduce you git-merge-dch. Grab it with git clone git://git.debian.org/~hertzog/git-merge-dch.git, you can build a package if you wish. Beware, you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been considering for some time now to create a merge tool specifically suited for debian/changelog files. My goal was to let Git use it automatically thanks to gitattributes.</p>
<p>I&#8217;ve just gone ahead, so let me introduce you <code><strong>git-merge-dch</strong></code>. Grab it with <code>git clone git://git.debian.org/~hertzog/git-merge-dch.git</code>, you can build a package if you wish. Beware, you need to have a dpkg-dev 1.15.5 that is not yet published (so you need to build dpkg from its git repository, <code>git clone git://git.debian.org/dpkg/dpkg.git</code>) as I rely on features that I introduced recently&#8230; you will also need the libalgorithm-merge-perl package.</p>
<p>Using it in a git repository requires two changes:</p>
<ul>
<li>defining a new merge driver somewhere in the git configuration (in <code>.git/config</code> or <code>~/.gitconfig</code> for example):
<pre>
[merge "git-merge-dch"]
        name = debian/changelog merge driver
        driver = git-merge-dch -m %O %A %B %A
</pre>
</li>
<li>defining the merge attribute for debian/changelog files either in <code>.gitattributes</code> in the repository itself or in <code>.git/info/attributes</code>:
<pre>
debian/changelog merge=git-merge-dch
</pre>
</li>
</ul>
<p>Now you can safely maintain two branches of a package with changelog files evolving separately and merge one into the other without creating undue conflicts. Suppose you created an experimental branch for version 2.28 (you use a version 2.28-1~exp1) when 2.26.2 was current stable in the master branch. In the mean time, 2.26.3 got out and was packaged in master. Next time you merge stable into experimental, the changelog entries for 2.28 and 2.26.3 won&#8217;t collide despite being at the same place in the changelog file compared to the common ancestor.</p>
<p>Let&#8217;s continue with this example, 2.28 is out. Instead of adding a new changelog entry with &#8220;New upstream release&#8221; without further changes, you keep the current changelog entry and simply change the version into 2.28-1. While preparing this you discover a branch with fixes that was based on 2.28-1~exp1, if you merge it it will reintroduce a 2.28-1~exp1 entry that you don&#8217;t want. Fortunately you can use the <code>--merge-prereleases</code> (-m) option of <code>git-merge-dch</code> so that it strip the prerelease part of the version string and considers 2.28-1~exp1 and 2.28-1 to be the same entry really.</p>
<p>The only limitation is that this merge tool will remove any lines which are not parsed by Dpkg::Changelog (and which in theory are not supposed to be there).</p>
<p>Feel free to test, share your comments, report bugs and send patches!</p>
<p><strong>Update</strong>: the script has been merged in dpkg-dev (>= 1.15.7) under the name dpkg-mergechangelogs.</p>
<p style="font-size: smaller"><a href="http://raphaelhertzog.com/2009/10/08/3-way-merge-of-debian-changelog-files/#comments">6 comments</a> | Liked this article? <a href="http://raphaelhertzog.com/support-my-work/">Click here</a>. | My blog is <a href="http://flattr.com/thing/26545/apt-get-install-debian-wizard">Flattr-enabled</a>.</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://raphaelhertzog.com/2009/10/08/3-way-merge-of-debian-changelog-files/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Git, CIA and branch merging</title>
		<link>http://raphaelhertzog.com/2008/07/07/git-cia-branch-merging/</link>
		<comments>http://raphaelhertzog.com/2008/07/07/git-cia-branch-merging/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 07:36:42 +0000</pubDate>
		<dc:creator>Raphaël Hertzog</dc:creator>
				<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://raphaelhertzog.com/?p=158</guid>
		<description><![CDATA[Dear Joey, we also had this problem for dpkg, that&#8217;s why I hacked the /usr/local/bin/git-commit-notice script that we&#8217;re using on Alioth to do something like this instead: while read oldrev newrev refname; do branchname=${refname#refs/heads/} &#91; &#34;$branchname&#34; = &#34;master&#34; &#93; &#38;&#38; branchname=&#34;&#34; for merged in $&#40;git rev-parse --not --branches &#124; grep -v $&#40;git rev-parse $refname&#41; &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>Dear <a href="http://kitenet.net/~joey/blog/entry/lazyweb:_git_cia_hooks/">Joey</a>, we also had this problem for dpkg, that&#8217;s why I hacked the /usr/local/bin/git-commit-notice script that we&#8217;re using on Alioth to do something like this instead:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> oldrev newrev refname; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">branchname</span>=<span style="color: #800000;">${refname#refs/heads/}</span>
    <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$branchname</span>&quot;</span> = <span style="color: #ff0000;">&quot;master&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #007800;">branchname</span>=<span style="color: #ff0000;">&quot;&quot;</span>
    <span style="color: #000000; font-weight: bold;">for</span> merged <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span> rev-parse <span style="color: #660033;">--not</span> <span style="color: #660033;">--branches</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-v</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span> rev-parse <span style="color: #007800;">$refname</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">git</span> rev-list <span style="color: #660033;">--reverse</span> <span style="color: #660033;">--stdin</span> <span style="color: #007800;">$oldrev</span>..<span style="color: #007800;">$newrev</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
         <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>git-ciabot.pl <span style="color: #007800;">$merged</span> <span style="color: #007800;">$branchname</span>
    <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>It will stop git rev-list each time that it encounters a commit that is available in any of the other branches present in the repository and thus when you merge a branch, you only see the merge commit in CIA.</p>
<p>You should also note that the script is smarter as it calls CIA only for branch updates, not for tag creation (and other kinds of updates) where it only leads to strange errors IIRC.</p>
<p style="font-size: smaller"><a href="http://raphaelhertzog.com/2008/07/07/git-cia-branch-merging/#comments">10 comments</a> | Liked this article? <a href="http://raphaelhertzog.com/support-my-work/">Click here</a>. | My blog is <a href="http://flattr.com/thing/26545/apt-get-install-debian-wizard">Flattr-enabled</a>.</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://raphaelhertzog.com/2008/07/07/git-cia-branch-merging/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Assembling bits of history with git: take two</title>
		<link>http://raphaelhertzog.com/2007/07/28/assembling-bits-of-history-with-git-take-two/</link>
		<comments>http://raphaelhertzog.com/2007/07/28/assembling-bits-of-history-with-git-take-two/#comments</comments>
		<pubDate>Sat, 28 Jul 2007 16:44:13 +0000</pubDate>
		<dc:creator>Raphaël Hertzog</dc:creator>
				<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://raphaelhertzog.com/2007/07/28/assembling-bits-of-history-with-git-take-two/</guid>
		<description><![CDATA[Following my previous article, I had some interesting comments introducing me to git-filter-branch (which is a new function coming from cogito&#8217;s cg-admin-rewritehist). This command is really designed to rewrite the history and you can do much more changes&#8230; it enabled me to fix the dates/authors/committers/logs of all the commits that were created with git_load_dirs. It [...]]]></description>
			<content:encoded><![CDATA[<p>Following <a href="http://raphaelhertzog.com/2007/07/24/assembling-bits-of-history-with-git/">my previous article</a>, I had some interesting comments introducing me to <code>git-filter-branch</code> (which is a new function coming from cogito&#8217;s <code>cg-admin-rewritehist</code>). This command is really designed to rewrite the history and you can do much more changes&#8230; it enabled me to fix the dates/authors/committers/logs of all the commits that were created with git_load_dirs. It can also be used to add one or more &#8220;parent commits&#8221; to any commit.</p>
<p>In parallel I discovered some problems with the git repository that I created: the tags were no more pointing to my master branch. This is because <code>git rebase</code> won&#8217;t convert them while rewriting history.</p>
<p>This lead me to redo everything from scratch. This time I used <code>git-filter-branch</code> instead. The man page even gives an example of how to link two branches together as if one was the predecessor of the other. Here&#8217;s how you can do it: let&#8217;s bind together &#8220;old&#8221; and &#8220;new&#8221;&#8230; the resulting branch will be &#8220;new-rewritten&#8221;.</p>
<pre>
$ git rev-parse old
0975870bb1631379f2da798fa78736a4fe32960a
$ git checkout new
$ git-filter-branch --tag-name-filter=cat --parent-filter \
"sed -e 's/^$/-p 0975870bb1631379f2da798fa78736a4fe32960a/'" \
new-rewritten
[...]
Rewritten history saved to the new-rewritten branch
</pre>
<p>Short explanation: the only commit without a parent commit (thus matching the empty regex &#8220;^$&#8221;) is the root commit and this one is changed to have a parent (-p) which is the last commit of the branch &#8220;old&#8221;.</p>
<p>At the end, you remove all the temporary branches, keep only what&#8217;s needed and repack everything to save space:</p>
<p><code><br />
$ git branch -D old new<br />
$ git prune<br />
$ git repack -a -d<br />
</code></p>
<p style="font-size: smaller"><a href="http://raphaelhertzog.com/2007/07/28/assembling-bits-of-history-with-git-take-two/#comments">2 comments</a> | Liked this article? <a href="http://raphaelhertzog.com/support-my-work/">Click here</a>. | My blog is <a href="http://flattr.com/thing/26545/apt-get-install-debian-wizard">Flattr-enabled</a>.</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://raphaelhertzog.com/2007/07/28/assembling-bits-of-history-with-git-take-two/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Assembling bits of history with git</title>
		<link>http://raphaelhertzog.com/2007/07/24/assembling-bits-of-history-with-git/</link>
		<comments>http://raphaelhertzog.com/2007/07/24/assembling-bits-of-history-with-git/#comments</comments>
		<pubDate>Tue, 24 Jul 2007 12:14:25 +0000</pubDate>
		<dc:creator>Raphaël Hertzog</dc:creator>
				<category><![CDATA[Tips and tricks]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://raphaelhertzog.com/2007/07/24/assembling-bits-of-history-with-git/</guid>
		<description><![CDATA[The dpkg team has a nice history of changing VCS over time. At the beginning, Ian Jackson simply uploaded new tarballs, then CVS was used during a few years, then Arch got used and up to now Subversion was used. When the subversion repository got created, the arch history has not been integrated as somehow [...]]]></description>
			<content:encoded><![CDATA[<p>The dpkg team has a nice history of changing VCS over time. At the beginning, Ian Jackson simply uploaded new tarballs, then CVS was used during a few years, then Arch got used and up to now Subversion was used. When the subversion repository got created, the arch history has not been integrated as somehow the conversion tools didn&#8217;t work.</p>
<p>Now we&#8217;re likely to move over git for various reasons and we wanted to get back the various bits of history stored in the different VCS. Unfortunately we lost the arch repository. So we have disjoints bits of history and we want to put them all in a single nice git branch&#8230; git comes with git-cvsimport, git-archimport and git-svnimport, so converting CVS/SVN/Arch repositories is relatively easy. But you end up with several repositories and several branches.</p>
<p>Git comes with a nice feature called &#8220;git rebase&#8221; which is able to replay history over another branch, but for this to work you need to have a common ancestor in the branch used for the rebase. That&#8217;s not the case&#8230; so let&#8217;s try to create that common ancestor! Extracting the first tree from the newest branch and committing it on top on the oldest branch will give that common ancestor because two identical trees will have the same identifier. Using <a href="http://packages.debian.org/git-load-dirs">git_load_dirs</a> you can easily load a tree in your git repository, and &#8220;git archive&#8221; will let you extract the first tree too.</p>
<p>In short, let&#8217;s see how I attach the &#8220;master&#8221; branch of my &#8220;git-svn&#8221; repository to the &#8220;master&#8221; branch of my &#8220;git-cvs&#8221; repository:</p>
<pre>
$ cd git-svn
$ git-rev-list --all | tail -1
0d6ec86c5d05f7e60a484c68d37fb5fc31146c40
$ git-archive --prefix=dpkg-1.13.11/ 0d6ec86c5d05f7e60a484c68d37fb5fc31146c40 | (cd /tmp &amp;&amp; tar xf -)
$ cd ../git-cvs
$ git checkout master
$ git_load_dirs -L"Fake commit to link SVN to older CVS history" /tmp/dpkg-1.13.11
[...]
$ git fetch ../git-svn master:svn
$ git checkout svn
$ git rebase master
</pre>
<p>That&#8217;s it, your svn branch now contains the old cvs history. Repeat as many times as necessary&#8230;</p>
<p style="font-size: smaller"><a href="http://raphaelhertzog.com/2007/07/24/assembling-bits-of-history-with-git/#comments">5 comments</a> | Liked this article? <a href="http://raphaelhertzog.com/support-my-work/">Click here</a>. | My blog is <a href="http://flattr.com/thing/26545/apt-get-install-debian-wizard">Flattr-enabled</a>.</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://raphaelhertzog.com/2007/07/24/assembling-bits-of-history-with-git/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

