REMOVING GOTO STATEMENTS
In my previous post, I explained one of the improvements I was coding was removing goto statements of builtin/bisect-helper.c
file.
In my first approach, I got rid of all goto’s present in the file. They affected six functions and I made one commit per each one. After discussing with my mentor,
only commits related to the patch series I am preparing will be sent and the rest will be done as improvement steps later on.
There were two functions of my patch series with goto’s: bisect_replay()
and bisect_skipped_commits()
.
The scheme followed to removed them was to separate steps in functions and replace goto statements with return calls.
For example: in a nutshell, bisect_replay()
is a function that reproduces a bisect session given a log file, and all file processing was done inside it.
Now, responsabilities have been separated and there is a main function bisect_replay()
that, after checking if file exists and resetting bisect session, calls process_replay_file()
which in turn calls process_line()
. Finally, bisect_replay()
reproduces the session.
This way, we remove goto’s and also functions are organized and splitted by functionalities.
Finally, the changes were squashed in their corresponding commits:
- bisect–helper: reimplement
bisect_replay
shell function in C - bisect–helper: reimplement
bisect_next
andbisect_auto_next
shell functions in C
REFINING PATCH SERIES
Also more refining work has been done. For example, making sure that indentation was correct, or
applying Git project coding standards such as removing braces ({}
) for one-line conditional and loop statements:
if (condition)
{
do_something;
}
was changed by:
if (condition)
do_something;
Commit messages or subject amending has been done, too.
This work has been performed in cycles. I sent my changes to my mentor and after reviewing, new suggestions arose and I applied them.
We are very close to having a final version branch and generating a patch series that will be sent to the mailing list. After that, I will receive the community feedback, implement pertinent changes and send the new patches versions in order to be integrated in the project.
MOVING FORWARD
This week I have also started to move forward some work that still needs to be done, like removing git-bisect.sh
from the project, renaming builtin/bisect--helper.c
to builtin/bisect.c
, changing bisect–helper options name by their final names (without “–bisect-prefix”) for example, to complete the conversion of git bisect
from shell to C.
Thank you for reading!