summaryrefslogtreecommitdiff
path: root/builtin-push.c
diff options
context:
space:
mode:
authorTay Ray Chuan <rctay89@gmail.com>2009-12-03 23:31:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-12-04 00:00:20 (GMT)
commit53970b92d9dc883669f3a9b79b5e39e73931b331 (patch)
tree329353c73dd255a5022fb48a9b27156b4d240b11 /builtin-push.c
parent2fe40b63001844f9a884ac9cb49cabd5e183b62f (diff)
downloadgit-53970b92d9dc883669f3a9b79b5e39e73931b331.zip
git-53970b92d9dc883669f3a9b79b5e39e73931b331.tar.gz
git-53970b92d9dc883669f3a9b79b5e39e73931b331.tar.bz2
builtin-push: don't access freed transport->url
Move the failed push message to before transport_disconnect() so that it doesn't access transport->url after transport has been free()'d (in transport_disconnect()). Additionally, make the failed push message more accurate by moving it before transport_disconnect(), so that it doesn't report errors due to a failed disconnect. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-push.c')
-rw-r--r--builtin-push.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin-push.c b/builtin-push.c
index 9846c63..03be045 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -102,13 +102,14 @@ static int push_with_options(struct transport *transport, int flags)
fprintf(stderr, "Pushing to %s\n", transport->url);
err = transport_push(transport, refspec_nr, refspec, flags,
&nonfastforward);
+ if (err != 0)
+ error("failed to push some refs to '%s'", transport->url);
+
err |= transport_disconnect(transport);
if (!err)
return 0;
- error("failed to push some refs to '%s'", transport->url);
-
if (nonfastforward && advice_push_nonfastforward) {
printf("To prevent you from losing history, non-fast-forward updates were rejected\n"
"Merge the remote changes before pushing again. See the 'non-fast-forward'\n"