threads / discuss / 43157

Re: Handling of branches in stgit

Subject: Re: Handling of branches in stgit

## tl;dr

4 messages between Nov 30, 2006 and Dec 5, 2006.

replies: 3people: 2as markdown or json

Yann Dirson· Nov 30, 2006, 00:00 UTC · lore

Handling of branches in stgit

I have started to work on recording parent information for stgit branches, so we don't need to give the same info on every "git pull".

I'm facing a problem, in that we have several kind of stgit branches:
* those created against a cogito branch (eg. by "cg clone" and "stg
  init").  They work pretty much intuitively (and it happens I mostly
  used this flavour before those tests).  All we need is the name of
  the local branch, and "stg pull <branch>" relies on "git fetch" to
  find the repository information in .git/branches/<branch>.
  In this case, it is easy to request pulling from any branch, but
  usually only one of them is what you want, and the results of using
  another one (or forgetting to specify the one you want) can be
  annoying [ISSUE 1].  Hence this work of mine: being able to store
  this info in .git/patches/<stack>/parent (my initial implementation)
  was sufficient in theory.
  But "stg pull" allows for a refspec argument.  Since the branch
  mapping is already defined in a file, and I canno think of any
  useful way to override it, maybe we could make sure noone uses it in
  such a case ?
  
* but those created against a local branch are typically different,
  and updated by "stg pull . <branch>".  In that case, we have to
  specify the repository (".") explicitely, in addition to the branch,
  and the way to use the use them is different.
* and it gets better with those branches created against a git remote
  branch (eg. by "stg clone" or "stg branch -c" against an existing
  remote branch), typically updated via "stg pull <remote>", where the
  repo information is extracted by "git fetch" from
  .git/remotes/<remote>.  That is, we do not specify a branch or a
  repository URL, but an alias that may cover several branches from
  another repo.
  Here the branch information from the remotes file appears not to be
  used at all (in fact all branches are fetched - not sure that it's
  always what we want, but I'll wait to find myself limited by this
  behaviour before complaining ;)
  Also, "stgit pull <remote>" using "git pull" by default, it is the
  1st branch listed in the remotes file that gets taken as parent
  [ISSUE 2].  We should probably instead run "git fetch <remote>" and
  then then "git pull . <branch>", but that surely requires some
  changes to the "stg pull" internals.
  Thus (modulo that issue), we need 2 infos: "remote" and branch.
  Storing the latter should help to solve issue 2.
  Note: whereas "stg pull origin", while pulling a "foo" branch, cannot
  know current "foo2" branch should be rebased to "foo", (after renaming
  remotes/origin to foo) "stg pull foo", not only fetches "origin" as
  expected, but also (seemingly correctly but hell how does it know
  [ISSUE 3]) rebases current "master" to "origin" - is "master"
  special in any way here ?  I did not find anything about this in the
  source, although I found a handful of occurences of "master" in
  commands/branch.py, which seem to imply "master" is so special it
  cannot be deleted, which would look like abuse to me [ISSUE 4].
Now what do we do next ?

We could implement an ad-hoc solution acknowledging there are 3 different ways to work with a branch, keeping the current "stg pull" syntaxes (they are already a pain for users IMHO) and storing paremeters as ad-hoc values, or we could try to rework the "stg pull" command line.

Some of my ideas for the latter include:
- store a "parent branch" with the name of the parent branch in the
local repository
- store a "parent repository" (ie. "." for local branches, "AUTO" for
cogito branches, and <remote> for git branches)
- rejecting non-default arguments and adding new options to allow to
specify/store alternative values
- we'll need to make sure there are no remote branches of one type
shadowed by one of the other type with same name, and do some sanity
checks that specified branch in a given remote really exists.
How does that sound ?
Catalin Marinas· Dec 1, 2006, 12:42 UTC · re: Yann Dirson · lore
On 30/11/06, Yann Dirson <ydirson@altern.org> wrote:
> I have started to work on recording parent information for stgit
> branches, so we don't need to give the same info on every "git pull".

Isn't this what the branch.<name>.remote configuration option is for? I think we should leave GIT handle this and StGIT only invoke "git pull" without any arguments.

Show 7 quoted lines
> I'm facing a problem, in that we have several kind of stgit branches:
>
> * those created against a cogito branch (eg. by "cg clone" and "stg
>   init").  They work pretty much intuitively (and it happens I mostly
>   used this flavour before those tests).  All we need is the name of
>   the local branch, and "stg pull <branch>" relies on "git fetch" to
>   find the repository information in .git/branches/<branch>.
But I think .git/branches got deprecated or it is a cogito-only feature.
Show 6 quoted lines
>   In this case, it is easy to request pulling from any branch, but
>   usually only one of them is what you want, and the results of using
>   another one (or forgetting to specify the one you want) can be
>   annoying [ISSUE 1].  Hence this work of mine: being able to store
>   this info in .git/patches/<stack>/parent (my initial implementation)
>   was sufficient in theory.

I would leave this to GIT and its configuration files. Do you see any problems with this approach?

I plan to merge the stgit config with the git one (and have a [stgit] section) so that it is more maintainable.

