Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

augfab
Copy link
Contributor

@augfab augfab commented Feb 21, 2019

This PR is a proposed fix for issue #4938.

Copy link
Member

@ethomson ethomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Thanks for tackling this. I have just a few minor issues to request that you address, if you don't mind.

src/branch.c Outdated
break;
case GIT_BRANCH_ALL:
error = retrieve_branch_reference(ref_out, repo, branch_name, false);
if (error < 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably only retry when error == GIT_ENOTFOUND, otherwise we might hide potentially fatal errors by ignoring them and doing something else.

src/branch.c Outdated
error = retrieve_branch_reference(ref_out, repo, branch_name, true);
break;
default:
abort();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abort is probably a bit harsh here. I think assert(0) is a reasonable compromise that we've used in the past.

@@ -23,17 +23,22 @@ void test_refs_branches_lookup__cleanup(void)
void test_refs_branches_lookup__can_retrieve_a_local_branch(void)
{
cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_LOCAL));
cl_git_pass(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_ALL));
cl_git_fail(git_branch_lookup(&branch, repo, "br2", GIT_BRANCH_REMOTE));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're leaking memory here, namely the results of the prior git_branch_lookup that are hidden with the new assignment to branch. Probably best to just make each one of these calls their own test function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was scratching my head about that, thanks for the explanation 🙂.

@augfab
Copy link
Contributor Author

augfab commented Feb 22, 2019

Thanks a lot @ethomson for the review!
I'll submit a new branch soon.

@ethomson
Copy link
Member

Awesome, thanks @augfab for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants