<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Okhuomon Ajayi]]></title><description><![CDATA[Okhuomon Ajayi]]></description><link>https://okhuomonajayi.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 11:42:37 GMT</lastBuildDate><atom:link href="https://okhuomonajayi.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[My Outreachy contribution period with Git: removing global state, one patch at a time]]></title><description><![CDATA[What went wrong, what I changed, and what Git's reviewers taught me]]></description><link>https://okhuomonajayi.hashnode.dev/my-outreachy-contribution-period-with-git-removing-global-state-one-patch-at-a-time</link><guid isPermaLink="true">https://okhuomonajayi.hashnode.dev/my-outreachy-contribution-period-with-git-removing-global-state-one-patch-at-a-time</guid><category><![CDATA[Git]]></category><category><![CDATA[outreachy]]></category><category><![CDATA[open source]]></category><category><![CDATA[C]]></category><dc:creator><![CDATA[Okhuomon Ajayi]]></dc:creator><pubDate>Thu, 05 Nov 2026 23:00:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6ae9fa4970fff515f779dd86/0a964c9d-ae70-4ad8-acf1-52d8d745b560.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I'm Okhuomon Ajayi, a software engineer from Lagos, Nigeria. I work with React, TypeScript, Python and C, among others. In open source, I have also written C++ for LibreOffice, Rust for Servo and a little OCaml. C was the first language I learned. For the December 2026 Outreachy round I applied to Git, to the project "Reduce Git's global state to enable Git's libification".</p>
<p>This post is about what I worked on during the contribution period, what went wrong, and what the reviewers taught me.</p>
<h2>What the project is about</h2>
<p>A lot of Git's code uses a global variable called <code>the_repository</code>. It points to the repository Git is running in. That works when Git runs as a command, but it is a problem if you want to use Git's code as a library, for example to work with two repositories in the same program. A function that quietly reaches for <code>the_repository</code> can end up using the wrong one.</p>
<p>The fix is simple to describe: when a function already gets a <code>struct repository *</code>, it should use that, and when it doesn't, the caller should pass one down. Once a file no longer uses the global, it can drop the <code>USE_THE_REPOSITORY_VARIABLE</code> macro at the top.</p>
<p>Simple to describe, but not always simple to do, as I found out.</p>
<h2>My first try in 2025</h2>
<p>This is not my first time on the Git mailing list. I applied in October 2025 and sent about ten patches in one week. None of them were merged. I was sending too fast, my subject lines had doubled prefixes like "[PATCH] [PATCH v2]", and my commit messages did not follow the project style. Christian Couder and Junio C Hamano pointed this out, kindly but clearly.</p>
<p>Honestly, I was overwhelmed. I felt really bad and a bit intimidated, because I kept making mistakes and I wasn't getting it right. I admit I stepped away. I even unsubscribed from the mailing list, because I kept seeing all the updates and I couldn't contribute.</p>
<p>This year I came back and slowed down. I read SubmittingPatches properly, wrote commit messages that explain why and not only what, and sent one change at a time.</p>
<h2>What I contributed</h2>
<p><strong>My microproject (merged).</strong> A progress message in <code>delta-islands.c</code> used <code>_()</code>, so "Marked 1 islands" could not be translated properly in languages with several plural forms. I changed it to <code>Q_()</code>, which picks the right form from the count. Junio asked me to move a note below the <code>---</code> line, I sent v2, and it was merged. It is listed in the Git v2.98.0 release notes. <a href="https://lore.kernel.org/git/20261013164922.93099-1-okhuomonajayi54@gmail.com/">https://lore.kernel.org/git/20261013164922.93099-1-okhuomonajayi54@gmail.com/</a></p>
<p><strong>diffcore-break and diffcore-rename (merged to master).</strong> <code>diffcore-rename.c</code> already had the repository through its diff options, but still used the global for the hash algorithm and the progress meter. I used the repository from the options and removed the macro. Patrick Steinhardt called it "trivially correct". <a href="https://lore.kernel.org/git/20261024221341.92086-1-okhuomonajayi54@gmail.com/">https://lore.kernel.org/git/20261024221341.92086-1-okhuomonajayi54@gmail.com/</a></p>
<p><strong>range-diff and bundle-uri (in 'next').</strong> Both followed the same idea. On bundle-uri, a reviewer pointed out that only two uses of the global were left in the file, so in v2 I finished the job and dropped the macro.</p>
<p>A few more patches are still in review.</p>
<h2>The notes story</h2>
<p>This is the part I learned the most from.</p>
<p><code>notes-utils.c</code> has functions that take a repository but still read and update the notes ref in <code>the_repository</code>. My first patch fixed that, but kept the macro. Patrick asked why I stopped one step short, so I sent v2, which removed the macro.</p>
<p>Then Junio pointed out something I had missed: the functions in <code>notes.c</code> that <code>notes-utils.c</code> calls still only work with <code>the_repository</code>. Removing the macro from <code>notes-utils.c</code> would make it look finished when it wasn't. He suggested hiding the header behind the macro instead, and I sent that.</p>
<p>Then Patrick asked a fair question: why not fix <code>notes.c</code> itself? Junio agreed that would be the ideal way.</p>
<p>So I did that. I sent one series of 6 patches. <code>struct notes_tree</code> now remembers which repository it was loaded from, and <code>notes.c</code> uses that when it reads, writes and prunes notes. With that in place, <code>notes-utils.c</code> really can drop the macro. Here is the idea in one line:</p>
<pre><code class="language-c">-	refs_update_ref(get_main_ref_store(the_repository), buf.buf,
+	refs_update_ref(get_main_ref_store(r), buf.buf,
</code></pre>
<p>This is the cover letter of the series on the mailing list archive:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6ae9fa4970fff515f779dd86/cc471d73-92e5-476d-b532-de49f35eb406.webp" alt="" style="display:block;margin:0 auto" />

<p><a href="https://lore.kernel.org/git/20261105203344.48513-1-okhuomonajayi54@gmail.com/">https://lore.kernel.org/git/20261105203344.48513-1-okhuomonajayi54@gmail.com/</a></p>
<h2>What the reviewers taught me</h2>
<p>The biggest lesson from the notes story is to follow the calls down. Before I say a file no longer depends on <code>the_repository</code>, I now check what the functions it calls actually do.</p>
<p>The second one came from <code>commit_encoding</code>. I moved a global into a config struct, and Junio pointed out that only one file uses it, so it is better to pass the value down. I should have looked at earlier discussions and compared designs before writing any code.</p>
<p>Patrick also asked me to send fewer, bigger series instead of many small topics, because that is easier for reviewers. And along the way I picked up the mailing-list habits: plain text, no top-posting, short quotes, and notes for reviewers below the <code>---</code> line.</p>
<h2>Helping others</h2>
<p>I reviewed some patches from other applicants, and I helped proofread edition 140 of Git Rev News, the community newsletter. I fixed typos and grammar in the Developer Spotlight interview, and I am credited at the end of the edition:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6ae9fa4970fff515f779dd86/0d8f15b3-d098-4bc4-b5f5-a681d2bca9af.webp" alt="" style="display:block;margin:0 auto" />

<p><a href="https://github.com/git/git.github.io/pull/878">https://github.com/git/git.github.io/pull/878</a></p>
<h2>What's next</h2>
<p>For now I'm waiting for reviews on the notes series. After that, I want to keep working bottom-up through Git's library code: group related files into one series, pass values down instead of adding new globals, and talk about the design on the list before writing code for the harder cases.</p>
<p>Thanks to my mentors Christian Couder, Usman Akinyemi, Siddharth Asthana and Kaartic Sivaraam, and to Junio C Hamano, Patrick Steinhardt, Karthik Nayak and Pablo Sabater for reviewing my patches and helping me improve them.</p>
]]></content:encoded></item></channel></rss>