threads / patch / 37680

patchgit-merge: mutually match SYNOPSIS and "usage".

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

## tl;dr

5 messages between Oct 7, 2014 and Oct 8, 2014. Diffs are folded; open one to read it.

replies: 4people: 2as markdown or json

Sergey Organov· Oct 7, 2014, 11:54 UTC · lore

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(-)
Show changes to 2 files +3 −5

Documentation/git-merge.txt, builtin/merge.c

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· Oct 7, 2014, 18:34 UTC · re: Sergey Organov · lore

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

Sergey Organov <sorganov@gmail.com> writes:
Show 9 quoted lines
> 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.

Show 34 quoted lines
>  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· Oct 7, 2014, 20:32 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> 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· Oct 7, 2014, 21:31 UTC · re: Sergey Organov · lore

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

Sergey Organov <sorganov@gmail.com> writes:
Show 6 quoted lines
> 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.
Show 5 quoted lines
>> 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· Oct 8, 2014, 10:12 UTC · re: Junio C Hamano · lore

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

Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> 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.

← back to recent threads