Sally wants more privacy. She decides to create her own branch.
lottery sally$ ls branches tags trunk lottery sally$ svn copy trunk branches/no_boys_allowed A branches/no_boys_allowed lottery sally$ svn st ? trunk/pb A + branches/no_boys_allowed ? branches/no_boys_allowed/pb lottery sally$ svn commit -m "a private branch so I can work without harry" Adding branches/no_boys_allowed Committed revision 14.
Now that Sally is working in her own branch, she feels much more
productive. She adds support for the “favorite” option. When a user is playing
his
favorite numbers, his chances of winning should be doubled. In doing this,
she had to rework the way command-line args are parsed.
And she removes an atoi() call she missed last time.
And she restructures all the error checking into one place.
So main() now looks like this:
int main(int argc, char** argv)
{
int balls[6];
int count_balls = 0;
int favorite = 0;
for (int i=1; i<argc; i++)
{
const char* arg = argv[i];
if ('-' == arg[0])
{
if (0 == strcmp(arg, "-favorite"))
{
favorite = 1;
}
else
{
goto usage_error;
}
}
else
{
char* endptr = NULL;
long val = strtol(arg, &endptr, 10);
if (*endptr)
{
goto usage_error;
}
balls[count_balls++] = (int) val;
}
}
if (6 != count_balls)
{
goto usage_error;
}
int power_ball = balls[5];
int result = calculate_result(balls, power_ball);
if (result < 0)
{
goto usage_error;
}
if (LUCKY_NUMBER == power_ball)
{
result = result * 2;
}
if (favorite)
{
result = result * 2;
}
printf("%d percent chance of winning\n", result);
return 0;
usage_error:
fprintf(stderr, "Usage: %s [-favorite] (5 white balls) power_ball\n", argv[0]);
return -1;
}
She commits her changes, knowing that the commit will succeed because she is working in her private branch.
no_boys_allowed sally$ svn commit -m "add -favorite and cleanup some other stuff" Sending no_boys_allowed/pb.c Transmitting file data . Committed revision 15.
|
I am happy for Sally and her burst of productivity here, but she probably should have made these changes in two or three separate commits instead of squashing them all into one. |