git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git pull and merging.

From
JWJosef Weidendorfer <josef.weidendorfer@gmx.de>
Date
Dec 7, 2006, 11:27 UTC
Message-ID
<200612071227.46194.Josef.Weidendorfer@gmx.de>
In-Reply-To
<4577B8C0.3060200@gmail.com>
On Thursday 07 December 2006 07:46, Aneesh Kumar K.V wrote:
> Josef Weidendorfer wrote:
Show 8 quoted lines
> > Now, instead of "git pull", git should default to
> > 
> > 	git pull origin refs/heads/devel:refs/remotes/origin/devel
> 
> 
> 
> this means the remote reference is refs/heads/devel and local tracking
> branch for that is refs/remotes/origin/devel. 
Yes.
Show 8 quoted lines
> > ie. it should update the local tracking branch "refs/remotes/origin/devel"
> > with the remote branch "refs/heads/devel".
> > The tracking branch "refs/remotes/origin/devel" will be merged with current
> > branch afterwards.
> > 
> 
> 
> That will be merged is the tricky part.

No. The merging part actually is the easiest, because everything about what to merge with what is already decided in "git pull" 's fetch phase:

* git fetch leaves the branches fetched _and_ what to merge of them
in .git/FETCH_HEAD. Example for "git pull" it git.git's master(shorted):

de51fa... branch 'master' of git://.../git/git 49ed2b... not-for-merge branch 'maint' of git://.../git/git b772ef... not-for-merge branch 'next' of git://.../git/git

Which means: Already in the fetch phase, we look up branch.*.merge to decide what to write into this file.

* the merge phase just looks up .git/FETCH_HEAD and merges all branches into
the current branch which are _not_ marked as "not-for-merge". There
is nothing tricky here: We did the 1st phase of pull in the same
"current" branch, so there really is no need to check any branch.*.merge
value again.
Show 7 quoted lines
> > Now looking at the documentation for branch.<name>.merge, it talks
> > about the remote branch, which is "refs/heads/devel" in your case, ie.
> > the first part of the refspec of the full "git pull" command above.
> > 
> 
> This is most confusing part. What merge indicate is not about refs/heads/devel
> should track refs/remotes/origin/devel. That is specfied in the remote config option.

Yes. But the value of branch.*.merge, which is the _remote_ side of such a refspec tracking specification given in remote.*.fetch's, will be checked against all remote parts of refspecs fetched in the 1st phase of "git pull". And it is already decided in the fetch phase what to merge.

Now looking at it, I think this semantic really is screwed and utterly confusing. Why decides branch.*.merge about actions done in fetch (I think even if you did "git fetch" alone)? OK, actually, that is an implementation detail and not really important.

More important: Because "branch.*.merge" specifies a _remote_ branch, the user has to understand that this info is already used in the fetch. The intuitive mental model of a user about how it works IMHO is that "branch.*.merge" is checked in the merge phase (as the name of the option suggests). But this way, how could the merge phase know about any remote branch at all, which does not need to be touched at all in the merge phase?

IMHO we should somehow change the semantic of branch.*.merge to specify the _local_ refspec part, as this is the branch which actually gets merged. This is the only way that a user could grasp the meaning of it. Perhaps introduce "branch.*.defaultmerge", and obsoleting "branch.*.merge"?

Show 6 quoted lines
> I guess we need to have a standard way of saying the branches. 
> 
> May be we want to document it in repo-config.
> 
> local branch on which changes can be made <branch-name>
> local tracking branch refs/remotes/<remote-name>/<branch-name>
This is not forced, but can be changed by configuration.
> remote branch refs/heads/<branch-name>
?
Previous: Aneesh Kumar K.VNext: Junio C Hamano
Message 12 of 36 in “git pull and merging.”
  1. Aneesh KumarDec 6, 2006
  2. Junio C HamanoDec 6, 2006
  3. Aneesh KumarDec 6, 2006
  4. Johannes SchindelinDec 6, 2006
  5. Peter BaumannDec 6, 2006
  6. Johannes SchindelinDec 6, 2006
  7. Peter BaumannDec 6, 2006
  8. Aneesh KumarDec 6, 2006
  9. Jakub NarebskiDec 6, 2006
  10. Josef WeidendorferDec 6, 2006
  11. Aneesh Kumar K.VDec 7, 2006
  12. Josef WeidendorferDec 7, 2006
  13. Junio C HamanoDec 7, 2006
  14. Josef WeidendorferDec 7, 2006
  15. Santi BéjarDec 8, 2006
  16. Josef WeidendorferDec 8, 2006
  17. Add branch.*.localmerge and documentation updateJosef Weidendorfer, Dec 8, 2006
  18. Santi BéjarDec 8, 2006
  19. Junio C HamanoDec 8, 2006
  20. Jakub NarebskiDec 8, 2006
  21. Josef WeidendorferDec 8, 2006
  22. Junio C HamanoDec 8, 2006
  23. Josef WeidendorferDec 8, 2006
  24. Junio C HamanoDec 8, 2006
  25. Add branch.*.merge warning and documentation updateJosef Weidendorfer, Dec 9, 2006
  26. Santi BéjarDec 9, 2006
  27. Josef WeidendorferDec 8, 2006
  28. Santi BéjarDec 8, 2006
  29. Santi BéjarDec 8, 2006
  30. Junio C HamanoDec 8, 2006
  31. Junio C HamanoDec 7, 2006
  32. Santi BéjarDec 8, 2006
  33. Jakub NarebskiDec 8, 2006
  34. Jakub NarebskiDec 6, 2006
  35. Johannes SchindelinDec 6, 2006
  36. Fwd: git pull and merging.Aneesh Kumar, Dec 6, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.