threads / patch / 52045

patchconfig/branch: state that <name>.merge is the remote ref

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

## tl;dr

6 messages between Oct 16, 2019 and Oct 19, 2019. Diffs are folded; open one to read it.

replies: 5people: 2as markdown or json

Philip Oakley· Oct 16, 2019, 11:28 UTC · lore

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(-)
Show changes to Documentation/config/branch.txt +3 −1
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
-- 
2.23.0.windows.1.21.g947f504ebe8.dirty
Junio C Hamano· Oct 18, 2019, 01:32 UTC · re: Philip Oakley · lore

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

Philip Oakley <philipoakley@iee.email> writes:
Show 5 quoted lines
>  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, 20:53 UTC · re: Junio C Hamano · lore

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

Hi Junio,
On 18/10/2019 02:32, Junio C Hamano wrote:
Show 13 quoted lines
> 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/ ?
Show 7 quoted lines
>
> 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
Philip Oakley· Oct 18, 2019, 20:59 UTC · re: Philip Oakley · lore

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

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>
---
 Documentation/config/branch.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Show changes to Documentation/config/branch.txt +4 −2
diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt
index a592d522a7..cdc19edaaf 100644
--- a/Documentation/config/branch.txt
+++ b/Documentation/config/branch.txt
@@ -52,8 +52,10 @@ branch.<name>.pushRemote::
 	option to override it for a specific branch.
 
 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
+	The name of the branch ref at the remote `branch.<name>.remote`
+	that is used as the upstream branch for the given 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
-- 
2.23.0.windows.1.21.g947f504ebe8.dirty
Junio C Hamano· Oct 18, 2019, 23:11 UTC · re: Philip Oakley · lore

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

Philip Oakley <philipoakley@iee.email> writes:
Show 6 quoted lines
> 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".

Show 6 quoted lines
>>      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, 15:19 UTC · re: Junio C Hamano · lore

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

Hi Junio, On 19/10/2019 00:11, Junio C Hamano wrote:

Show 10 quoted lines
> 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 ;-)
Show 14 quoted lines
>>>       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.

← back to recent threads