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

Re: [PATCH] Cogito: Support for implicit remote branches in cloned repositories

From
JWJosef Weidendorfer <josef.weidendorfer@gmx.de>
Date
Nov 8, 2005, 16:46 UTC
Message-ID
<200511081746.20348.Josef.Weidendorfer@gmx.de>
In-Reply-To
<20051107232122.GZ1431@pasky.or.cz>
On Tuesday 08 November 2005 00:21, Petr Baudis wrote:
> The problem is that at least Cogito defaults to the 'origin' branch when
> pulling/merging, so if you'll have 'origin/master' instead of 'origin',
> I will have to hack that around. So it's not _just_ a convention but
> something reflected in some code as well.

The new git-clone simply would not produce an "origin" branch at all, and I do not think Cogito expects that a repository always has an "origin" branch.

The following fact (Git's default clone setup until now, Cogito's clone setup)
	"origin" tracks remote "master", to be merged into local "master"

has to be stored into some configuration file, and not to be set up implicitly as it is done currently. Then you take this setup from the configuration, and there never would be something hardcoded, and Junios suggestion would be a convention.

Git already stores half of this into remotes/repo: the "Pull" lines specify which local head tracks which remote head; the same with Cogito's .git/branches. Missing in both cases is the information that "origin" maps to the local development head "master". More common name for this information: "origin" is the upstream for "master".

This information is useful at least for two cases: (1) for specifying the default action to be done on "git-pull" or "cg-update", and (2) try to prohibit accidental bogus merges.

The default action currently is either hardcoded (Cogito) or working somehow by luck (Git: you have to be on "master" for git-pull). AFAIK, Cogito prohibits bogus merges by enforcing to be either on "master" or to be in a not-mergeable state (cg-seeking).

Merge relationship is useful to be specified not only for upstream direction, but also for branches which branched off the current head and should be merged back (e.g. topical branches). For this, multiple branches to be merged with "git pull" should be specifyable.

Where to put the information about default merge relation?

Both .git/remotes and .git/branches are candidates, but merge relation also makes sense for local branches, i.e. git-branch <branch> <origbranch> should set up to merge from <origbranch> if you are on <branch> by default. Similarly, it should set up a relation the other way to state that it is useful to merge from <branch> into <origbranch> (this is for (2) above).

A possiblity would be to put the merge relationship into .git/config:

[master] merge-canditate: origin merge-default: origin

Problem here is that head names should not appear in key names, because key names are case insensitive :-( A possibility would be for config keys to become case sensitive after a ":" (of course only for toplevel keys):

[head:master] merge-default: origin

Show 12 quoted lines
> >  - clone by default [*1*] creates .git/refs/heads/origin/*
> >    heads; your "master" becomes my "origin/master".
> >    Interestingly but logically, if your repository was cloned
> >    from somewhere else, you would have "origin/master", which
> >    would become my "origin/origin/master".
> 
> This loses the pretty nice property that 'origin' refers to the HEAD
> branch of the remote repository, no matter how is it called (well, it is
> nice as long as the remote repository doesn't _switch_ the HEAD to some
> non-superset branch; but repositories you're cloning from shouldn't do
> that). So you should either have origin/HEAD locally, or make the
> 'master' branch more "socially canonical".

Ah, so git-clone sets up a local development head for the remote HEAD, which does not always have to be "master", right? This information would be available by the proposed storing of merge relationship: local "master" wants get merges from remote HEAD to be updated.

Josef
Previous: Junio C Hamano
Message 10 of 10 in “Cogito: Support for implicit remote branches in cloned repositories”
  1. Cogito: Support for implicit remote branches in cloned repositoriesJosef Weidendorfer, Nov 4, 2005
  2. Junio C HamanoNov 4, 2005
  3. Josef WeidendorferNov 4, 2005
  4. Petr BaudisNov 4, 2005
  5. Junio C HamanoNov 4, 2005
  6. Linus TorvaldsNov 4, 2005
  7. Junio C HamanoNov 6, 2005
  8. Petr BaudisNov 7, 2005
  9. Junio C HamanoNov 7, 2005
  10. Josef WeidendorferNov 8, 2005

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.