diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-23 21:34:45 +0100 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-23 21:34:45 +0100 |
commit | d5c84f67d311ed177ddfbd1c2645e23e46df5729 (patch) | |
tree | d7911acf85cc3745459aaa20d5604b6bb0dc4621 | |
parent | 3fade40e393e1ca74be7f475819fcaecc9f4dc83 (diff) | |
download | libgit2-d5c84f67d311ed177ddfbd1c2645e23e46df5729.tar.gz |
local: adjust to the common refspec parsercmn/local-push
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.
-rw-r--r-- | src/transports/local.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/transports/local.c b/src/transports/local.c index c544fa935..3846f06d0 100644 --- a/src/transports/local.c +++ b/src/transports/local.c @@ -339,14 +339,11 @@ static int local_push_update_remote_ref( int error; git_reference *remote_ref = NULL; - /* rref will be NULL if it is implicit in the pushspec (e.g. 'b1:') */ - rref = rref ? rref : lref; - - if (lref) { + /* check for lhs, if it's empty it means to delete */ + if (lref[0] != '\0') { /* Create or update a ref */ - if ((error = git_reference_create(NULL, remote_repo, rref, loid, - !git_oid_iszero(roid), NULL, NULL)) < 0) - return error; + error = git_reference_create(NULL, remote_repo, rref, loid, + !git_oid_iszero(roid), NULL, NULL); } else { /* Delete a ref */ if ((error = git_reference_lookup(&remote_ref, remote_repo, rref)) < 0) { @@ -355,13 +352,11 @@ static int local_push_update_remote_ref( return error; } - if ((error = git_reference_delete(remote_ref)) < 0) - return error; - + error = git_reference_delete(remote_ref); git_reference_free(remote_ref); } - return 0; + return error; } static int local_push( |