GSoC Week 2



A slow week

This week felt quite slow. I just got off with the conversion of ‘set-branch’ and figured out what problems were there with the collective effort of my mentors and mine (more on that in the following sections). The ‘set-url’ conversion and my contributions to gitFAQ just reached the master branch of git/git, feels nice <3.

What I have inferred till now, is that communication is KEY. If anyone, even if you are a (to-be) GSoC student or a junior/friend of mine reading this, one thing you should never forget is communicating about the problems you are facing with someone senior and more experienced than you. What you are facing right now, there’s a really high chance that they might’ve faced something similar (if not identical) before.

The above paragraph kinda sums up how I finished the conversion of set-branch. So going into detail:

What had happened?

If you read the previous blog, you may have noticed what problem I had faced back then. Quoting from the last blog:

I discovered this while debugging the errors, by doing a cat .gitmodules, observing that an entry was never even made in the first place for the branch

And,

… my goal now is to create a mechanism which will make a submodule.<name>.branch entry in .gitmodules if one does not exist and update it with the branch desired in the arguments of the subcommand

As you may observe, the naive me thought that there was a problem in inserting an entry into the .gitmodules file and hence I embarked on a quest to create a “mechanism” to do so. But guess what, this wasn’t even the problem in the first place. Want to know what happened? Let’s move to the next section.

The Real Problem

So, the real problem actually was with the option parsing. You see, what parse_options does is filter out the optional arguments and the non-option arguments (such as filenames, branch names, etc.) and modify the argv[] array and argc appropriately. When I had debugged their values (using a WARNING message), I was stumped to see that an argument was missing… from the middle of the entered command!! The test command was (from t7419):

git submodule set-branch --branch topic submodule  

The missing argument was topic, thus making argc=1 (the only argument being submodule). Now, after hours of debugging I was extremely confused and going around in circles until I mailed my mentors about the problem I was facing. Turns out, the error wasn’t in the C code but rather in the shell code. My mentor Christian sent me this Documentation about parameter substiution in BASH. And then I realised that at this line in the shell script:

git ${wt_prefix:+-C "$wt_prefix"} ${prefix:+--super-prefix "$prefix"} submodule--helper set-branch ${GIT_QUIET:+--quiet} ${branch:+--branch "$branch"} ${default:+--default} -- "$@"

I had missed out on the $branch argument, due to which the C code never really accepted a branch. The statement ${branch:+--branch $branch}, translates to: If branch is set and is non-NULL, set it to $branch (i.e., topic in this case) else set it to -branch. Had I not communicated with my mentors, I wouldn’t have been able to write this blog in the first place ;)

Next Steps

The conversion is done with. Now I will submit a v2 for review shortly after getting some advice from my mentors regarding my changes. This will mark the end of my subproject 1 (SP1) of GSoC. My next goal is the conversion of subcommand summary from shell to C.

Stay home, stay safe! ;)

Over and out,
Shourya Shukla

Comments

Popular posts from this blog

The Final Report

GSoC Week 4 [One month special]

GSoC Week 10