<?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>nvie.com</title>
	<atom:link href="http://nvie.com/feed" rel="self" type="application/rss+xml" />
	<link>http://nvie.com</link>
	<description>Anything that interests me.</description>
	<lastBuildDate>Mon, 03 May 2010 17:54:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>An upgrade of gitflow</title>
		<link>http://nvie.com/archives/492</link>
		<comments>http://nvie.com/archives/492#comments</comments>
		<pubDate>Thu, 04 Mar 2010 00:44:20 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[gitflow]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=492</guid>
		<description><![CDATA[Last week, I silently tagged gitflow 0.2. The most important changes since 0.1 are: Order of arguments changed to have a more &#8220;gitish&#8221; subcommand structure. For example, you now say: git flow feature start myfeature Better initializer. git flow init now prompts interactively to set up a gitflow enabled repo. Added a command to list [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I silently tagged <a href="http://github.com/nvie/gitflow/tree/0.2">gitflow 0.2</a>. The most important changes since 0.1 are:</p>
<ul>
<li>Order of arguments changed to have a more &#8220;gitish&#8221; subcommand structure. For example, you now say:
<pre>git flow feature start myfeature</pre>
</li>
<li>Better initializer. <code>git flow init</code> now prompts interactively to set up a gitflow enabled repo.</li>
<li>Added a command to list all feature/release/hotfix/support branches, e.g.:
<pre>git flow feature list</pre>
</li>
<li>Made all merge/rebase operations failsafe, providing a non-destructive workflow in case of merge conflicts.</li>
<li>Easy diff&#8217;ing of all changes on a specific (or the current) feature branch:
<pre>git flow feature diff [feature]</pre>
</li>
<li>Add support for feature branch rebasing:
<pre>git flow feature rebase</pre>
</li>
<li>Some subactions now take name prefixes as their arguments, for convenience. For example, if you have feature branches called &#8220;experimental&#8221;, &#8220;refactoring&#8221; and &#8220;feature-X&#8221;, you could say:
<pre>git flow feature finish ref</pre>
<p>And gitflow will know you mean the &#8220;refactoring&#8221; feature branch.</p>
<p>These actions are: <code>finish</code>, <code>diff</code> and <code>rebase</code>.</li>
<li>Much better overall sanity checking.</li>
<li>Better portability (POSIX compliant code)</li>
<li>Better (more portable) flag parsing using Kate Ward&#8217;s <a href="http://code.google.com/p/shflags/">shFlags</a>.</li>
<li>Improved installer. To install <code>git flow</code> as a first-class Git subcommand, simply type:
<pre>sudo make install</pre>
</li>
<li>Major and minor bug fixes.</li>
</ul>
<p>That&#8217;s all for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/492/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Unexpected side effects in Python classes</title>
		<link>http://nvie.com/archives/470</link>
		<comments>http://nvie.com/archives/470#comments</comments>
		<pubDate>Wed, 03 Mar 2010 01:22:09 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=470</guid>
		<description><![CDATA[Today, I lost several hours while debugging a language implementation detail in Python that I did not know of and that really feels counterintuitive and dangerous to me. I was writing unit tests for a Python class that I was implementing, when one of the tests that had repeatedly been passing suddenly failed. Moreover, the [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I lost several hours while debugging a language implementation detail in Python that I did not know of and that really feels counterintuitive and dangerous to me.</p>
<p>I was writing unit tests for a Python class that I was implementing, when one of the tests that had repeatedly been passing suddenly failed. Moreover, the failing test case was really for testing some completely unrelated piece of functionaly. This simply could not be broken!</p>
<p>After at least an hour of scrutinizing the code, I was able to distill the real problem, which I think is summarized here in the most compact way:<br />
<script src="http://gist.github.com/321150.js"></script><br />
Creating a simple <code>Foo</code> instance twice exposes the ugly side effect: the second <code>Foo</code> instance has an already initialized <code>x</code> instance variable when the constructor enters! Yuck! Moreover, now, too:</p>
<script src="http://gist.github.com/321155.js"></script>
<p>Apparently, the <code>x</code> &#8220;instance variable&#8221; is a shared object, much like a global or class variable.</p>
<p>To be even more confusing, this doesn&#8217;t seem to hold for basic data types. For example, change the dictionary to an integer, and the example behaves as expected:</p>
<script src="http://gist.github.com/321157.js"></script>
<h2>The behaviour demystified</h2>
<p>The real confusion here is that I was thinking that I was creating &#8220;instance variables&#8221;, like you would in C++ or Java. As the <a href="http://docs.python.org/tutorial/classes.html#instance-objects">Python documentation</a> mentions:</p>
<blockquote><p>&#8220;data attributes correspond to [...] to data members in C++. Data attributes need not be declared; like local variables, they spring into existence when they are first assigned to.&#8221;</p></blockquote>
<p>Yes, I knew that, but nonetheless my real-world class is much bigger than <code>Foo</code> and I wanted an explicit overview on which instance variables are in this class. Hence the data member.</p>
<p>However, this is not how the Python interpreter processes Python code. In fact, upon class definition, the statement <code>x = {}</code> is executed within the scope of the newly defined class. To prove this:</p>
<script src="http://gist.github.com/321158.js"></script>
<p>Even without a constructor or instance variable, we can access the data member <code>x</code>. Of course. Now this suddenly seems obvious.</p>
<p>But what about our instance variables? Apparently, when we create a new instance of <code>Bar</code>, the instance data member <code>x</code> is initially <em>pointing to the same object</em> as the class data member <code>x</code>. The following example proves this:</p>
<script src="http://gist.github.com/321172.js"></script>
<p>This example also demonstrates the subtlety of the accidentally discovered side-effect. Remember how we were changing the dictionary in our initial example? <code>self.x[id] = id</code><br />
The instance data member was pointing to the same object as the class data member. By updating the dictionary, the single dictionary object was changed, causing unwanted side effects in other class instances.</p>
<p>In the gist above, we force <code>x</code> to point to a new dictionary by the assignment <code>self.x = { id:id }</code>. In other words, <code>x</code> points to a new object! This also perfectly explains why the integer example worked—it&#8217;s the same kind of assignment.</p>
<h2>Conclusion</h2>
<p>To summarize, I learned some important lessons today:</p>
<ul>
<li>All the time, I have been creating class data members in all my classes, without knowing this.</li>
<li>I initialized those members to default values, effectively creating useless objects that are never accessed and just claiming memory.</li>
<li>Although it can be explained, a seemingly innocent statement like <code>x = {}</code> can have very ugly side effects. Be warned!</li>
<li>Never underestimate the power of unit tests. It is absolutely worth the investment.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/470/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>gitflow 0.1 released</title>
		<link>http://nvie.com/archives/438</link>
		<comments>http://nvie.com/archives/438#comments</comments>
		<pubDate>Tue, 26 Jan 2010 12:49:56 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[gitflow]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=438</guid>
		<description><![CDATA[After the overwhelming attention and feedback on the Git branching model post, a general consensus was that this workflow would benefit from some form of proper scriptability. The workflow works seamlessly if you perform the steps involved manually, but hey&#8230; manually is manually, really. UPDATE 2/4/2010: Anyone reading this: I recommend NOT USING this very [...]]]></description>
			<content:encoded><![CDATA[<p>After the overwhelming attention and feedback on the <a href="/archives/323">Git branching model post</a>, a general consensus was that this workflow would benefit from some form of proper scriptability. The workflow works seamlessly if you perform the steps involved manually, but hey&#8230; manually is manually, really.</p>
<blockquote><p><ins datetime="2010-02-04T11:10:19+00:00"><strong>UPDATE 2/4/2010</strong>:<br />
Anyone reading this: I recommend NOT USING this very early release, but to jump on the <a href="http://github.com/nvie/gitflow/tree/develop">current develop tip</a>, which is much more mature. Release 0.2 is coming very soon.</ins></p></blockquote>
<p>An assisting tool (dubbed <code>gitflow</code>) was therefore created to provide simple, high-level commands to adopt the workflow into your own software development process. It&#8217;s free and it&#8217;s open source. Feel free to contribute to it if you like.</p>
<blockquote><p>Fork me on Github:<br />
<a href="http://github.com/nvie/gitflow">http://github.com/nvie/gitflow</a></p></blockquote>
<p>Since this morning, the first working <a href="http://github.com/nvie/gitflow/downloads">release 0.1</a> was tagged, albeit very basic.</p>
<h3>A quick walkthrough</h3>
<p>The <code>gitflow</code> script essentially features six subcommands: paired start/finish commands for managing the different types of branches from the originating article:</p>
<ul>
<li>Feature branches
<ul>
<li><code>gitflow start feature <em>myfeature</em></code></li>
<li><code>gitflow finish feature <em>myfeature</em></code></li>
</ul>
</li>
<li>Release branches
<ul>
<li><code>gitflow start release <em>version-id</em></code></li>
<li><code>gitflow finish release <em>version-id</em></code></li>
</ul>
</li>
<li>Hotfix branches
<ul>
<li><code>gitflow start hotfix <em>version-id</em></code></li>
<li><code>gitflow finish hotfix <em>version-id</em></code></li>
</ul>
</li>
</ul>
<p>Each of these scripts exactly reports what actions were taken and what follow-up actions are required by the user. This output will be polished in future versions to improve the <a href="http://en.wikipedia.org/wiki/User_experience_design">UX</a>. An example output:</p>
<pre>
<strong>$ gitflow finish feature foo</strong>
Branches 'develop' and 'origin/develop' have diverged.
And local branch 'develop' is ahead of 'origin/develop'.
Switched to branch "develop"
Your branch is ahead of 'origin/develop' by 12 commits.
Merge made by recursive.
 README |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Deleted branch foo (cd3effb).

Summary of actions:
- The feature branch 'foo' was merged into 'develop'
- Feature branch 'foo' has been removed
- You are now on branch 'develop'
</pre>
<h3>Limitations</h3>
<p>The script is very limited at the moment yet, but future versions will fix that, too. Some of the main limitations:</p>
<ul>
<li>Branch names (<code>master</code>, <code>develop</code>) and the remote repo name (<code>origin</code>) are currently fixed.</li>
<li>There is no support for dealing with merge conflicts yet.</li>
<li>There is no support for <code>support-*</code> branches (see the <a href="/archives/323#comment-185">original comment</a> that proposed this extension)</li>
<li>There is no documentation.</li>
<li>There is no installer.</li>
</ul>
<p>However, as this post is written, some of the limitations are already taken care of by community members. Power to the open source!</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/438/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>sudo make sandwich</title>
		<link>http://nvie.com/archives/435</link>
		<comments>http://nvie.com/archives/435#comments</comments>
		<pubDate>Mon, 25 Jan 2010 21:52:40 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=435</guid>
		<description><![CDATA[This one is just too funny not to link. Image from xkcd.com.]]></description>
			<content:encoded><![CDATA[<p>This one is just too funny not to link.</p>
<p><img src="http://imgs.xkcd.com/comics/sandwich.png" alt="" /></p>
<p>Image from <a href="http://xkcd.com/149/">xkcd.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/435/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building Git from scratch on Snow Leopard</title>
		<link>http://nvie.com/archives/420</link>
		<comments>http://nvie.com/archives/420#comments</comments>
		<pubDate>Tue, 12 Jan 2010 23:29:24 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=420</guid>
		<description><![CDATA[When you try to build Git from scratch on a Snow Leopard machine, you may have ran into the following problem: $ git clone git://github.com/git/git.git Initialized empty Git repository in /Users/nvie/git/.git/ remote: Counting objects: 111619, done. remote: Compressing objects: 100% (28007/28007), done. remote: Total 111619 (delta 82192), reused 111264 (delta 81852) Receiving objects: 100% (111619/111619), [...]]]></description>
			<content:encoded><![CDATA[<p>When you try to build Git <a href="http://github.com/git/git">from scratch</a> on a Snow Leopard machine, you may have ran into the following problem:</p>
<pre><strong>$ git clone git://github.com/git/git.git</strong>
Initialized empty Git repository in /Users/nvie/git/.git/
remote: Counting objects: 111619, done.
remote: Compressing objects: 100% (28007/28007), done.
remote: Total 111619 (delta 82192), reused 111264 (delta 81852)
Receiving objects: 100% (111619/111619), 27.60 MiB | 531 KiB/s, done.
Resolving deltas: 100% (82192/82192), done.
<strong>$ cd git</strong>
<strong>$ make prefix=/usr/local/bin/git</strong>
GIT_VERSION = 1.6.2.rc0.90.g0753
    * new build flags or prefix
    CC fast-import.o
    CC abspath.o
    :
    :
<span style="color: #ff0000;">ld: warning: in /opt/local/lib/libexpat.dylib, file is not of required architecture</span>
<span style="color: #ff0000;">    ...
ld: symbol(s) not found
collect2: ld returned 1 exit status
</span></pre>
<p>Then, you have a pretty big change you are having an old Darwin ports (<a href="http://www.macports.org">macports</a>) collection in use which has not yet been upgraded to Snow Leopard&#8217;s new x64 architecture.</p>
<p>There is, however, a simple solution to this, namely to have the <code>git</code> build ignore the Darwin ports, simply by adding the following parameter to the build:</p>
<pre><strong>$ make <span style="color: #008000;">NO_DARWIN_PORTS=1</span> prefix=/usr/local/bin/git</strong></pre>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/420/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A successful Git branching model</title>
		<link>http://nvie.com/git-model</link>
		<comments>http://nvie.com/git-model#comments</comments>
		<pubDate>Tue, 05 Jan 2010 07:49:34 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[gitflow]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=323</guid>
		<description><![CDATA[In this post I present the development model that I&#8217;ve introduced for all of my projects (both at work and private) about a year ago, and which has turned out to be very successful. I&#8217;ve been meaning to write about it for a while now, but I&#8217;ve never really found the time to do so thoroughly, [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I present the development model that I&#8217;ve introduced for all of my projects (both at work and private) about a year ago, and which has turned out to be very successful. I&#8217;ve been meaning to write about it for a while now, but I&#8217;ve never really found the time to do so thoroughly, until now. I won&#8217;t talk about any of the projects&#8217; details, merely about the branching strategy and release management.</p>
<p style="text-align: center;"><img class="size-full wp-image-344 aligncenter" title="The branches of the branching model" src="http://nvie.com/wp-content/uploads/2009/12/Screen-shot-2009-12-24-at-11.32.03.png" alt="" width="611" height="815" /></p>
<p><span id="more-323"></span></p>
<p>It focuses around <a href="http://git-scm.com">Git</a> as the tool for the versioning of all of our source code.</p>
<h2>Why git?</h2>
<p>For a thorough discussion on the pros and cons of Git compared to centralized source code control systems, <a href="http://whygitisbetterthanx.com/">see</a> <a href="http://www.looble.com/git-vs-svn-which-is-better/">the</a> <a href="http://git.or.cz/gitwiki/GitSvnComparsion">web</a>. There are plenty of flame wars going on there. As a developer, I prefer Git above all other tools around today. Git really changed the way developers think of merging and branching. From the classic CVS/Subversion world I came from, merging/branching has always been considered a bit scary (&#8220;beware of merge conflicts, they bite you!&#8221;) and something you only do every once in a while.</p>
<p>But with Git, these actions are extremely cheap and simple, and they are considered one of the core parts of your <em>daily</em> workflow, really. For example, in CVS/Subversion <a href="http://svnbook.red-bean.com">books</a>, branching and merging is first discussed in the later chapters (for advanced users), while in <a href="http://book.git-scm.com">every</a> <a href="http://pragprog.com/titles/tsgit/pragmatic-version-control-using-git">Git</a> <a href="http://github.com/progit/progit">book</a>, it&#8217;s already covered in chapter 3 (basics).</p>
<p>As a consequence of its simplicity and repetitive nature, branching and merging are no longer something to be afraid of. Version control tools are supposed to assist in branching/merging more than anything else.</p>
<p>Enough about the tools, let&#8217;s head onto the development model.  The model that I&#8217;m going to present here is essentially no more than a set of procedures that every team member has to follow in order to come to a managed software development process.</p>
<h2>Decentralized but centralized</h2>
<p>The repository setup that we use and that works well with this branching model, is that with a central &#8220;truth&#8221; repo. Note that this repo is only <em>considered</em> to be the central one (since Git is a DVCS, there is no such thing as a central repo at a technical level). We will refer to this repo as <code>origin</code>, since this name is familiar to all Git users.</p>
<p style="text-align: center;"><a href="http://nvie.com/wp-content/uploads/2010/01/centr-decentr.png"><img class="alignnone size-full wp-image-413" title="Centralised, yet decentralised" src="http://nvie.com/wp-content/uploads/2010/01/centr-decentr.png" alt="" width="478" height="356" /></a></p>
<p>Each developer pulls and pushes to origin. But besides the centralized push-pull relationships, each developer may also pull changes from other peers to form sub teams. For example, this might be useful to work together with two or more developers on a big new feature, before pushing the work in progress to <code>origin</code> prematurely. In the figure above, there are subteams of Alice and Bob, Alice and David, and Clair and David.</p>
<p>Technically, this means nothing more than that Alice has defined a Git remote, named <code>bob</code>, pointing to Bob&#8217;s repository, and vice versa.</p>
<h2>The main branches</h2>
<p><img class="size-full wp-image-348 alignright" title="Master-develop cycle" src="http://nvie.com/wp-content/uploads/2009/12/bm002.png" alt="" width="254" height="378" /></p>
<p>At the core, the development model is greatly inspired by existing models out there. The central repo holds two main branches with an infinite lifetime:</p>
<ul>
<li><code>master</code></li>
<li><code>develop</code></li>
</ul>
<p>The <code>master</code> branch at <code>origin</code> should be familiar to every Git user. Parallel to the <code>master</code> branch, another branch exists called <code>develop</code>.</p>
<p>We consider <code>origin/master</code> to be the main branch where the source code of <code>HEAD</code> always reflects a <em>production-ready</em> state.</p>
<p>We consider <code>origin/develop</code> to be the main branch where the source code of <code>HEAD</code> always reflects a state with the latest delivered development changes for the next release. Some would call this the &#8220;integration branch&#8221;. This is where any automatic nightly builds are built from.</p>
<p>When the source code in the <code>develop</code> branch reaches a stable point and is ready to be released, all of the changes should be merged back into <code>master</code> somehow and then tagged with a release number. How this is done in detail will be discussed further on.</p>
<p>Therefore, each time when changes are merged back into <code>master</code>, this is a new production release <em>by definition</em>. We tend to be very strict at this, so that theoretically, we could use a Git hook script to automatically build and roll-out our software to our production servers everytime there was a commit on <code>master</code>.</p>
<h2>Supporting branches</h2>
<p>Next to the main branches <code>master</code> and <code>develop</code>, our development model uses a variety of supporting branches to aid parallel development between team members, ease tracking of features, prepare for production releases and to assist in quickly fixing live production problems. Unlike the main branches, these branches always have a limited life time, since they will be removed eventually.</p>
<p>The different types of branches we may use are:</p>
<ul>
<li>Feature branches</li>
<li>Release branches</li>
<li>Hotfix branches</li>
</ul>
<p>Each of these branches have a specific purpose and are bound to strict rules as to which branches may be their originating branch and which branches must be their merge targets. We will walk through them in a minute.</p>
<p>By no means are these branches &#8220;special&#8221; from a technical perspective. The branch types are categorized by how we <em>use</em> them. They are of course plain old Git branches.</p>
<h3>Feature branches</h3>
<p><img class="alignright size-full wp-image-368" title="Feature branch" src="http://nvie.com/wp-content/uploads/2009/12/fb.png" alt="" width="133" height="352" />May branch off from: <code>develop</code></p>
<p>Must merge back into: <code>develop</code></p>
<p>Branch naming convention: anything except <code>master</code>, <code>develop</code>, <code>release-*</code>, or <code>hotfix-*</code></p>
<p>Feature branches (or sometimes called topic branches) are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point. The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into <code>develop</code> (to definitely add the new feature to the upcoming release) or discarded (in case of a disappointing experiment).</p>
<p>Feature branches typically exist in developer repos only, not in <code>origin</code>.</p>
<h4>Creating a feature branch</h4>
<p>When starting work on a new feature, branch off from the <code>develop</code> branch.</p>
<pre><strong>$ git checkout -b myfeature develop</strong>
Switched to a new branch "myfeature"</pre>
<h4>Incorporating a finished feature on develop</h4>
<p>Finished features may be merged into the <code>develop</code> branch definitely add them to the upcoming release:</p>
<pre><strong>$ git checkout develop</strong>
Switched to branch 'develop'
<strong>$ git merge --no-ff myfeature</strong>
Updating ea1b82a..05e9557
<em>(Summary of changes)</em>
<strong>$ git branch -d myfeature</strong>
Deleted branch myfeature (was 05e9557).
<strong>$ git push origin develop</strong></pre>
<p>The <code>--no-ff</code> flag causes the merge to always create a new commit object, even if the merge could be performed with a fast-forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature. Compare:</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-394" title="Merging with or without fast-forwards" src="http://nvie.com/wp-content/uploads/2010/01/merge-without-ff.png" alt="" width="463" height="414" /></p>
<p>In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the <code>--no-ff</code> flag was used.</p>
<p>Yes, it will create a few more (empty) commit objects, but the gain is much bigger that that cost.</p>
<p>Unfortunately, I have not found a way to make <code>--no-ff</code> the default behaviour of <code>git merge</code> yet, but it really should be.</p>
<h3>Release branches</h3>
<p>May branch off from: <code>develop</code></p>
<p>Must merge back into: <code>develop</code> and <code>master</code></p>
<p>Branch naming convention: <code>release-*</code></p>
<p>Release branches support preparation of a new production release. They allow for last-minute dotting of i&#8217;s and crossing t&#8217;s. Furthermore, they allow for minor bug fixes and preparing meta-data for a release (version number, build dates, etc.). By doing all of this work on a release branch, the <code>develop</code> branch is cleared to receive features for the next big release.</p>
<p>The key moment to branch off a new release branch from <code>develop</code> is when develop (almost) reflects the desired state of the new release. At least all features that are targeted for the release-to-be-built must be merged in to <code>develop</code> at this point in time. All features targeted at future releases may not—they must wait until after the release branch is branched off.</p>
<p>It is exactly at the start of a release branch that the upcoming release gets assigned a version number—not any earlier. Up until that moment, the <code>develop</code> branch reflected changes for the &#8220;next release&#8221;, but it is unclear whether that &#8220;next release&#8221; will eventually become 0.3 or 1.0, until the release branch is started. That decision is made on the start of the release branch and is carried out by the project&#8217;s rules on version number bumping.</p>
<h4>Creating a release branch</h4>
<p>Release branches are created from the <code>develop</code> branch. For example, say version 1.1.5 is the current production release and we have a big release coming up. The state of <code>develop</code> is ready for the &#8220;next release&#8221; and we have decided that this will become version 1.2 (rather than 1.1.6 or 2.0). So we branch off and give the release branch a name reflecting the new version number:</p>
<pre><strong>$ git checkout -b release-1.2 develop</strong>
Switched to a new branch "release-1.2"
<strong>$ ./bump-version.sh 1.2</strong>
Files modified successfully, version bumped to 1.2.
<strong>$ git commit -a -m "Bumped version number to 1.2"</strong>
[release-1.2 74d9424] Bumped version number to 1.2
1 files changed, 1 insertions(+), 1 deletions(-)</pre>
<p>After creating a new branch and switching to it, we bump the version number. Here, <code>bump-version.sh</code> is a fictional shell script that changes some files in the working copy to reflect the new version. (This can of course be a manual change—the point being that <em>some</em> files change.) Then, the bumped version number is committed.</p>
<p>This new branch may exist there for a while, until the release may be rolled out definitely. During that time, bug fixes may be applied in this branch (rather than on the <code>develop</code> branch). Adding large new features here is strictly prohibited. They must be merged into <code>develop</code>, and therefore, wait for the next big release.</p>
<h4>Finishing a release branch</h4>
<p>When the state of the release branch is ready to become a real release, some actions need to be carried out. First, the release branch is merged into <code>master</code> (since every commit on <code>master</code> is a new release <em>by definition</em>, remember). Next, that commit on <code>master</code> must be tagged for easy future reference to this historical version. Finally, the changes made on the release branch need to be merged back into <code>develop</code>, so that future releases also contain these bug fixes.</p>
<p>The first two steps in Git:</p>
<pre><strong>$ git checkout master</strong>
Switched to branch 'master'
<strong>$ git merge --no-ff release-1.2
</strong>Merge made by recursive.
<em>(Summary of changes)</em>
<strong>$ git tag -a 1.2</strong></pre>
<p>The release is now done, and tagged for future reference.<br />
<ins datetime="2010-02-06T12:31:04+00:00"><strong>Edit:</strong> You might as well want to use the <code>-s</code> or <code>-u &lt;key&gt;</code> flags to sign your tag cryptographically.</ins></p>
<p>To keep the changes made in the release branch, we need to merge those back into <code>develop</code>, though. In Git:</p>
<pre><strong>$ git checkout develop</strong>
Switched to branch 'develop'
<strong>$ git merge --no-ff release-1.2
</strong>Merge made by recursive.
<em>(Summary of changes)</em></pre>
<p>This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit.</p>
<p>Now we are really done and the release branch may be removed, since we don&#8217;t need it anymore:</p>
<pre><strong>$ git branch -d release-1.2</strong>
Deleted branch release-1.2 (was ff452fe).</pre>
<h3>Hotfix branches</h3>
<p><img class="alignright size-full wp-image-390" title="Hotfix branching" src="http://nvie.com/wp-content/uploads/2010/01/hotfix-branches1.png" alt="" width="307" height="422" />May branch off from: <code>master</code></p>
<p>Must merge back into: <code>develop</code> and <code>master</code></p>
<p>Branch naming convention: <code>hotfix-*</code></p>
<p>Hotfix branches are very much like release branches in that they are also meant to prepare for a new production release, albeit unplanned. They arise from the necessity to act immediately upon an undesired state of a live production version. When a critical bug in a production version must be resolved immediately, a hotfix branch may be branched off from the corresponding tag on the master branch that marks the production version.</p>
<p>The essence is that work of team members (on the <code>develop</code> branch) can continue, while another person is preparing a quick production fix.</p>
<h4>Creating the hotfix branch</h4>
<p>Hotfix branches are created from the <code>master</code> branch. For example, say version 1.2 is the current production release running live and causing troubles due to a severe bug. But changes on <code>develop</code> are yet unstable. We may then branch off a hotfix branch and start fixing the problem:</p>
<pre><strong>$ git checkout -b hotfix-1.2.1 master</strong>
Switched to a new branch "hotfix-1.2.1"
<strong>$ ./bump-version.sh 1.2.1</strong>
Files modified successfully, version bumped to 1.2.1.
<strong>$ git commit -a -m "Bumped version number to 1.2.1"</strong>
[hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1
1 files changed, 1 insertions(+), 1 deletions(-)</pre>
<p>Don&#8217;t forget to bump the version number after branching off!</p>
<p>Then, fix the bug and commit the fix in one or more separate commits.</p>
<pre><strong>$ git commit -m "Fixed severe production problem"</strong>
[hotfix-1.2.1 abbe5d6] Fixed severe production problem
5 files changed, 32 insertions(+), 17 deletions(-)</pre>
<p><strong>Finishing a hotfix branch</strong></p>
<p>When finished, the bugfix needs to be merged back into <code>master</code>, but also needs to be merged back into <code>develop</code>, in order to safeguard that the bugfix is included in the next release as well. This is completely similar to how release branches are finished.</p>
<p>First, update <code>master</code> and tag the release.</p>
<pre><strong>$ git checkout master</strong>
Switched to branch 'master'
<strong>$ git merge --no-ff hotfix-1.2.1</strong>
Merge made by recursive.
<em>(Summary of changes)</em>
<strong>$ git tag -a 1.2.1</strong></pre>
<p><ins datetime="2010-02-06T12:31:04+00:00"><strong>Edit:</strong> You might as well want to use the <code>-s</code> or <code>-u &lt;key&gt;</code> flags to sign your tag cryptographically.</ins></p>
<p>Next, include the bugfix in <code>develop</code>, too:</p>
<pre><strong>$ git checkout develop</strong>
Switched to branch 'develop'
<strong>$ git merge --no-ff hotfix-1.2.1</strong>
Merge made by recursive.
<em>(Summary of changes)</em></pre>
<p>The one exception to the rule here is that, <strong>when a release branch currently exists, the hotfix changes need to be merged into that release branch, instead of </strong><code><strong>develop</strong></code>. Back-merging the bugfix into the release branch will eventually result in the bugfix being merged into <code>develop</code> too, when the release branch is finished. (If work in <code>develop</code> immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into <code>develop</code> now already as well.)</p>
<p>Finally, remove the temporary branch:</p>
<pre><strong>$ git branch -d hotfix-1.2.1</strong>
Deleted branch hotfix-1.2.1 (was abbe5d6).</pre>
<h2>Summary</h2>
<p>While there is nothing really shocking new to this branching model, the &#8220;big picture&#8221; figure that this post began with has turned out to be tremendously useful in our projects. It forms an elegant mental model that is easy to comprehend and allows team members to develop a shared understanding of the branching and releasing processes.</p>
<p>A high-quality PDF version of the figure is provided here. Go ahead and hang it on the wall for quick reference at any time.</p>
<p><ins datetime="2010-05-03T17:50:14+00:00"><strong>Update:</strong> And for anyone who requested it: here&#8217;s the <a href='http://nvie.com/wp-content/uploads/2010/01/gitflow-model.src.key_.zip'>gitflow-model.src.key</a> of the main diagram image (Apple Keynote).</ins></p>
<table border="0">
<tbody>
<tr>
<td align="center"><a href="http://nvie.com/wp-content/uploads/2010/01/Git-branching-model.pdf"><img class="alignnone size-full wp-image-383" title="Download PDF" src="http://nvie.com/wp-content/uploads/2010/01/pdf_icon.png" alt="" width="128" height="128" /></a></td>
</tr>
<tr>
<td align="center"><strong><a href="http://nvie.com/wp-content/uploads/2010/01/Git-branching-model.pdf">Git-branching-model.pdf</a></strong></td>
</tr>
</tbody>
</table>
<p>Feel free to add your comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/git-model/feed</wfw:commentRss>
		<slash:comments>118</slash:comments>
		</item>
		<item>
		<title>Avoiding fast-forward merges in Git</title>
		<link>http://nvie.com/archives/319</link>
		<comments>http://nvie.com/archives/319#comments</comments>
		<pubDate>Sat, 19 Dec 2009 12:21:24 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Git]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=319</guid>
		<description><![CDATA[Just a pointer to an excellent post I wanted to share with you: In the section &#8220;Why we shouldn’t fast-forward&#8221; at http://robey.lag.net/2009/11/29/more-git.html, Robey explains very clearly how fast forwards effectively make you loose historical information that may be crucial to ever reconstruct or understand your own project&#8217;s history.]]></description>
			<content:encoded><![CDATA[<p>Just a pointer to an excellent post I wanted to share with you:</p>
<p>In the section &#8220;Why we shouldn’t fast-forward&#8221; at <a href="http://robey.lag.net/2009/11/29/more-git.html">http://robey.lag.net/2009/11/29/more-git.html</a>, Robey explains very clearly how fast forwards effectively make you loose historical information that may be crucial to ever reconstruct or understand your own project&#8217;s history.</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/319/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto-generate classes for your Core Data data model, revisited</title>
		<link>http://nvie.com/archives/310</link>
		<comments>http://nvie.com/archives/310#comments</comments>
		<pubDate>Mon, 19 Oct 2009 22:20:32 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[mogenerator]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=310</guid>
		<description><![CDATA[A few months ago, I wrote about automatically generating classes for your Core Data entities and how to automate Xcode using users scripts, such that, when your model changed, you only needed to run your custom script again and your intermediate model files would reflect the new situation. Well, the guys from the mogenerator project [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, I wrote about <a title="Automatically generate classes for your Core Data data model" href="/archives/263">automatically generating classes for your Core Data entities</a> and how to automate Xcode using users scripts, such that, when your model changed, you only needed to run your custom script again and your intermediate model files would reflect the new situation.</p>
<p>Well, the guys from the <a title="mogenerator project at Github" href="http://github.com/rentzsch/mogenerator">mogenerator</a> project have come up with a far superior solution in the mean time. The newest version of mogenerator comes with an Xcode plugin named Xmo&#8217;d, which monitors your *.xcdatamodel file for changes and, as soon as it changes, regenerates all of the neccessary files.</p>
<p><strong>This means that there is officially no more reason not to use mogenerator.</strong></p>
<p>To set it up, download the installer package from their (improved) <a title="mogenerator project home page" href="http://rentzsch.github.com/mogenerator/">project website</a> and install it. (Before installing, please read the important release note about the renamed method <code>+newInManagedObjectContext:</code>.)</p>
<p>When installed, all you need to do is Command-click your *.xcdatamodel file, click Get Info, switch to the Comments tab and add the string &#8220;xmod&#8221; to the comment field. This is the trigger for Xmo&#8217;d to start (re)generating your machine-classes (the underscored class files) when the data model changes. Brilliant!</p>
<p><a href="http://nvie.com/wp-content/uploads/2009/10/comment-field.png"><img class="alignnone size-full wp-image-311" title="Adding the trigger to the comment field." src="http://nvie.com/wp-content/uploads/2009/10/comment-field.png" alt="Adding the trigger to the comment field." width="381" height="545" /></a></p>
<p>Oh, the default location at which the generated files will be emitted, is in a folder named after your project, right next to where your *.xcdatamodel already sits:</p>
<p><a href="http://nvie.com/wp-content/uploads/2009/10/emission-location.png"><img class="alignnone size-medium wp-image-314" title="Location where output files are generated" src="http://nvie.com/wp-content/uploads/2009/10/emission-location-300x239.png" alt="Location where output files are generated" width="300" height="239" /></a></p>
<p>Enjoy it and spread the word!</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/310/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically generate classes for your Core Data data model</title>
		<link>http://nvie.com/archives/263</link>
		<comments>http://nvie.com/archives/263#comments</comments>
		<pubDate>Thu, 30 Jul 2009 22:20:34 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[User scripts]]></category>
		<category><![CDATA[Xcode]]></category>
		<category><![CDATA[mogenerator]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=263</guid>
		<description><![CDATA[When designing a Core Data data model for your Xcode projects, you can choose to create Objective-C object wrappers for your entities, so that you can profit from type-safe code. The normal, tedious, workflow for this is that you select each entity from the model designer, select all of its attributes and relationships, Ctrl-click it [...]]]></description>
			<content:encoded><![CDATA[<p>When designing a Core Data data model for your Xcode projects, you can choose to create Objective-C object wrappers for your entities, so that you can profit from type-safe code. The normal, tedious, workflow for this is that you select each entity from the model designer, select all of its attributes and relationships, Ctrl-click it and from the contextual menu first select &#8220;Copy Obj-C 2.0 Method Declarations To Clipboard&#8221;, paste it into the appropriate class header file, then do the same thing for the method implementations in the class implementation file. Waaaaaay too much work. Not to mention the manual copy-pastes are really hard to keep in sync once you start adding functionality to these class files, since you don&#8217;t want to overwrite those additions, but you want to keep replacing everything else.</p>
<h3>Meet mogenerator</h3>
<p>Fortunately, there is a great way for automating this process, using mogenerator. The tool can be downloaded as a <a href="http://aralbalkan.com/2152">DMG installer</a> (Aral Balkan&#8217;s blog mentions a workaround for older Xcode versions, but for Xcode 3.1.3 it worked out of the box for me), or you can checkout the sources from <a href="http://github.com/rentzsch/mogenerator/">github</a> and build it yourself.</p>
<p>The mogenerator command line tool eases this generation process by reading the *.xcdatamodel file and generating both class files and intermediate class files for each entity. The intermediate classes (called <em>machine</em> classes) are continuously overwritten by subsequent regenerations, so you should never edit the contents of these files. The actual model object classes (called <em>human</em> classes) inherit from those intermediate classes with a default empty implementation, allowing for all manual extensions.</p>
<p>For example, when you design a model with two entities Foo and Bar, mogenerator can be invokes as follows:</p>
<pre>mogenerator -m MyDocument.xcdatamodel -M Entities -H Model</pre>
<p>The flag -m sets the input model file, while -M and -H specify the output directories where the machine and human classes should be generated respectively.</p>
<p>This does a few things:</p>
<ul>
<li>In the Entities subdirectory, there will be generated header and implementation files for NSManagedObject subclasses called _Foo and _Bar;</li>
<li>In the Model subdirectory, there will be generated classes called Foo and Bar—respective subclasses of _Foo and _Bar. These are only created if not available yet. Otherwise, they are left as is.</li>
</ul>
<h3>Wrapping it up</h3>
<p>The trick of how mogenerator works is that you can run the script as often as you want. After every change in your model, you&#8217;ll want to re-run the generation again to update the machine classes. You could easily leave Xcode, switch over to Terminal and issue the command above. But you&#8217;ll get quite tired of that after a few times.</p>
<p>Therefore, I&#8217;ve written a custom user script that can be added to Xcode (see figure), which does the following:</p>
<ul>
<li>You can configure the output directories in the first lines of the script. There is no per-project configuration, so choose them as you would like to use them with all your projects;</li>
<li>Mind that these generated files are not automatically included in your Xcode project. Drag them there once and ideally put the machine generated classes into a group under &#8220;Other resource&#8221;, so you never have to see them again. Whenever you add a new class to your model, new files will be generated, so again you must drag the new files to reference those, of course!</li>
<li>The script can be run with any file in the project opened. It starts out with that file and walks up the directory tree to search for your Xcode project. If found, it executes all the rest from your project directory. (Suggestions are welcome, I could not find a better implementation since a variable like %%%{PBXProjectPath}%%% does not seem to exist.)</li>
<li>It invokes mogenerator to generate all model classes for the project. It is smart enough to detect whether you are using Brian Webster&#8217;s <a href="http://www.fatcatsoftware.com/blog/2008/per-object-ordered-relationships-using-core-data">BWOrderedManagedObject</a> in your project. If so, your generated machine classes will inherit from BWOrderedManagedObject instead of NSManagedObject.</li>
</ul>
<p><a href="http://nvie.com/wp-content/uploads/2009/07/set-user-script.png"><img class="alignnone size-medium wp-image-291" title="Edit user script window" src="http://nvie.com/wp-content/uploads/2009/07/set-user-script-300x211.png" alt="Edit user script window" width="300" height="211" /></a></p>
<p>To add this script to Xcode, open the menu Scripts (the icon) &gt; Edit User Scripts&#8230; Click the &#8220;+&#8221;-button on the bottom-left and select &#8220;New shell script&#8221;. Set the values for Input, Directory, Output and Errors as in the screenshot above, then copy-paste the script below into the code window. Add a nice keyboard shortcut to this action to top it off :-) I&#8217;ve chosen ^⌥⌘G for this.</p>
<p>Please feel free to leave any comments if this helped you.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">#!/bin/sh
#
# Automatic (re)generation of model classes for all *.xcdatamodel files.
# Written by Vincent Driessen
#
# You are free to use this script in any way.
# The original blog post is http://nvie.com/archives/263
#
&nbsp;
# Define output directories
MACHINE_DIR=&quot;Entities&quot;
MODEL_DIR=&quot;Model&quot;
&nbsp;
# Look for the Xcode project directory for this file
cd `dirname &quot;%%%{PBXFilePath}%%%&quot;`
while [ `ls -d *.xcodeproj 2&amp;gt;/dev/null | wc -l` -eq 0 ]; do
    cd ..
    if [ &quot;`pwd`&quot; = &quot;/&quot; ]; then
        echo &quot;No Xcode project found.&quot;
        exit 1
    fi
done
&nbsp;
echo &quot;Project directory is `pwd`&quot;
&nbsp;
#
# Check to see whether the base class is just a default (NSManagedObject) or maybe
# Brian Webster's excellent BWOrderedManagedObject.
# http://www.fatcatsoftware.com/blog/2008/per-object-ordered-relationships-using-core-data
#
# NOTE:
# The check really is quite arbitrary: if there exists a file called BWOrderedManagedObject.h
# somewhere below the project root directory, we assume that we want to use this as the base
# class for all generated classes.
#
EXTRA_FLAGS=
if [ `find . -name BWOrderedManagedObject.h | wc -l` -gt 0 ]; then
	EXTRA_FLAGS+=&quot;--base-class BWOrderedManagedObject&quot;
fi
&nbsp;
# Generate the model classes using mogenerator
for model in `find . -name '*.xcdatamodel'`; do
	# The output directories have to exist, so create them
    mkdir -p &quot;${MACHINE_DIR}&quot; &quot;${MODEL_DIR}&quot;
    mogenerator ${EXTRA_FLAGS} -m &quot;${model}&quot; -M &quot;${MACHINE_DIR}&quot; -H &quot;${MODEL_DIR}&quot;
done</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/263/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>NSManagedObjectContext extensions</title>
		<link>http://nvie.com/archives/243</link>
		<comments>http://nvie.com/archives/243#comments</comments>
		<pubDate>Tue, 21 Jul 2009 23:32:49 +0000</pubDate>
		<dc:creator>Vincent Driessen</dc:creator>
				<category><![CDATA[Core Data]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://nvie.com/?p=243</guid>
		<description><![CDATA[The Core Data framework rules, and its API is really really powerful. But really, why does the Core Data API require us to write so much boilerplate code? Simple things need to be simple. Why is the deletion of a managed object from the NSManagedObjectContext so easy: &#91;context deleteObject:someObject&#93;; Compared to its creation: &#91;NSEntityDescription insertNewObjectForEntityForName:@&#34;someObjectClassName&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>The Core Data framework rules, and its API is really really powerful. But really, why does the Core Data API require us to write so much boilerplate code? Simple things need to be simple.</p>
<p>Why is the deletion of a managed object from the NSManagedObjectContext so easy:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>context deleteObject<span style="color: #002200;">:</span>someObject<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>Compared to its creation:</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSEntityDescription</span> insertNewObjectForEntityForName<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;someObjectClassName&quot;</span>
                              inManagedObjectContext<span style="color: #002200;">:</span>context<span style="color: #002200;">&#93;</span>;</pre></div></div>

<h3>Extending NSManagedObjectContext</h3>
<p>Add the following category on NSManagedObjectContext to all of your Core Data projects and your pains will be history.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@implementation</span> <span style="color: #400080;">NSManagedObjectContext</span> <span style="color: #002200;">&#40;</span>NSManagedObjectContextConvenienceMethods<span style="color: #002200;">&#41;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>newObject<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">Class</span><span style="color: #002200;">&#41;</span>entity <span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSEntityDescription</span> insertNewObjectForEntityForName<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>entity description<span style="color: #002200;">&#93;</span>
                                         inManagedObjectContext<span style="color: #002200;">:</span>self<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></div></div>

<p>Now, a call to create a new object is as easy as deleting it.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">&#91;</span>context newObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>someEntity class<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;</pre></div></div>

<h3>Further enhancements of NSManagedObject</h3>
<p>Matt Gallagher has written an <a href="http://cocoawithlove.com/2008/03/core-data-one-line-fetch.html">excellent article</a> about how to further enhance NSManagedObject for adding simple, one-line fetch support. Be sure to check it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://nvie.com/archives/243/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
