Commit d5c84f67 by Carlos Martín Nieto

local: adjust to the common refspec parser

We no longer have NULL strings, but empty ones and duplicate the sides
if necessar, so the first check will never do anything.

While in the area, remove unnecessary ifs and early returns.
parent 3fade40e
...@@ -339,14 +339,11 @@ static int local_push_update_remote_ref( ...@@ -339,14 +339,11 @@ static int local_push_update_remote_ref(
int error; int error;
git_reference *remote_ref = NULL; git_reference *remote_ref = NULL;
/* rref will be NULL if it is implicit in the pushspec (e.g. 'b1:') */ /* check for lhs, if it's empty it means to delete */
rref = rref ? rref : lref; if (lref[0] != '\0') {
if (lref) {
/* Create or update a ref */ /* Create or update a ref */
if ((error = git_reference_create(NULL, remote_repo, rref, loid, error = git_reference_create(NULL, remote_repo, rref, loid,
!git_oid_iszero(roid), NULL, NULL)) < 0) !git_oid_iszero(roid), NULL, NULL);
return error;
} else { } else {
/* Delete a ref */ /* Delete a ref */
if ((error = git_reference_lookup(&remote_ref, remote_repo, rref)) < 0) { if ((error = git_reference_lookup(&remote_ref, remote_repo, rref)) < 0) {
...@@ -355,13 +352,11 @@ static int local_push_update_remote_ref( ...@@ -355,13 +352,11 @@ static int local_push_update_remote_ref(
return error; return error;
} }
if ((error = git_reference_delete(remote_ref)) < 0) error = git_reference_delete(remote_ref);
return error;
git_reference_free(remote_ref); git_reference_free(remote_ref);
} }
return 0; return error;
} }
static int local_push( static int local_push(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment