summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-03-18 05:04:12 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2015-03-18 05:04:12 +0100
commit03b51b5d945355260bd34971a31ba8d6958cfb99 (patch)
tree9549910832482ab736b52e48cd340381edf78e02
parent83ad46f7269aa9768c768a366f5cc3912f84a421 (diff)
parent1034f1b583e4bfe39d46243568aafb27e725f2fa (diff)
downloadlibgit2-03b51b5d945355260bd34971a31ba8d6958cfb99.tar.gz
Merge pull request #2955 from git-up/update_tips_fixes
Update tips fixes
-rw-r--r--src/push.c27
-rw-r--r--src/remote.c4
2 files changed, 18 insertions, 13 deletions
diff --git a/src/push.c b/src/push.c
index c6a93ba2f..d4171bbd6 100644
--- a/src/push.c
+++ b/src/push.c
@@ -180,6 +180,10 @@ int git_push_update_tips(git_push *push)
git_vector_foreach(&push->status, i, status) {
int fire_callback = 1;
+ /* Skip unsuccessful updates which have non-empty messages */
+ if (status->msg)
+ continue;
+
/* Find the corresponding remote ref */
fetch_spec = git_remote__matching_refspec(push->remote, status->ref);
if (!fetch_spec)
@@ -198,21 +202,18 @@ int git_push_update_tips(git_push *push)
if (j == push->specs.length)
continue;
- /* If this ref update was successful (ok, not ng), it will have an empty message */
- if (status->msg == NULL) {
- /* Update the remote ref */
- if (git_oid_iszero(&push_spec->loid)) {
- error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
+ /* Update the remote ref */
+ if (git_oid_iszero(&push_spec->loid)) {
+ error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
- if (error >= 0) {
- error = git_reference_delete(remote_ref);
- git_reference_free(remote_ref);
- }
- } else {
- error = git_reference_create(NULL, push->remote->repo,
- git_buf_cstr(&remote_ref_name), &push_spec->loid, 1,
- "update by push");
+ if (error >= 0) {
+ error = git_reference_delete(remote_ref);
+ git_reference_free(remote_ref);
}
+ } else {
+ error = git_reference_create(NULL, push->remote->repo,
+ git_buf_cstr(&remote_ref_name), &push_spec->loid, 1,
+ "update by push");
}
if (error < 0) {
diff --git a/src/remote.c b/src/remote.c
index bdb4b31df..ac7c43c78 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -2329,6 +2329,10 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
(error = git_remote_connect(remote, GIT_DIRECTION_PUSH)) < 0)
goto cleanup;
+ free_refspecs(&remote->active_refspecs);
+ if (dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs) < 0)
+ goto cleanup;
+
if (remote->push) {
git_push_free(remote->push);
remote->push = NULL;