-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Branch upstream configuration #1450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The term 'tracking' is overloaded. Help distinguish what we mean by using 'upstream' for this part of the library.
👍 |
if ((ret = remote_name(&buf, repo, refname)) < 0) | ||
return ret; | ||
|
||
if (buffer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, one shouldn't wrap single statements in braces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is a left-over
Return the size we'd need to write to instead of simply an error. Split the function into two to be used later by the upstream configuration functions.
* | ||
* @return 0 or an error code | ||
*/ | ||
GIT_EXTERN(int) git_branch_unset_upstream(git_reference *branch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather see this implemented as git_branch_set_upstream(branch, NULL)
. Can you make it happen? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Add functions to set and unset the upstream configuration to complement the getter we already have.
Magnificient. |
Branch upstream configuration
First rename
git_branch_tracking
togit_branch_upstream
to use clearer nomenclature and then addset_upstream
andunset_upstream
to let the user manage the upstream configuration without needing to care how the configuration is written.For
set_upstream
I kept going back and forth between passing a{remote, refname}
pair and the upstream branch directly. Given the unfortunate complexity of getting the pair, I went with "whatevergit_branch_lookup
will do something with" which should give the least surprising result for a given string.I'm still not quite sure whether the split-up version of
git_branch_remote_name
should return the remote name or the remote directly, as we then have to load it again inset_upstream
.