Skip to content

Commit 03b51b5

Browse files
committed
Merge pull request libgit2#2955 from git-up/update_tips_fixes
Update tips fixes
2 parents 83ad46f + 1034f1b commit 03b51b5

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/push.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ int git_push_update_tips(git_push *push)
180180
git_vector_foreach(&push->status, i, status) {
181181
int fire_callback = 1;
182182

183+
/* Skip unsuccessful updates which have non-empty messages */
184+
if (status->msg)
185+
continue;
186+
183187
/* Find the corresponding remote ref */
184188
fetch_spec = git_remote__matching_refspec(push->remote, status->ref);
185189
if (!fetch_spec)
@@ -198,21 +202,18 @@ int git_push_update_tips(git_push *push)
198202
if (j == push->specs.length)
199203
continue;
200204

201-
/* If this ref update was successful (ok, not ng), it will have an empty message */
202-
if (status->msg == NULL) {
203-
/* Update the remote ref */
204-
if (git_oid_iszero(&push_spec->loid)) {
205-
error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
205+
/* Update the remote ref */
206+
if (git_oid_iszero(&push_spec->loid)) {
207+
error = git_reference_lookup(&remote_ref, push->remote->repo, git_buf_cstr(&remote_ref_name));
206208

207-
if (error >= 0) {
208-
error = git_reference_delete(remote_ref);
209-
git_reference_free(remote_ref);
210-
}
211-
} else {
212-
error = git_reference_create(NULL, push->remote->repo,
213-
git_buf_cstr(&remote_ref_name), &push_spec->loid, 1,
214-
"update by push");
209+
if (error >= 0) {
210+
error = git_reference_delete(remote_ref);
211+
git_reference_free(remote_ref);
215212
}
213+
} else {
214+
error = git_reference_create(NULL, push->remote->repo,
215+
git_buf_cstr(&remote_ref_name), &push_spec->loid, 1,
216+
"update by push");
216217
}
217218

218219
if (error < 0) {

src/remote.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,6 +2329,10 @@ int git_remote_upload(git_remote *remote, const git_strarray *refspecs, const gi
23292329
(error = git_remote_connect(remote, GIT_DIRECTION_PUSH)) < 0)
23302330
goto cleanup;
23312331

2332+
free_refspecs(&remote->active_refspecs);
2333+
if (dwim_refspecs(&remote->active_refspecs, &remote->refspecs, &remote->refs) < 0)
2334+
goto cleanup;
2335+
23322336
if (remote->push) {
23332337
git_push_free(remote->push);
23342338
remote->push = NULL;

0 commit comments

Comments
 (0)