# [PATCH] merge: simplify code flow

3 messages from 2015-04-23 to 2015-04-23. Participants: Junio C Hamano, Jeff King.
Thread: https://gitlist.dev/t/39147

## Junio C Hamano, 2015-04-23 20:01

Subject: [PATCH] merge: simplify code flow
Message-ID: <xmqqh9s6397b.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqh9s6397b.fsf%40gitster.dls.corp.google.com

```
One of the first things cmd_merge() does is to see if the "--abort"
option is given and run "reset --merge" and exit.  When the control
reaches this point, we know "--abort" was not given.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/merge.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/builtin/merge.c b/builtin/merge.c
index 3b0f8f9..0ab7142 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1158,15 +1158,15 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 		option_commit = 0;
 	}
 
-	if (!abort_current_merge) {
-		if (!argc) {
-			if (default_to_upstream)
-				argc = setup_with_upstream(&argv);
-			else
-				die(_("No commit specified and merge.defaultToUpstream not set."));
-		} else if (argc == 1 && !strcmp(argv[0], "-"))
-			argv[0] = "@{-1}";
+	if (!argc) {
+		if (default_to_upstream)
+			argc = setup_with_upstream(&argv);
+		else
+			die(_("No commit specified and merge.defaultToUpstream not set."));
+	} else if (argc == 1 && !strcmp(argv[0], "-")) {
+		argv[0] = "@{-1}";
 	}
+
 	if (!argc)
 		usage_with_options(builtin_merge_usage,
 			builtin_merge_options);

```

## Jeff King, 2015-04-23 20:10

Subject: Re: [PATCH] merge: simplify code flow
Message-ID: <20150423201019.GA28338@peff.net>
URL: https://gitlist.dev/e/20150423201019.GA28338%40peff.net
In-Reply-To: <xmqqh9s6397b.fsf@gitster.dls.corp.google.com>

```
On Thu, Apr 23, 2015 at 01:01:44PM -0700, Junio C Hamano wrote:

> One of the first things cmd_merge() does is to see if the "--abort"
> option is given and run "reset --merge" and exit.  When the control
> reaches this point, we know "--abort" was not given.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Yeah, this looks obviously correct.

As an aside, the fact that the actual "if (abort_current_merge)"
conditional ends with a "goto" to a cleanup label that is 500 lines away
is...kind of gross.

-Peff

```

## Junio C Hamano, 2015-04-23 20:15

Subject: Re: [PATCH] merge: simplify code flow
Message-ID: <xmqqd22u38l0.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqd22u38l0.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20150423201019.GA28338@peff.net>

```
Jeff King <peff@peff.net> writes:

> Yeah, this looks obviously correct.

It is funny that this dates back to the very beginning of defaulting
to the upstream, the code that "if ()" block implements, introduced
at 93e535a5 (merge: merge with the default upstream branch without
argument, 2011-03-23).

> As an aside, the fact that the actual "if (abort_current_merge)"
> conditional ends with a "goto" to a cleanup label that is 500 lines away
> is...kind of gross.

Reading "git show 93e535a5" output, I see that it is a more recent
"breakage" ;-)

```
