diff mbox series

[v1] config/branch: state that <name>.merge is the remote ref

Message ID 20191016112822.1701-1-philipoakley@iee.email (mailing list archive)
State New, archived
Headers show
Series [v1] config/branch: state that <name>.merge is the remote ref | expand

Commit Message

Philip Oakley Oct. 16, 2019, 11:28 a.m. UTC
The branch.<name>.merge value typically looks just like a
local ref. Tell the reader it is the ref name at the remote,
which may be different.

Signed-off-by: Philip Oakley <philipoakley@iee.email>
---

This confusion had me scratching my head for many minutes recently.
A simple clarification would avoid such mental model errors.

 Documentation/config/branch.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Junio C Hamano Oct. 18, 2019, 1:32 a.m. UTC | #1
Philip Oakley <philipoakley@iee.email> writes:

>  branch.<name>.merge::
>  	Defines, together with branch.<name>.remote, the upstream branch
> -	for the given branch. It tells 'git fetch'/'git pull'/'git rebase' which
> +	for the given branch. It defines the branch name _on the remote_,
> +	which may be different from the local branch name.

While I do agree with the goal of make things more clear, I'd avoid
being overly redundant and giving irrelevant information (e.g. the
copy you have locally may be made under arbitrary name that is
different from the name used at the remote).  After all, the users
do not even need to know about the remote-tracking branch to
understand this naming mechanism.

Perhaps something along this line instead:

    The name of the branch at the remote `branch.<name>.remote` that
    is used as the upstream branch for the given branch.  It tells
    `git fetch`, etc., which branch to merge and ...
Philip Oakley Oct. 18, 2019, 8:53 p.m. UTC | #2
Hi Junio,

On 18/10/2019 02:32, Junio C Hamano wrote:
> Philip Oakley <philipoakley@iee.email> writes:
>
>>   branch.<name>.merge::
>>   	Defines, together with branch.<name>.remote, the upstream branch
>> -	for the given branch. It tells 'git fetch'/'git pull'/'git rebase' which
>> +	for the given branch. It defines the branch name _on the remote_,
>> +	which may be different from the local branch name.
> While I do agree with the goal of make things more clear, I'd avoid
> being overly redundant and giving irrelevant information (e.g. the
> copy you have locally may be made under arbitrary name that is
> different from the name used at the remote).  After all, the users
> do not even need to know about the remote-tracking branch to
> understand this naming mechanism.
I'd argue that the user has to know about the branch <name> to even get 
here,
and that the key value can be confusing (been there!), so improving the 
understanding
was the aim.

That said, tedious repetition should be avoided, so I'll look to reword 
it while still retaining the emphasis. Perhaps:

branch.<name>.merge::
     Defines, for the local branch <name>, the upstream branch ref
     _on the remote_ (as given by branch.<name>.remote).
     The upstream ref may be different from the local branch ref.

optionally s/different from/ same as/ ?

>
> Perhaps something along this line instead:
>
>      The name of the branch at the remote `branch.<name>.remote` that
>      is used as the upstream branch for the given branch.  It tells
>      `git fetch`, etc., which branch to merge and ...
>
If this, should we also say it (the key value) is that of the upstream 
branch _ref_?

Hmm, *thinks*, I think I'm being swayed by your version. Update to follow.

Philip
Junio C Hamano Oct. 18, 2019, 11:11 p.m. UTC | #3
Philip Oakley <philipoakley@iee.email> writes:

> branch.<name>.merge::
>     Defines, for the local branch <name>, the upstream branch ref
>     _on the remote_ (as given by branch.<name>.remote).
>     The upstream ref may be different from the local branch ref.
>
> optionally s/different from/ same as/ ?

That "optionally" part is exactly why I said "upstream and remote
tracking names may or may not differ is irrelevant information".

>>      The name of the branch at the remote `branch.<name>.remote` that
>>      is used as the upstream branch for the given branch.  It tells
>>      `git fetch`, etc., which branch to merge and ...
>>
> If this, should we also say it (the key value) is that of the upstream
> branch _ref_?

Yeah, that makes it clear that readers should not write "master" and
use "refs/heads/master" instead.  It may even be more (technically)
correct to say just "ref" without branch (this ref does not have to
be a branch at the remote repository at all).  I am not sure if we
want to go that far to make it more correct and also make it hint
that using a non-branch ref is a valid configuration to readers, but
I agree it is a good idea to avoid saying "name" (which implies
that "master" is OK, which is not).

Thanks.
Philip Oakley Oct. 19, 2019, 3:19 p.m. UTC | #4
Hi Junio,
On 19/10/2019 00:11, Junio C Hamano wrote:
> Philip Oakley <philipoakley@iee.email> writes:
>
>> branch.<name>.merge::
>>      Defines, for the local branch <name>, the upstream branch ref
>>      _on the remote_ (as given by branch.<name>.remote).
>>      The upstream ref may be different from the local branch ref.
>>
>> optionally s/different from/ same as/ ?
> That "optionally" part is exactly why I said "upstream and remote
> tracking names may or may not differ is irrelevant information".
I think we misunderstand each other again. That very potential 
difference, no matter which way described, was the point at hand - that 
is we are talking about refs at different places.

If we have (quite typically) that merge config indicating that we wish 
to merge refs/heads/master with refs/heads/master then it looks like a 
no-op. They are both the same ref (by name / character sequence). 
Without the extra knowledge that one is local and the other is remote 
then the mental model confusion in the reader continues. The 
'optionally' offer was about choosing the best way of coercing the 
reader into considering the alternate viewpoint. Sometime things  need 
to explained both ways, so that at least one will register.

It could be argued that the merge ref should have been 
`refs/remotes/origin/master` (for that typical following case), but it 
isn't (IIUC because of historic backward compatibility), which would 
have at least avoided the local  v remote conundrum.

All that said, I ended up going with your suggested text anyway ;-)
>>>       The name of the branch at the remote `branch.<name>.remote` that
>>>       is used as the upstream branch for the given branch.  It tells
>>>       `git fetch`, etc., which branch to merge and ...
>>>
>> If this, should we also say it (the key value) is that of the upstream
>> branch _ref_?
> Yeah, that makes it clear that readers should not write "master" and
> use "refs/heads/master" instead.  It may even be more (technically)
> correct to say just "ref" without branch (this ref does not have to
> be a branch at the remote repository at all).  I am not sure if we
> want to go that far to make it more correct and also make it hint
> that using a non-branch ref is a valid configuration to readers, but
> I agree it is a good idea to avoid saying "name" (which implies
> that "master" is OK, which is not).
I'd agree. I'll think about the simplified ref comment.

P.
diff mbox series

Patch

diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt
index a592d522a7..3bfe4f81d3 100644
--- a/Documentation/config/branch.txt
+++ b/Documentation/config/branch.txt
@@ -53,7 +53,9 @@  branch.<name>.pushRemote::
 
 branch.<name>.merge::
 	Defines, together with branch.<name>.remote, the upstream branch
-	for the given branch. It tells 'git fetch'/'git pull'/'git rebase' which
+	for the given branch. It defines the branch name _on the remote_,
+	which may be different from the local branch name.
+	It tells 'git fetch'/'git pull'/'git rebase' which
 	branch to merge and can also affect 'git push' (see push.default).
 	When in branch <name>, it tells 'git fetch' the default
 	refspec to be marked for merging in FETCH_HEAD. The value is