# [PATCH] push: Correctly initialize nonfastforward in do_push.

2 messages from 2009-09-16 to 2009-09-16. Participants: Matthieu Moy, Junio C Hamano.
Thread: https://gitlist.dev/t/20973

## Matthieu Moy, 2009-09-16 16:37

Subject: [PATCH] push: Correctly initialize nonfastforward in do_push.
Message-ID: <1253119020-26547-1-git-send-email-Matthieu.Moy@imag.fr>
URL: https://gitlist.dev/e/1253119020-26547-1-git-send-email-Matthieu.Moy%40imag.fr

```
The variable is assigned unconditionally in print_push_status, but
print_push_status is not reached by all codepaths. In particular, this
fixes a bug where "git push ... nonexisting-branch" was complaining about
non-fast forward.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
(I'm the one to blame, sorry for introducing this bug)

 builtin-push.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-push.c b/builtin-push.c
index 3cb1ee4..a73333b 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -140,7 +140,7 @@ static int do_push(const char *repo, int flags)
 		struct transport *transport =
 			transport_get(remote, url[i]);
 		int err;
-		int nonfastforward;
+		int nonfastforward = 0;
 		if (receivepack)
 			transport_set_option(transport,
 					     TRANS_OPT_RECEIVEPACK, receivepack);
-- 
1.6.5.rc1.11.g2d184.dirty

```

## Junio C Hamano, 2009-09-16 17:13

Subject: Re: [PATCH] push: Correctly initialize nonfastforward in do_push.
Message-ID: <7vpr9q24oa.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vpr9q24oa.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1253119020-26547-1-git-send-email-Matthieu.Moy@imag.fr>

```
Matthieu Moy <Matthieu.Moy@imag.fr> writes:

> The variable is assigned unconditionally in print_push_status, but
> print_push_status is not reached by all codepaths. In particular, this
> fixes a bug where "git push ... nonexisting-branch" was complaining about
> non-fast forward.

Hmm, the patch looks correct but I am scratching my head to see how this
is triggered.  "git push ... nonexisting-branch" seems to get:

	error: src refspec nonexisting-branch does not match any.
        error: failed to push some refs to '...'

```
