# [PATCH] git-merge: mutually match SYNOPSIS and "usage".

5 messages from 2014-10-07 to 2014-10-08. Participants: Sergey Organov, Junio C Hamano.
Thread: https://gitlist.dev/t/37680

## Sergey Organov, 2014-10-07 11:54

Subject: [PATCH] git-merge: mutually match SYNOPSIS and "usage".
Message-ID: <87wq8cnla9.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87wq8cnla9.fsf%40osv.gnss.ru

```
SYNOPSIS section of the git-merge manual page had outdated explicit
list of options.

"usage" returned by 'git merge -h' didn't have "-m <msg>" that is one
of essential distinctions between obsolete invocation form and the
recent one.

Signed-off-by: Sergey Organov <sorganov@gmail.com>
---
 Documentation/git-merge.txt | 6 ++----
 builtin/merge.c             | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index cf2c374..e24a1d4 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -9,10 +9,8 @@ git-merge - Join two or more development histories together
 SYNOPSIS
 --------
 [verse]
-'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
-	[-s <strategy>] [-X <strategy-option>] [-S[<key-id>]]
-	[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
-'git merge' <msg> HEAD <commit>...
+'git merge' [options] [-m <msg>] [<commit>...]
+'git merge' [options] <msg> HEAD <commit>...
 'git merge' --abort
 
 DESCRIPTION
diff --git a/builtin/merge.c b/builtin/merge.c
index dff043d..086502f 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -40,7 +40,7 @@ struct strategy {
 };
 
 static const char * const builtin_merge_usage[] = {
-	N_("git merge [options] [<commit>...]"),
+	N_("git merge [options] [-m <msg>] [<commit>...]"),
 	N_("git merge [options] <msg> HEAD <commit>"),
 	N_("git merge --abort"),
 	NULL
-- 
1.9.3

```

## Junio C Hamano, 2014-10-07 18:34

Subject: Re: [PATCH] git-merge: mutually match SYNOPSIS and "usage".
Message-ID: <xmqq4mvfg24e.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq4mvfg24e.fsf%40gitster.dls.corp.google.com
In-Reply-To: <87wq8cnla9.fsf@osv.gnss.ru>

```
Sergey Organov <sorganov@gmail.com> writes:

> SYNOPSIS section of the git-merge manual page had outdated explicit
> list of options.
>
> "usage" returned by 'git merge -h' didn't have "-m <msg>" that is one
> of essential distinctions between obsolete invocation form and the
> recent one.
>
> Signed-off-by: Sergey Organov <sorganov@gmail.com>
> ---

Please do not do two unrelated things in a single change.

It may be a clear and very welcome improvement to change from
"explicitly list only often used options" to "just say [options] and
have the list of options and their descriptions".

I am not sure about the other change to single out "-m <msg>",
especially marking it as optional by enclosing it inside "[-m
<msg>]", makes much sense, as that is still not very easily
distinguishable from "git merge [options] [<commit>...]".  In other
words, I agree with your motivation to call for attention that the
command behaves differently with and without "-m", but I do not
think that part of the change in this patch achieves it well.

>  Documentation/git-merge.txt | 6 ++----
>  builtin/merge.c             | 2 +-
>  2 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
> index cf2c374..e24a1d4 100644
> --- a/Documentation/git-merge.txt
> +++ b/Documentation/git-merge.txt
> @@ -9,10 +9,8 @@ git-merge - Join two or more development histories together
>  SYNOPSIS
>  --------
>  [verse]
> -'git merge' [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
> -	[-s <strategy>] [-X <strategy-option>] [-S[<key-id>]]
> -	[--[no-]rerere-autoupdate] [-m <msg>] [<commit>...]
> -'git merge' <msg> HEAD <commit>...
> +'git merge' [options] [-m <msg>] [<commit>...]
> +'git merge' [options] <msg> HEAD <commit>...
>  'git merge' --abort
>  
>  DESCRIPTION
> diff --git a/builtin/merge.c b/builtin/merge.c
> index dff043d..086502f 100644
> --- a/builtin/merge.c
> +++ b/builtin/merge.c
> @@ -40,7 +40,7 @@ struct strategy {
>  };
>  
>  static const char * const builtin_merge_usage[] = {
> -	N_("git merge [options] [<commit>...]"),
> +	N_("git merge [options] [-m <msg>] [<commit>...]"),
>  	N_("git merge [options] <msg> HEAD <commit>"),
>  	N_("git merge --abort"),
>  	NULL

```

## Sergey Organov, 2014-10-07 20:32

Subject: Re: [PATCH] git-merge: mutually match SYNOPSIS and "usage".
Message-ID: <87bnpnsjrw.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87bnpnsjrw.fsf%40osv.gnss.ru
In-Reply-To: <xmqq4mvfg24e.fsf@gitster.dls.corp.google.com>

