{"@attributes":{"version":"2.0"},"channel":{"title":"Rohit Ashiwal","description":"Hello, I am Rohit Ashiwal","link":"https:\/\/rashiwal.me\/","pubDate":"Wed, 04 Feb 2026 07:35:06 +0000","lastBuildDate":"Wed, 04 Feb 2026 07:35:06 +0000","generator":"Jekyll v3.10.0","item":[{"title":"# The Final Report","description":"<p>Hey Everyone!<\/p>\n\n<p>My project was to <a href=\"https:\/\/summerofcode.withgoogle.com\/projects\/#6407042053439488\">improve the consistency of sequencer commands<\/a>. There are two backends available for rebasing, viz, the am and the interactive. Naturally, there shall be some features that are implemented in one but not in the other. The project aimed to remove inconsistencies in how the command line options are handled. A copy of my project proposal is hosted <a href=\"https:\/\/rashiwal.me\/git_proposal_19.pdf\">here<\/a>. The project was done under the guidance of <a href=\"https:\/\/www.linkedin.com\/in\/thomas-gummerer-47715a15\">Thomas Gummerer<\/a> and <a href=\"https:\/\/www.linkedin.com\/in\/elijah-newren-0a41665\/\">Elijah Newren<\/a>, two of the best Git developers.<\/p>\n\n<p><em>Let\u2019s dive into my journey of GSoC with Git!<\/em><\/p>\n\n<h2 id=\"-pre-gsoc-period\">## Pre-GSoC Period<\/h2>\n\n<p>I started contributing to Git from this February where Dscho (aka Johannes) was mentoring me to remove an\u00a0<a href=\"https:\/\/github.com\/git-for-windows\/git\/issues\/1970\">external dependency<\/a>\u00a0of the MinGit package.<\/p>\n\n<p>After some time, <a href=\"https:\/\/public-inbox.org\/git\/CAL7ArXqkVfrnQWYFDYdwMGkZjHCwzyQX4pbKCo=KCzy-zJiRBw@mail.gmail.com\/\">I\u00a0introduced\u00a0myself<\/a> to Git where I picked a\u00a0<a href=\"https:\/\/public-inbox.org\/git\/20190303122842.30380-1-rohit.ashiwal265@gmail.com\/\">micro-project<\/a> and continued working on it and improving my understanding of the mailing list. People at Git are extremely co-operative and the community is always active to help you 24x7. It\u2019s the time when I received some critical reviews and learned how things work in an organization. The interaction taught me the workflow and more importantly how important \u201cword choice\u201d is when committing.<\/p>\n\n<p>After several iterations and help from the people, I was able to complete my proposal that I finally submitted for GSoC \u201819. And yeah! I was selected for GSoC!<\/p>\n\n<h2 id=\"-the-plan\">## The \u201cPlan\u201d<\/h2>\n\n<p>I planned on completing the following tasks:<\/p>\n\n<div class=\"language-md highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"p\">1.<\/span> Suggest relevant flags for operations that have such a concept like git cherry-pick --skip\n<span class=\"p\">2.<\/span> Unify the suggestive messages of git (cherry-pick|rebase-i) with git (am|rebase)\n<span class=\"p\">3.<\/span> Implement flags that am-based rebases support, but not interactive, in interactive rebases, e.g.:\n\t--ignore-whitespace\n\t--committer-date-is-author-date\n\t--ignore-date (aka --reset-author-date)\n\t--whitespace=...\n<span class=\"p\">4.<\/span> [Bonus] Make a flag to allow rebase to rewrite commit messages that refer to older commits that were also rebased\n<span class=\"p\">5.<\/span> [Bonus] Performance run on different backends of rebasing, if everything agrees, deprecate am-based rebases\n<\/code><\/pre><\/div><\/div>\n\n<p>Alas! I was only able to complete the first two tasks and flags --ignore-whitespace, --committer-date-is-author-date and --ignore-date with almost no work done on --whitespace=\u2026 flags and [Bonus] features.<\/p>\n\n<h2 id=\"-phase-1\">## Phase 1<\/h2>\n\n<p>The phase started with <a href=\"https:\/\/public-inbox.org\/git\/20190608191958.4593-1-rohit.ashiwal265@gmail.com\/\">teaching cherry-pick and revert to \u201cskip\u201d commits<\/a>. git am or rebase advice user to use\u00a0git am --skip\u00a0or\u00a0git rebase --skip\u00a0to skip the commit that has become empty or has risen conflict. OTOH, git\u00a0rebase -i\u00a0or\u00a0cherry-pick\u00a0advice user to use git reset HEAD which on the user\u2019s part is annoying and sometimes confusing. My\u00a0PATCH brought consistency between the advice of these commands by introducing --skip option to these subcommands.<\/p>\n\n<h2 id=\"-phase-2\">## Phase 2<\/h2>\n\n<p>Most of the work was done in phase 2. I started by <a href=\"https:\/\/public-inbox.org\/git\/20190712185015.20585-1-rohit.ashiwal265@gmail.com\/\">implementing and  polishing<\/a> --ignore-whitespace and --committer-date-is-author-date flags. The former was expected to appropriately handle whitespace changes while committing while the latter helped us to set the committer date equal to the value same as the author date. This was the time when I got familiar with the internal workings of the sequencer. I sent the patches for review while I started working on another flag --ignore-date. Review took a long time (Git community as always on their toes to only allow the most pristine code into their tree). By the time of phase 3 I was only able to work on these two flags :\/<\/p>\n\n<h2 id=\"-phase-3\">## Phase 3<\/h2>\n\n<p>The <a href=\"https:\/\/public-inbox.org\/git\/20190712185015.20585-1-rohit.ashiwal265@gmail.com\/\">parallel submission<\/a> of the previous (two) patches was causing a mental mess, so I switched a new topic <a href=\"https:\/\/public-inbox.org\/git\/20190806173638.17510-1-rohit.ashiwal265@gmail.com\/\">rebase-i-more-options<\/a>. It contained the previous patches along with the code of yet another flag --ignore-date (also aliased --reset-author-date). Since the polishing from phase 2 took a toll on time, I asked my mentors if we can start working on --whitespace=\u2026 flags while my patches were still in review to which they answered, \u201cIt\u2019s fine even if we are not able to meet all the goals, what\u2019s important is that we only allow well-tested and well-written code into the git\u2019s source\u201d. I agreed. I spent all my time in this phase to polish the patch series which was sent to the mailing list.<\/p>\n\n<h2 id=\"-post-gsoc\">## Post-GSoC<\/h2>\n\n<p>The project still requires the following to be done:<\/p>\n\n<div class=\"language-md highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"p\">1.<\/span> Introduce --whitespace=... flags\n<span class=\"p\">2.<\/span> Work on the aforementioned bonus features\n<\/code><\/pre><\/div><\/div>\n\n<p>I am planning on continuing even after GSoC. I\u2019ll take the project to completion since I feel responsible for all the projects that I\u2019m part of.<\/p>\n\n<p>Best Wishes<br \/>\nRohit<\/p>\n\n<hr \/>\n<h4 id=\"-git-log\">### git log<\/h4>\n\n<p>The following commits were sent during GSoC \u201819 and they are currently present in git\/git\u2019s tree (master and proposed updates).<\/p>\n\n<p><a href=\"https:\/\/github.com\/git\/git\/commit\/ac9e40e8ef\">ac9e40e8ef<\/a> Merge branch \u2018ra\/t3600-test-path-funcs\u2019<\/p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>A GSoC micro.\n\n* ra\/t3600-test-path-funcs:\n  t3600: use helpers to replace test -d\/f\/e\/s &lt;path&gt;\n  t3600: modernize style\n  test functions: add function `test_file_not_empty`\n<\/code><\/pre><\/div><\/div>\n\n<p><a href=\"https:\/\/github.com\/git\/git\/commit\/d97c62c828\">d97c62c828<\/a> Merge branch \u2018ra\/cherry-pick-revert-skip\u2019<\/p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>\"git cherry-pick\/revert\" learned a new \"--skip\" action.\n\n* ra\/cherry-pick-revert-skip:\n  cherry-pick\/revert: advise using --skip\n  cherry-pick\/revert: add --skip option\n  sequencer: use argv_array in reset_merge\n  sequencer: rename reset_for_rollback to reset_merge\n  sequencer: add advice for revert\n<\/code><\/pre><\/div><\/div>\n\n<p><a href=\"https:\/\/github.com\/git\/git\/commit\/966fc12521\">966fc12521<\/a> Merge branch \u2018ra\/rebase-i-more-options\u2019 into pu<\/p>\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>\"git rebase -i\" learned a few options that are known by \"git\nrebase\" proper.\n\nLooking good.\n\n* ra\/rebase-i-more-options:\n  rebase: add --reset-author-date\n  rebase -i: support --ignore-date\n  sequencer: rename amend_author to author_to_rename\n  rebase -i: support --committer-date-is-author-date\n  sequencer: add NULL checks under read_author_script\n  rebase -i: add --ignore-whitespace flag\n<\/code><\/pre><\/div><\/div>\n\n<hr \/>\n<p>Psst!<\/p>\n\n<p>I also have a <a href=\"https:\/\/github.com\/r1walz\/git-patches\">repository<\/a> containing all the patches that I have sent (and will be sending) to the GIT mailing list. The work done under GSoC contains [GSoC] tag in the commit message. Clone the repo and use <code class=\"language-plaintext highlighter-rouge\">git log --grep=\"GSoC\"<\/code> to list all \u201cGSoC\u201d commits.<\/p>\n\n<hr \/>\n<h4 id=\"-special-thanks\">### Special Thanks<\/h4>\n\n<p>I\u2019d love to take some time and thank all the people who helped me to realize the project, especially:<\/p>\n\n<div class=\"language-md highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code><span class=\"p\">-<\/span> Christian Couder\n<span class=\"p\">-<\/span> Elijah Newren\n<span class=\"p\">-<\/span> Eric Sunshine\n<span class=\"p\">-<\/span> Johannes Schindelin\n<span class=\"p\">-<\/span> Junio C. Hamano\n<span class=\"p\">-<\/span> Phillip Wood\n<span class=\"p\">-<\/span> Thomas Gummerer\n<\/code><\/pre><\/div><\/div>\n\n<p>and many others. Thank you very much!<\/p>\n\n","pubDate":"Wed, 21 Aug 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/final-report\/","guid":"https:\/\/rashiwal.me\/2019\/final-report\/"},{"title":"# Another Iteration","description":"<p>Hey All!<\/p>\n\n<p>Sorry for a late post. Weeks are busy as we are in the middle of our internship season. I had to run between things and this is the time which I\u2019m able to factor out of my schedule.<\/p>\n\n<p>Last week was spent polishing the <a href=\"https:\/\/public-inbox.org\/git\/20190806173638.17510-1-rohit.ashiwal265@gmail.com\/\">patch<\/a> that I sent. From making the patch compile on Windows to factoring out code to changing documentation,  I had accounted for all the suggestions that I received there. The <a href=\"https:\/\/github.com\/r1walz\/git\/pull\/4\">PR<\/a> which focused on adding --ignore-date to the interactive machinery was also added to the series. There was nothing new to the logical part, just changing the control path and introducing functions.<\/p>\n\n<p>We are in the final week of GSoC now and I still yet to implement the --whitespace=&lt;\u2026&gt; flags. I\u2019ll try to, at least, form a minimal patch (or idea) of how these new set of flags should work. I may not be able to implement in the given time, but GSoC is not about completing the project, it\u2019s about introducing a student to the world of open source. And now that I am familiar with the code of git, I\u2019ll become a \u201cserial\u201d committer and will try to keep my project alive until completion.<\/p>\n\n<p>See ya!<\/p>\n\n","pubDate":"Mon, 12 Aug 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/another-iteration\/","guid":"https:\/\/rashiwal.me\/2019\/another-iteration\/"},{"title":"# The Discussion","description":"<p>Hey Everyone!<\/p>\n\n<p>As mentioned in the last week\u2019s <a href=\"https:\/\/rashiwal.me\/2019\/second-evaluation\/\">post<\/a>, Junio pointed out that calling read_author_date_or_die() (now, read_author_date_or_null()) <em>might<\/em> be unsafe as we <em>might<\/em> not have a saved copy of the author information on the disk.<\/p>\n\n<p>The mentors and I had a long discussion on how the current calling of function is actually \u201csafe\u201d. Here is the thought process:<\/p>\n\n<ol>\n  <li>do_pick_commit() and do_merge() always call write_author_script() to write author information to the disk before calling run_git_commit() so, we are sure to find the information there on the disk.<\/li>\n  <li>commit_staged_changes() only calls run_git_commit() when it is stopped because of merge conflicts or by \u2018edit\u2019 todo commands. In this case, author_script is already written by the previous invocation of git. In all other cases, run_git_commit() throws an error as it should. So we are fine if read_author_date_or_null() also throws an error.<\/li>\n<\/ol>\n\n<h2 id=\"-current-work\">## Current Work<\/h2>\n\n<p>I am working on polishing my patches. The work is already done but before sending them to the mailing list I am thinking of updating my <a href=\"https:\/\/github.com\/r1walz\/git\/pull\/4\">PR about introducing --ignore-date<\/a>.<\/p>\n\n<p>If everything goes well, I\u2019ll have it done by tomorrow evening and will send all the commits under a new common topic \u201crebase-i-more-options\u201d (Junio named it :p) by Tuesday.<\/p>\n\n<p>See ya!<\/p>\n\n","pubDate":"Sat, 03 Aug 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/the-discussion\/","guid":"https:\/\/rashiwal.me\/2019\/the-discussion\/"},{"title":"# Second Evaluation","description":"<p>Hey Everyone!<\/p>\n\n<p>Last week I sent two patched introducing \u2013ignore-whitespace and \u2013committer-date-is-author-date to the interactive rebase. Both received good reviews and I think \u2013ignore-whitespace is in a better condition now.<\/p>\n\n<p>As for the other, I still need to get some work done. I modified the function read_env_script() to accept NULL arguments to selectively retrieve the required information. Also, I introduced read_author_date_or_die() to read the author date from disk using that modified function. The thing is, there are three callers of run_git_commit (which calls our baby function) and it turns out, as Junio pointed, calling them might not be safe as we might not have a saved copy of the author information on the disk. I\u2019m currently working on fixing this. This will significantly change the current implementation.<\/p>\n\n<p>Phillip Wood mentioned that read_author_date_or_die() is not a good function, in essence, it kills the process in the library code. We try hard to keep the process from dying in a dirty state. So, it\u2019s better to give out an error and let the repo come to a \u201cclean\u201d state than error and die out. A piece of nice advice to keep in mind.<\/p>\n\n<h2 id=\"-other-stuff\">## Other Stuff<\/h2>\n\n<p><strong>College<\/strong> Internship season is around the corner, so I had to spend some time with the Training and Placement team of the college to get my resume verified. This <em>long<\/em> process kept me busy for the whole week! Other than that:<\/p>\n\n<p><img src=\"\/assets\/second_evaluation.png\" alt=\"secone_evaluation\" \/><\/p>\n\n<p>The results of GSoC second evaluation was out and I passed! The project is going in the right direction and that too pretty fast (compared to other projects in the past), hope all my patches get merged unifying behaviour of different sequencer commands.<\/p>\n\n<p>Best!<\/p>\n","pubDate":"Fri, 26 Jul 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/second-evaluation\/","guid":"https:\/\/rashiwal.me\/2019\/second-evaluation\/"},{"title":"# A Tale of Two Patches","description":"<p>Hey Everyone!<\/p>\n\n<p>This week was very productive. I solved the part where we were spawning an octopus. It turns out that it also checks for the \u201cGIT_COMMITTER_DATE\u201d env variable and that reduced the work to a child\u2019s play.<\/p>\n\n<p><em>For perfectionists, here is the full flow chart:<\/em><\/p>\n\n<p><img src=\"\/assets\/images\/committer-date-is-author-date-2.png\" alt=\"flow chart showing control flow\" \/><\/p>\n\n<p>Finally, I was able to send two patches for the review, <a href=\"https:\/\/public-inbox.org\/git\/20190712185015.20585-1-rohit.ashiwal265@gmail.com\/\">here<\/a> and <a href=\"https:\/\/public-inbox.org\/git\/20190712185357.21211-1-rohit.ashiwal265@gmail.com\/\">here<\/a>. Merging them will teach the interactive rebase the art of ignoring whitespace changes and lying about the committer date (by changing it to the author date). Since the patches were dependent on each other, in essence, they had overlapping codes, I had to base my second patch on the first. Because they were sent during weekends, they didn\u2019t receive any comments yet. But believe it will soon receive their critical eye soon.<\/p>\n\n<h2 id=\"-future-plans\">## Future Plans<\/h2>\n\n<p>My college will re-open very soon, but I don\u2019t think that will hinder me from my work at Git. Workflow at Git allows even a busy student to work on his project without any (say) \u201cdelays\u201d since the community is spread across the globe, we are sure to receive the reviews \u2018round the clock.<\/p>\n\n<p>I\u2019ll start working on --ignore-date flag which will help us \u201clie\u201d about the author date by ignoring the date author date in the patches and using the time of commit. Actually, I\u2019ve already started working on this and soon will submit a draft PR on GitHub.<\/p>\n\n<p>Stay Tuned!<\/p>\n\n","pubDate":"Sun, 14 Jul 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/tale-of-two-patches\/","guid":"https:\/\/rashiwal.me\/2019\/tale-of-two-patches\/"},{"title":"# A Lie","description":"<p>Hey Everyone!<\/p>\n\n<p>It\u2019s almost time we fully implement --committer-date-is-author-date for rebase -i. For those who don\u2019t know, this flag helps us \u201clie\u201d about the committer date (making it equal to the author date).<\/p>\n\n<h2 id=\"-implementation\">## Implementation<\/h2>\n\n<p>Here is a flow chart showing the rough control flow of what happens when we run \u201cgit rebase -i &lt;args&gt;\u201d or \u201cgit rebase --continue\u201d.<\/p>\n\n<p><img src=\"\/assets\/images\/committer-date-is-author-date.png\" alt=\"flow chart showing control flow\" \/><\/p>\n\n<p>Both the commands (after executing \u201cepilogue\u201d) calls sequencer_continue which can be thought of as the driver function. As it is clear from the chart, in the end, all of the functions call either commit_tree_extended or run_git_commit. Both of them checks for GIT_COMMITTER_DATE env variable to set the committer date. We can easily read the author date from the author script which is saved under <a href=\"https:\/\/github.com\/git\/git\/blob\/v2.22.0\/sequencer.c#L108\">rebase_path_author_script()<\/a> and set the committer date to the value read. The catch here is, this all works only when we do not allow fast-forwards, i.e., we <a href=\"https:\/\/git-scm.com\/docs\/git-rebase\/2.22.0#Documentation\/git-rebase.txt---no-ff\">force<\/a> a rebase!<\/p>\n\n<p>Also, I\u2019ve not explored <a href=\"https:\/\/github.com\/git\/git\/blob\/v2.22.0\/sequencer.c#L3407\">the part<\/a> where we actually spawn an octopus merge to record a merge commit. I guess it also reads GIT_COMMITTER_DATE env variable somehow but we will only know for sure when we read the code ;)<\/p>\n\n<p>Remember the \u201cepilogue\u201d I mentioned? It helps us sustain the --committer-date-is-author-date flag between interrupts. Something that am based rebase can\u2019t do :P We are basically saving it as a file under the <a href=\"https:\/\/github.com\/git\/git\/blob\/v2.22.0\/sequencer.c#L50\">rebase_path()<\/a> as rebase_path_cdate_is_adate() (subject to change) and <a href=\"https:\/\/github.com\/git\/git\/blob\/v2.22.0\/sequencer.c#L2497\">checking<\/a> if this path exists to set the flag.<\/p>\n\n<p>I still need to work on the documentation and tests for this new flag. Let\u2019s see, this flag will soon be a reality!<\/p>\n\n<h2 id=\"-other-stuff\">## Other Stuff<\/h2>\n\n<p>I was discussing with the mentors about my previous patch. It\u2019s about time we send it to the mailing list. There are some final checks that need to be clear. I can already see it in the git\/git tree :P<\/p>\n\n<p>\u2018Till then!<\/p>\n\n","pubDate":"Sun, 07 Jul 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/a-lie\/","guid":"https:\/\/rashiwal.me\/2019\/a-lie\/"},{"title":"# First Evaluation","description":"<p>Hey Everyone!<\/p>\n\n<p>We are on a path to implement \u2013committer-date-is-author-date in rebase -i and this week I got to explore some parts of it, particularly the sequencer file. It is clear from the code that not only the functions directly spawning \u201cgit-commit\u201d can be \u201cfixed\u201d by setting GIT_COMMITTER_DATE variable but also some functions like commit_trees() which check for env variables will be fixed through this way. Moreover, I found that we <em>might<\/em> need to change the merge mechanism code to handle the flag but more research is needed.<\/p>\n\n<h2 id=\"-other-stuff\">## Other Stuff<\/h2>\n\n<p><img src=\"\/assets\/first_evaluation.png\" alt=\"first_evaluation\" \/><\/p>\n\n<p>The results of GSoC first evaluation was out and I passed!<\/p>\n","pubDate":"Fri, 28 Jun 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/first-evaluation\/","guid":"https:\/\/rashiwal.me\/2019\/first-evaluation\/"},{"title":"# Unproductive Week","description":"<p>Hey Everyone!<\/p>\n\n<p>Last week was even duller. I didn\u2019t get any time to work on the new flag \u2013committer-date-is-author-date. My mentors and I, all were busy with travelling and other stuff. But I discovered that setting GIT_COMMITTER_DATE environment variable through the code will not affect committer date during interactive rebase. The week ended with two more rounds of review of my earlier <a href=\"https:\/\/public-inbox.org\/git\/20190608191958.4593-1-rohit.ashiwal265@gmail.com\/\">patch<\/a>. The good news is that my patch is now in Junio\u2019s <a href=\"https:\/\/github.com\/gitster\/git\/tree\/ra\/cherry-pick-revert-skip\/\">tree<\/a>! And soon it will be merged in the main <a href=\"https:\/\/github.com\/git\/git\">git\/git<\/a> repository.<\/p>\n\n<h2 id=\"-other-stuff\">## Other Stuff<\/h2>\n\n<p>Remember that <a href=\"https:\/\/rashiwal.me\/2019\/ignoring-spaces\/#-other-stuff\">foo.bar<\/a> challenge? Dude, it is real! I received a mail from the Google Staffing! Who knows I might fetch an internship at Google for real! I am very excited.<\/p>\n\n<p>Thanks!<\/p>\n\n","pubDate":"Sat, 22 Jun 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/unproductive-week\/","guid":"https:\/\/rashiwal.me\/2019\/unproductive-week\/"},{"title":"# Esoteric Teachings About Git Commit","description":"<p>Hey Everyone!<\/p>\n\n<p>Now that we know how to use git-commit and what commits are all about, we are ready to learn about some of the rules which will help us in efficient collaboration.<\/p>\n\n<h4 id=\"-commit-related-changes\">## Commit Related Changes<\/h4>\n\n<p>A commit should contain changes related to only one topic like fixing two different bugs should enjoy their separate commits. Small, concise and scope-limited commits make it easier for other developers to understand the changes and review them.<\/p>\n\n<h4 id=\"-commit-often\">## Commit Often<\/h4>\n\n<p>Small and concise commits give the reviewers a \u201csmaller\u201d area to focus on which in turn helps them in better reviewing of the code. Moreover, it allows us to share more frequently with others thereby reducing chances of merge conflicts and also enabling easier integration.<\/p>\n\n<h4 id=\"-dont-commit-half-done-work\">## Don\u2019t Commit Half-Done Work<\/h4>\n\n<p>As discussed in the last blog post, commit is a logical entity. It should be logically independent and should contain everything from related test to documentation. Also, we should split commit into smaller logical chunks for efficient collaboration. If we are tempted to commit half-done work because of the need for a clean working tree, we can use git-stash instead. Even if we are committing WIP commits for the sake of review we should remember to squash those commits before merging them into the main tree so that everything remains logically clean and clear.<\/p>\n\n<h4 id=\"-test-your-code-before-committing\">## Test Your Code Before Committing<\/h4>\n\n<p>Sometimes we do not wait for that code review tool to finish testing our code on all platforms and we push our code to the main branch only to know that the new code broke something. This is very wrong. We should try to test our code thoroughly. Only when it passes the test suite successfully, we should merge it into the codebase. As a simple rule of thumb: divide commits such that it passes the test suite successfully for each commit.<\/p>\n\n<h4 id=\"-write-good-commit-description\">## Write Good Commit Description<\/h4>\n\n<p>Begin with a commit message, a very short summary describing overall changes in less than 50 characters. You can also add the \u201carea\u201d of work in the commit message.<\/p>\n\n<p>Next line should be a <strong>blank<\/strong> line followed by a commit description.<\/p>\n\n<p>Commit description: or the body of commit should teach us about the motivation and need for the commit, i.e., the body should spread light on the \u201cwhy\u201d and \u201cwhat\u201d part of the changes. Use imperative present tense in your commit description as if you are dictating the codebase to do something. For example,<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>sequencer: use argv_array in reset_merge\n\nAvoid using magic numbers for array size and index under `reset_merge`\nfunction. Use `argv_array` instead. This will make the code shorter and\neasier to extend.\n\nSigned-off-by: Rohit Ashiwal &lt;rohit.ashiwal265@gmail.com&gt;\n<\/code><\/pre><\/div><\/div>\n\n<p>The body should be wrapped around 72 characters since it helps git-log to format it beautifully while displaying information about the commits.<\/p>\n\n<h5 id=\"-example-1\">### Example 1<\/h5>\n\n<p>Here is an example:<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>feat: add Snackbar for loginSuccessful or loginFailed\n<\/code><\/pre><\/div><\/div>\n\n<p>The message does classify the commit as a feature commit but it is kind of redundant as it is implied that a commit will always bring a new kind of change. Also, the commit message has an area work but it can be better formatted as:<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>login: display login state information using snackbar\n<\/code><\/pre><\/div><\/div>\n\n<p>This is a better message as in it provides a clear area of work and more generic kind of information about the what was done.<\/p>\n\n<h5 id=\"-example-2\">### Example 2<\/h5>\n\n<p>Let\u2019s have a look on another example:<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>cherry-pick\/revert: add --skip flag\n\nWe are trying to implement git cherry-pick --skip for that I've\nintroduced sequencer_skip in the sequencer.c file which basically\ncalls rollback_single_pick and then, if there are still instructions\nin todo file, sequencer_continue.\n<\/code><\/pre><\/div><\/div>\n\n<p>Commit message looks nice but the commit description is not good. It speaks more about \u201chow\u201d we are trying to achieve whatever we are trying to achieve (in this case adding \u2013skip flag to cherry-pick and revert). A better commit message could be:<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>cherry-pick\/revert: add --skip flag\n\ngit am or rebase advise the user to use `git (am | rebase) --skip` to\nskip the commit. cherry-pick and revert also have this concept of\nskipping commits but they advise the user to use `git reset` (or in\ncase of a patch which had conflicts, `git reset --merge`) which on the\nuser's part is annoying and sometimes confusing. Add a `--skip` option\nto make these commands more consistent.\n<\/code><\/pre><\/div><\/div>\n\n<p>This is better because it clearly explains the motivation of adding \u2013skip flag and why is there a need for this flag anyway. The commit description also dictates the difficulties currently faced by the users providing even more reason for this change.<\/p>\n\n<hr \/>\n\n<p>Now you know about the secrets of committing to achieve effective open source collaboration. Bring these rules in practice and you\u2019ll notice differences, be it in surfing the git history or cherry-picking the required commits just by reading the oneliners. Hope you learned something new!<\/p>\n\n<p>Thanks!<\/p>\n","pubDate":"Mon, 17 Jun 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/esoteric-git-commit\/","guid":"https:\/\/rashiwal.me\/2019\/esoteric-git-commit\/"},{"title":"# Common Teachings About Git Commit","description":"<p>Hey Everyone!<\/p>\n\n<p>I know Git (a popular <a href=\"https:\/\/www.git-tower.com\/learn\/git\/ebook\/en\/desktop-gui\/basics\/what-is-version-control\">VCS<\/a>) can be intimidating at first but learning and understanding it can help us efficiently develop software solutions. Today, I\u2019ll introduce you to \u201ccommit\u201d, a very commonly used command, which is linked to the very concept of version control.<\/p>\n\n<h2 id=\"-git-commit\">## git-commit<\/h2>\n\n<p>According to <a href=\"https:\/\/git-scm.com\/docs\/git-commit\">man page<\/a> of git-commit:<\/p>\n\n<blockquote>\n  <p>git-commit - Record changes to the repository<\/p>\n\n  <p>[--- and a long description ---]<\/p>\n<\/blockquote>\n\n<p>Well, that is not very helpful to beginners. Man pages can be hard to understand (or even navigate through) by themselves. Let\u2019s break down to simpler terms what git-commit is all about.<\/p>\n\n<blockquote>\n  <p>quick note: we are not talking about commits as in git-internals but as an entity for the better understanding since users will not be going inside and question us anyway :p<\/p>\n<\/blockquote>\n\n<p>A commit is a logical entity which records a snapshot of the current state of the file system. It contains information about which files were changed, who authored them and at what time, time of commit, who committed (to the main tree), a message suggesting what was done\/changed and why, a PGP signature and much more in a cryptic form.<\/p>\n\n<p>git-commit is the porcelain command which records these commits to the commit tree and updates the HEAD of the branch to point to the latest commit. Prior use of the git-add [<sup id=\"fnref:1\" role=\"doc-noteref\"><a href=\"#fn:1\" class=\"footnote\" rel=\"footnote\">1<\/a><\/sup>] command is required to select the changes that will be staged for the next commit. Then git-commit is used to create a snapshot of the staged changes along a timeline of a Git project\u2019s history.<\/p>\n\n<h3 id=\"-important-options\">### Important Options<\/h3>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>-m &lt;message&gt;  :  Sets the commit's message. A oneliner describing what\n                 the commit is all about\n-a, --all     :  Includes all currently modified (and tracked) files\n                 in this commit\n--amend       :  Rewrite the last commit with any currently staged\n                 changes and\/or a new commit message\n--no-edit     :  Do not launch the editor, just use the previous commit\n                 message\n-S[&lt;keyid&gt;]   :  Add your PGP signature. Remember to add a signing key\n                 using git-config for easier workflow\n-s            :  Add DCO at the end of commit description\n<\/code><\/pre><\/div><\/div>\n\n<h3 id=\"-usage-examples\">### Usage Examples<\/h3>\n\n<p>For a basic workflow, you can use git-add command to stage changes for the next commit.<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>$ git add main.c\n$ git commit -m \"add the driver program\"\n<\/code><\/pre><\/div><\/div>\n\n<p>If you have lots of changed files in your working directory and want all of them included in the next commit then make use of <code class=\"language-plaintext highlighter-rouge\">-a<\/code> option. Thereby omit the <code class=\"language-plaintext highlighter-rouge\">git-add<\/code> step.<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>$ git commit -am \"teach this that\"\n<\/code><\/pre><\/div><\/div>\n\n<p>The <code class=\"language-plaintext highlighter-rouge\">--amend<\/code> option comes handy when we have to change that mistyped word in the commit message\/description or forgot to add that header file.<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>$ git add forgotten-header.h\n$ git commit --amend [--no-edit]\n<\/code><\/pre><\/div><\/div>\n\n<p>You can also PGP sign your commits using <code class=\"language-plaintext highlighter-rouge\">-S<\/code> option or add a simple DCO [<sup id=\"fnref:2\" role=\"doc-noteref\"><a href=\"#fn:2\" class=\"footnote\" rel=\"footnote\">2<\/a><\/sup>] to your commits using <code class=\"language-plaintext highlighter-rouge\">-s<\/code>.<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>$ git commit -sS\nEDITOR -------------------------------------------------------------------------\nmain: add greetings                                           # commit message\n\nWe need to greet our users before giving the control to the   # commit\nCLI interface. Add greetings at the startup of the program.   # description\n\nSigned-off-by: Rohit Ashiwal &lt;rohit.ashiwal265@gmail.com&gt;     # DCO\n\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#\n# On branch master\n#\n# Initial commit\n#\n# Changes to be committed:\n#       new file:   main.c\n--------------------------------------------------------------------------------\n<\/code><\/pre><\/div><\/div>\n\n<h2 id=\"-summary\">## Summary<\/h2>\n\n<p>We learned about what commits are and how to record changes using git-commit. We also learned some common options of the command. But only knowing about what they are is not enough. There is much more to it like how should we organise commits, i.e., how to divide them properly, what to write in commit message\/description. Even length of each line of commit message\/description is important! Soon I\u2019ll write another blog explaining about these points.<\/p>\n\n<p>See you there!<\/p>\n\n<hr \/>\n<p>Footnote:<\/p>\n\n<div class=\"footnotes\" role=\"doc-endnotes\">\n  <ol>\n    <li id=\"fn:1\" role=\"doc-endnote\">\n      <p>1: Here is a tutorial on <a href=\"https:\/\/rubygarage.org\/blog\/most-basic-git-commands-with-examples\">basics of Git<\/a> with examples\u00a0<a href=\"#fnref:1\" class=\"reversefootnote\" role=\"doc-backlink\">&#8617;<\/a><\/p>\n    <\/li>\n    <li id=\"fn:2\" role=\"doc-endnote\">\n      <p>2: What is <a href=\"https:\/\/en.wikipedia.org\/wiki\/Developer_Certificate_of_Origin\">DCO<\/a>? Word of <a href=\"https:\/\/developercertificate.org\/\">DCO<\/a>.\u00a0<a href=\"#fnref:2\" class=\"reversefootnote\" role=\"doc-backlink\">&#8617;<\/a><\/p>\n    <\/li>\n  <\/ol>\n<\/div>\n","pubDate":"Mon, 17 Jun 2019 00:00:00 +0000","link":"https:\/\/rashiwal.me\/2019\/common-git-commit\/","guid":"https:\/\/rashiwal.me\/2019\/common-git-commit\/"}]}}