Yann Dirson· Dec 1, 2006, 22:19 UTC · re: Catalin Marinas · lore
On Fri, Dec 01, 2006 at 12:42:19PM +0000, Catalin Marinas wrote:
Show 7 quoted lines
> On 30/11/06, Yann Dirson <ydirson@altern.org> wrote:
> >I have started to work on recording parent information for stgit
> >branches, so we don't need to give the same info on every "git pull".
> 
> Isn't this what the branch.<name>.remote configuration option is for?
> I think we should leave GIT handle this and StGIT only invoke "git
> pull" without any arguments.

This is one part of the problem (and I admit I have missed this config option), the other one being having stgit pull the correct branch, unstead of (implicitely) having git-pull using the 1st one in the remotes file.

Show 9 quoted lines
> >I'm facing a problem, in that we have several kind of stgit branches:
> >
> >* those created against a cogito branch (eg. by "cg clone" and "stg
> >  init").  They work pretty much intuitively (and it happens I mostly
> >  used this flavour before those tests).  All we need is the name of
> >  the local branch, and "stg pull <branch>" relies on "git fetch" to
> >  find the repository information in .git/branches/<branch>.
> 
> But I think .git/branches got deprecated or it is a cogito-only feature.

.git/branches still seems to be the only type of branch created by cogito. And in fact, when remotes started to appear, I wondered how the cogito branch management (a quite intuitive and classical one) would be made to work well with remotes-defining-several-branches, as well as branches-potentially-defined-in-several-remotes (possible repo inconsistency AFAICT, or maybe to specify different protocols to a single repo ?) - and indeed I still don't have an answer, I guess cogito would have to possibly change its user interface if it were to be able to use multi-branch remotes.

In the meantime, we should support them in cogito. And indeed, I found stgit to work perfectly with those.

Show 9 quoted lines
> >  In this case, it is easy to request pulling from any branch, but
> >  usually only one of them is what you want, and the results of using
> >  another one (or forgetting to specify the one you want) can be
> >  annoying [ISSUE 1].  Hence this work of mine: being able to store
> >  this info in .git/patches/<stack>/parent (my initial implementation)
> >  was sufficient in theory.
> 
> I would leave this to GIT and its configuration files. Do you see any
> problems with this approach?

I'd rather consider it a stgit issue: git itself does no have to know which of the various heads descending from our stack base is to be "prefered" by our stack. Where to store it is anothe issue (see below).

> I plan to merge the stgit config with the git one (and have a [stgit]
> section) so that it is more maintainable.

Sure, let's take advantage of git-repo-config ! My latest 1/3 patch could then be seen as a 1st step towards an abstraction of stgit object configuration, which could ease the transition from file storage to config items :)

Best regards,
-- 
Yann.
Yann Dirson· Dec 5, 2006, 22:51 UTC · re: Yann Dirson · lore
On Fri, Dec 01, 2006 at 11:19:41PM +0100, Yann Dirson wrote:
Show 18 quoted lines
> > >  annoying [ISSUE 1].  Hence this work of mine: being able to store
> > >  this info in .git/patches/<stack>/parent (my initial implementation)
> > >  was sufficient in theory.
> > 
> > I would leave this to GIT and its configuration files. Do you see any
> > problems with this approach?
> 
> I'd rather consider it a stgit issue: git itself does no have to know
> which of the various heads descending from our stack base is to be
> "prefered" by our stack.  Where to store it is anothe issue (see below).
> 
> 
> > I plan to merge the stgit config with the git one (and have a [stgit]
> > section) so that it is more maintainable.
> 
> Sure, let's take advantage of git-repo-config !
> My latest 1/3 patch could then be seen as a 1st step towards an
> abstraction of stgit object configuration, which could ease the transition

Indeed most of the current attributes of a stack (except maybe for the description, which can hardly be seen as a config option) are quite volatile, and thus unsuited for repo-config. OTOH, as you said parent information would find easily its place there.

Show 11 quoted lines
> > On 30/11/06, Yann Dirson <ydirson@altern.org> wrote:
> > >I have started to work on recording parent information for stgit
> > >branches, so we don't need to give the same info on every "git pull".
> >
> > Isn't this what the branch.<name>.remote configuration option is for?
> > I think we should leave GIT handle this and StGIT only invoke "git
> > pull" without any arguments.
> 
> This is one part of the problem (and I admit I have missed this config option),
> the other one being having stgit pull the correct branch, unstead of
> (implicitely) having git-pull using the 1st one in the remotes file.

I would also think that what really belongs to that config item would be the declaration of which remote our parent branch should use to be updated (ie. no need to duplicate the info in all the stgit stacks forked off the same parent).

However it looks like this config option is not currently used unless the branch to be git-fetched is the curent one, which is quite annoying - we would need to get that setting ourselves to pass it to git-fetch.

What's not clear to me is how to deal with cogito branches (maybe check for the existence of .git/branches/<name> and then "git fetch <name>" ?), and with local branches (how are we supposed to derive that a branch is not a remote one ? Should GIT add a branch.<name>.remote or "." for locally-created branches ?).

We would also still need a config item to tell which parent branch we should use, in order to know which branch.<name>.remote to extract, and which branch to fast-forward our base onto.

Best regards,

← back to recent threads