```
Junio C Hamano <gitster@pobox.com> writes:

> Sergey Organov <sorganov@gmail.com> writes:
>
>> SYNOPSIS section of the git-merge manual page had outdated explicit
>> list of options.
>>
>> "usage" returned by 'git merge -h' didn't have "-m <msg>" that is one
>> of essential distinctions between obsolete invocation form and the
>> recent one.
>>
>> Signed-off-by: Sergey Organov <sorganov@gmail.com>
>> ---
>
> Please do not do two unrelated things in a single change.

Well, I thought they are related, sorry.

> It may be a clear and very welcome improvement to change from
> "explicitly list only often used options" to "just say [options] and
> have the list of options and their descriptions".

OK, noticed.

> I am not sure about the other change to single out "-m <msg>",
> especially marking it as optional by enclosing it inside "[-m
> <msg>]", makes much sense, as that is still not very easily
> distinguishable from "git merge [options] [<commit>...]".

I was looking at the merge.c code, and that's how it seems to work. You
can get new semantics without -m, and you can't get old semantics with
-m, isn't it? It looks like the set of descriptions I produced is
formally correct.

> In other words, I agree with your motivation to call for attention
> that the command behaves differently with and without "-m", but I do
> not think that part of the change in this patch achieves it well.

Any particular suggestion?

Thanks.

-- 
Sergey.

```

## Junio C Hamano, 2014-10-07 21:31

Subject: Re: [PATCH] git-merge: mutually match SYNOPSIS and "usage".
Message-ID: <xmqq1tqjefd8.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq1tqjefd8.fsf%40gitster.dls.corp.google.com
In-Reply-To: <87bnpnsjrw.fsf@osv.gnss.ru>

```
Sergey Organov <sorganov@gmail.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
> ...
> I was looking at the merge.c code, and that's how it seems to work. You
> can get new semantics without -m, and you can't get old semantics with
> -m, isn't it? It looks like the set of descriptions I produced is
> formally correct.

The thing is, with "-m <msg>" we will never fall into the
traditional syntax, hence "git merge -m <msg> <msg> HEAD <commit>"
appear to be allowed with "git merge [options] <msg> HEAD
<commit>...", but it is not.

And the inverse is not true (an obvious example is "git merge
$branch", even though it does not have "-m <msg>" it uses the modern
& common.

So the updated SYNOPSIS is not really helping.

>> In other words, I agree with your motivation to call for attention
>> that the command behaves differently with and without "-m", but I do
>> not think that part of the change in this patch achieves it well.
>
> Any particular suggestion?

I was going to suggest "explain how the traditional syntax is
triggered in the DESCRIPTION section", but it turns out that we
already do that.

      The second syntax (<msg> HEAD <commit>...) is supported for
      historical reasons. Do not use it from the command line or in
      new scripts. It is the same as git merge -m <msg> <commit>....

Strictly speaking, I think it is not qute "the same"---I recall
vaguely that it broke tests if you replace the traditional-style
invocation in 'git pull' with the -m <msg> syntax, but I do not have
details handy; you may want to try it out if you are interested.

So I would think

	SYNOPSIS
        	git merge [options] <commit>...
		git merge [options] <msg> HEAD <commit>...
                git merge --abort

should be sufficient, possibly with some clarification on "The
second syntax" paragraph in the DESCRIPTION section.

```

## Sergey Organov, 2014-10-08 10:12

Subject: Re: [PATCH] git-merge: mutually match SYNOPSIS and "usage".
Message-ID: <87h9zeg9an.fsf@osv.gnss.ru>
URL: https://gitlist.dev/e/87h9zeg9an.fsf%40osv.gnss.ru
In-Reply-To: <xmqq1tqjefd8.fsf@gitster.dls.corp.google.com>

```
Junio C Hamano <gitster@pobox.com> writes:

> Sergey Organov <sorganov@gmail.com> writes:
>
>> Junio C Hamano <gitster@pobox.com> writes:
>> ...
>> I was looking at the merge.c code, and that's how it seems to work. You
>> can get new semantics without -m, and you can't get old semantics with
>> -m, isn't it? It looks like the set of descriptions I produced is
>> formally correct.
>
> The thing is, with "-m <msg>" we will never fall into the
> traditional syntax, hence "git merge -m <msg> <msg> HEAD <commit>"
> appear to be allowed with "git merge [options] <msg> HEAD
> <commit>...", but it is not.

No. When you see:

  git merge [options] [-m <msg>] <commit>...

Isn't it obvious that 'options' don't include "-m <msg>", so
  
  git merge [options] <msg> HEAD <commit>...

form will never apply when you have "-m <msg>" in the command, exaclty
because 'options' don't include "-m <msg"?

>
> And the inverse is not true (an obvious example is "git merge
> $branch", even though it does not have "-m <msg>" it uses the modern
> & common.

Sure, and this is covered as well.

> So the updated SYNOPSIS is not really helping.

I disagree, see above.

I still think that for somewhat messy historical situation, the
suggested syntax description is good enough.

-- 
Sergey.

```
