threads / discuss / 7652

GIT and the current -stable

Subject: GIT and the current -stable

## tl;dr

16 messages between Apr 14, 2007 and Apr 15, 2007.

replies: 15people: 9as markdown or json

Rene Herman· Apr 14, 2007, 05:36 UTC · lore
Good day.
Stumbling around with git here. I'd like to use git to efficiently track the 
  current -stable as well as -current. Say, my local tree is a clone of 
Linus current:

git clone \ git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git local

I then branch off a 2.6.20 branch:

cd local git checkout -b v2.6.20 v2.6.20

to now update to the current -stable I could do:

git pull \ git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.20.y.git

each time that a new -stable is released. Rather though, I'd like a simple "git pull" to do this while on this branch while a "git pull" while back on the master branch pulls from the originally cloned Linus repo again.

Is this possible? Do I want it to be? Comments like "work like this instead" welcome as well; figuring out what the heck it is that I want from git seems to be one of the most difficult questions to answer...

Currently using git 1.5.0.4.
Rene.
Junio C Hamano· Apr 14, 2007, 06:24 UTC · re: Rene Herman · lore

Re: GIT and the current -stable

Rene Herman <rene.herman@gmail.com> writes:
Show 17 quoted lines
> Stumbling around with git here. I'd like to use git to efficiently
> track the current -stable as well as -current. Say, my local tree is a
> clone of Linus current:
>
> git clone \
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
> local
>
> I then branch off a 2.6.20 branch:
>
> cd local
> git checkout -b v2.6.20 v2.6.20
>
> to now update to the current -stable I could do:
>
> git pull \
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.20.y.git

I think adding these lines to .git/config would do the trick, after you have done the "checkout -b v2.6.20 v2.6.20" step:

[branch "v2.6.20"]
	remote = stable
	merge = refs/heads/master
[remote "stable"]
	url = git://git.kernel.org/.../stable/linux-2.6.20.y.git
	fetch = refs/heads/master

provided if stable team forks v2.6.20.y history off of Linus's v2.6.20.

With the above configuration, anytime you say "git pull" while on your v2.6.20 branch will fetch from "stable" and merge their 'master' branch in your current branch (i.e. v2.6.20 branch).

Rene Herman· Apr 14, 2007, 07:13 UTC · re: Junio C Hamano · lore

Re: GIT and the current -stable

On 04/14/2007 08:24 AM, Junio C Hamano wrote:
Show 16 quoted lines
> I think adding these lines to .git/config would do the trick,
> after you have done the "checkout -b v2.6.20 v2.6.20" step:
> 
> [branch "v2.6.20"]
> 	remote = stable
> 	merge = refs/heads/master
> [remote "stable"]
> 	url = git://git.kernel.org/.../stable/linux-2.6.20.y.git
> 	fetch = refs/heads/master
> 
> provided if stable team forks v2.6.20.y history off of Linus's
> v2.6.20.
> 
> With the above configuration, anytime you say "git pull" while
> on your v2.6.20 branch will fetch from "stable" and merge their
> 'master' branch in your current branch (i.e. v2.6.20 branch).

Yes, this does seem to work, thanks. Was thrown of a bit by having named the branch "v2.6.20". GIT and I disagree what it is that I want to happen when I say "git checkout v2.6.20" if v2.6.20 is also a tag on master.

The pull behaviour does not follow further branches:
rene@7ixe4:~/src/linux/local$ git branch
* 2.6.20
   master
rene@7ixe4:~/src/linux/local$ git checkout -b 7ixe4
Switched to a new branch "7ixe4"
rene@7ixe4:~/src/linux/local$ git pull
Warning: No merge candidate found because value of config option
          "branch.7ixe4.merge" does not match any remote branch fetched.
No changes.

This might in practice not be all bad in fact, and I suppose I understand how to "fix" it along the same lines as above.

But as happens very frequently with GIT, I get the feeling that I just don't understand how it's all intended to be used. It seems that what I wanted above is not standard? What would be expected use of the stable GIT repo? Just cloning that outright into another repo?

A "GIT WHYTO" from someone with the oversight would be very useful...
Rene.
Greg KH· Apr 14, 2007, 07:21 UTC · re: Junio C Hamano · lore

Re: GIT and the current -stable

On Fri, Apr 13, 2007 at 11:24:19PM -0700, Junio C Hamano wrote:
Show 32 quoted lines
> Rene Herman <rene.herman@gmail.com> writes:
> 
> > Stumbling around with git here. I'd like to use git to efficiently
> > track the current -stable as well as -current. Say, my local tree is a
> > clone of Linus current:
> >
> > git clone \
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
> > local
> >
> > I then branch off a 2.6.20 branch:
> >
> > cd local
> > git checkout -b v2.6.20 v2.6.20
> >
> > to now update to the current -stable I could do:
> >
> > git pull \
> > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.20.y.git
> 
> I think adding these lines to .git/config would do the trick,
> after you have done the "checkout -b v2.6.20 v2.6.20" step:
> 
> [branch "v2.6.20"]
> 	remote = stable
> 	merge = refs/heads/master
> [remote "stable"]
> 	url = git://git.kernel.org/.../stable/linux-2.6.20.y.git
> 	fetch = refs/heads/master
> 
> provided if stable team forks v2.6.20.y history off of Linus's
> v2.6.20.

Yes, we do branch off Linus's tree for each of the different .y releases.

Some people have asked us to keep all of the different .y branches in the same git tree, but for now we have been using different repositories on kernel.org to keep things simpler for the majority of people who do not fully understand how to use the branching features of git (myself included in that category at times, I've messed up merging to different branches too many times...)

> With the above configuration, anytime you say "git pull" while
> on your v2.6.20 branch will fetch from "stable" and merge their
> 'master' branch in your current branch (i.e. v2.6.20 branch).
That's really cool, thanks for pointing out how to do it.
thanks,
greg k-h
Linus Torvalds· Apr 14, 2007, 17:34 UTC · re: Junio C Hamano · lore

Re: GIT and the current -stable

On Fri, 13 Apr 2007, Junio C Hamano wrote:
Show 7 quoted lines
> 
> I think adding these lines to .git/config would do the trick,
> after you have done the "checkout -b v2.6.20 v2.6.20" step:
> 
> [branch "v2.6.20"]
> 	remote = stable
> 	merge = refs/heads/master

Please don't do this. Using the same name for a branch as for a tag is madness. Call it "v2.6.20-stable" or anything else, but don't re-use the same naming as for tags.

Sure, git will have some random well-defined order of parsing which one "v2.6.20" actually means in any particular context (usually the tag-name will take precedence, except for contexts where the branchname is required!), and yeah, you can always make things unambiguous by specifying the full name (ie say "[refs/]tags/v2.6.20" when you want to make sure it's unambiguously the tag, not the branch) but it's still guaranteed to cause confusion at *some* level, if only for the user.

So just don't do it. 
		Linus
Gerb Stralko· Apr 14, 2007, 18:45 UTC · re: Linus Torvalds · lore

Re: GIT and the current -stable

> Please don't do this. Using the same name for a branch as for a tag is
> madness. Call it "v2.6.20-stable" or anything else, but don't re-use the
> same naming as for tags.
>

Yes I have done this before, and it took me awhile to realize what was going on. It caused me some grief, and a few hours of lost time...Of course this was back in my earlier days ;)

Chris Wright· Apr 14, 2007, 08:34 UTC · re: Rene Herman · lore

Re: GIT and the current -stable

* Rene Herman (rene.herman@gmail.com) wrote:
Show 16 quoted lines
> Stumbling around with git here. I'd like to use git to efficiently track 
> the current -stable as well as -current. Say, my local tree is a clone of 
> Linus current:
> 
> git clone \ 
> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git local
> 
> I then branch off a 2.6.20 branch:
> 
> cd local
> git checkout -b v2.6.20 v2.6.20
> 
> to now update to the current -stable I could do:
> 
> git pull \ 
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.20.y.git

I've already put a tree like this up on kernel.org. The master branch is Linus' tree, and there's branches for each of the stable releases called linux-2.6.[12-20].y (I didn't add 2.6.11.y).

http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6-stable.git;a=summary
> each time that a new -stable is released. Rather though, I'd like a simple 
> "git pull" to do this while on this branch while a "git pull" while back on 
> the master branch pulls from the originally cloned Linus repo again.

You have to be careful with pull. It will always want to merge onto your current branch.

thanks, -chris

Rene Herman· Apr 14, 2007, 08:54 UTC · re: Chris Wright · lore

Re: GIT and the current -stable

On 04/14/2007 10:34 AM, Chris Wright wrote:
Show 5 quoted lines
> I've already put a tree like this up on kernel.org.  The master branch
> is Linus' tree, and there's branches for each of the stable releases
> called linux-2.6.[12-20].y (I didn't add 2.6.11.y).
> 
> http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6-stable.git;a=summary
I see, thank you; that sounds like a good "master" repo to clone then.
Rene.
Rene Herman· Apr 14, 2007, 23:13 UTC · re: Rene Herman · lore

Re: GIT and the current -stable

On 04/14/2007 10:54 AM, Rene Herman wrote:
Show 9 quoted lines
> On 04/14/2007 10:34 AM, Chris Wright wrote:
> 
>> I've already put a tree like this up on kernel.org.  The master branch
>> is Linus' tree, and there's branches for each of the stable releases
>> called linux-2.6.[12-20].y (I didn't add 2.6.11.y).
>>
>> http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6-stable.git;a=summary 
> 
> I see, thank you; that sounds like a good "master" repo to clone then.
Okay, I just cloned this repo, like:

git clone -n \ git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6-stable.git \ stable

How do I now checkout for example 2.6.20.6, or get a diff between 2.6.20.6 and the (at the moment of writing latest -stable) 2.6.20.7?

rene@7ixe4:~/src/linux$ cd stable
rene@7ixe4:~/src/linux/stable$ git branch -a
* master
   origin/HEAD
   origin/linux-2.6
   origin/linux-2.6.12.y
   origin/linux-2.6.13.y
   origin/linux-2.6.14.y
   origin/linux-2.6.15.y
   origin/linux-2.6.16.y
   origin/linux-2.6.17.y
   origin/linux-2.6.18.y
   origin/linux-2.6.19.y
   origin/linux-2.6.20.y
   origin/master
and I can check them out like
rene@7ixe4:~/src/linux/stable$ git checkout origin/linux-2.6.20.y
or in this case, but only this case, like:
rene@7ixe4:~/src/linux/stable$ git checkout v2.6.20.7
"v2.6.20.7" seems to be the only tag from the stable branches that's present 
  in this tree?

rene@7ixe4:[...]$ git tag -l | grep "v2\.6\.[[:digit:]]\{1,2\}\." v2.6.20.7

Rene.
Julian Phillips· Apr 15, 2007, 00:23 UTC · re: Rene Herman · lore

Re: GIT and the current -stable

On Sun, 15 Apr 2007, Rene Herman wrote:
Show 6 quoted lines
>
> "v2.6.20.7" seems to be the only tag from the stable branches that's present
>  in this tree?
>
> rene@7ixe4:[...]$ git tag -l | grep "v2\.6\.[[:digit:]]\{1,2\}\."
> v2.6.20.7

Obviously I don't know how Chris created his conglomerated repo, but I just made one of my own, and it has all the tags I would expect in it ... so it's not an inherent git problem (or not in 1.5.1.1 anyway).

I guess that Chris created his in such a way that the automated tag following code didn't trigger? (Or maybe used a really old git?)

(Mine's at http://git.q42.co.uk/w/stable.git if anyone is interested enough to want to look at it ...)

It only took me 4 commands to create too (ok, so three of them were bash for loops ... and I did do a little bit more to tidy up), I do enjoy using flexible tools :D.

-- 
Julian

  ---
Go slowly to the entertainments of thy friends, but quickly to their
misfortunes.
 		-- Chilo
Brian Gernhardt· Apr 14, 2007, 15:15 UTC · re: Chris Wright · lore

Re: GIT and the current -stable

On Apr 14, 2007, at 4:34 AM, Chris Wright wrote:
Show 6 quoted lines
> I've already put a tree like this up on kernel.org.  The master branch
> is Linus' tree, and there's branches for each of the stable releases
> called linux-2.6.[12-20].y (I didn't add 2.6.11.y).
>
> http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6- 
> stable.git;a=summary

Is HEAD for that repo the most recent stable branch, or (as gitweb makes it look) Linus's head. I'd expect a "-stable" repo to point at the most recent stable commit, not the most recent development commit. And I'd also expect gitweb's summary page to show the shortlog for HEAd. One of my assumptions are being broken and I don't like it. It leaves me all confused...

(I'd just clone your repo and look for myself, but I'm still pulling Linus's tree for the first time and I don't have a fast connection.)

~~ Brian
Chris Wright· Apr 14, 2007, 17:19 UTC · re: Brian Gernhardt · lore

Re: GIT and the current -stable

* Brian Gernhardt (benji@silverinsanity.com) wrote:
Show 13 quoted lines
> On Apr 14, 2007, at 4:34 AM, Chris Wright wrote:
> >I've already put a tree like this up on kernel.org.  The master branch
> >is Linus' tree, and there's branches for each of the stable releases
> >called linux-2.6.[12-20].y (I didn't add 2.6.11.y).
> >
> >http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6-stable.git;a=summary
> 
> Is HEAD for that repo the most recent stable branch, or (as gitweb  
> makes it look) Linus's head.  I'd expect a "-stable" repo to point at  
> the most recent stable commit, not the most recent development  
> commit.  And I'd also expect gitweb's summary page to show the  
> shortlog for HEAd.  One of my assumptions are being broken and I  
> don't like it.  It leaves me all confused...

As I mentioned. The master branch (HEAD) is Linus' tree, and each stable tree is on its own branch. You'll find shortlog summarizes the main branch, so yes, gitweb's summary is a bit confusing based on your assumptions. This is a new tree and hasn't been publicized until now. It does make sense to have its head be the newest stable, I'll switch that around.

thanks, -chris

Brian Gernhardt· Apr 14, 2007, 17:23 UTC · re: Chris Wright · lore

Re: GIT and the current -stable

On Apr 14, 2007, at 1:19 PM, Chris Wright wrote:
> As I mentioned.  The master branch (HEAD) is Linus' tree, and each
> stable tree is on its own branch.

Hm. I should drink my coffee, then read the mailing list, not the other way around. If you do update HEAD to be the most recent stable, my thanks. Apologies for the noise.

~~ Brian
Chris Wright· Apr 14, 2007, 17:31 UTC · re: Brian Gernhardt · lore

Re: GIT and the current -stable

* Brian Gernhardt (benji@silverinsanity.com) wrote:
> Hm.  I should drink my coffee, then read the mailing list, not the  
> other way around.  If you do update HEAD to be the most recent  
> stable, my thanks.  Apologies for the noise.
No problem, was a good suggestion (and it's done).

thanks, -chris

Julian Phillips· Apr 14, 2007, 19:07 UTC · re: Chris Wright · lore

Re: GIT and the current -stable

On Sat, 14 Apr 2007, Chris Wright wrote:
Show 21 quoted lines
> * Brian Gernhardt (benji@silverinsanity.com) wrote:
>> On Apr 14, 2007, at 4:34 AM, Chris Wright wrote:
>>> I've already put a tree like this up on kernel.org.  The master branch
>>> is Linus' tree, and there's branches for each of the stable releases
>>> called linux-2.6.[12-20].y (I didn't add 2.6.11.y).
>>>
>>> http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6-stable.git;a=summary
>>
>> Is HEAD for that repo the most recent stable branch, or (as gitweb
>> makes it look) Linus's head.  I'd expect a "-stable" repo to point at
>> the most recent stable commit, not the most recent development
>> commit.  And I'd also expect gitweb's summary page to show the
>> shortlog for HEAd.  One of my assumptions are being broken and I
>> don't like it.  It leaves me all confused...
>
> As I mentioned.  The master branch (HEAD) is Linus' tree, and each
> stable tree is on its own branch.  You'll find shortlog summarizes the
> main branch, so yes, gitweb's summary is a bit confusing based on your
> assumptions.  This is a new tree and hasn't been publicized until now.
> It does make sense to have its head be the newest stable, I'll switch
> that around.

Would it not make more sense to point HEAD at the linux-2.6.20-y branch and either let master be Linus' tree or simply not have a master branch? Otherwise, what happens to master when the latest stable tree becomes linux-2.6.21-y?

-- 
Julian

  ---
Most people want either less corruption or more of a chance to
participate in it.
Uwe Kleine-König· Apr 14, 2007, 11:56 UTC · re: Rene Herman · lore

Re: GIT and the current -stable

Hello Rene,
Rene Herman wrote:
Show 7 quoted lines
> each time that a new -stable is released. Rather though, I'd like a simple 
> "git pull" to do this while on this branch while a "git pull" while back on 
> the master branch pulls from the originally cloned Linus repo again.
> 
> Is this possible? Do I want it to be? Comments like "work like this 
> instead" welcome as well; figuring out what the heck it is that I want from 
> git seems to be one of the most difficult questions to answer...

Chris' mail made that somehow superfluous but anyhow. I have a Python script to update my Linux tree. It's attached.

It automatically adds git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.x.y as a remote as soon as v2.6.x is seen in Linus' repo and then fetches 2.6.16, 2.6.(last - 1) and 2.6.last. If you want to fetch all, change

	for stable in (16, last_stable - 1, last_stable):
in
	for stable in xrange(16, last_stable + 1):

The location of the repo is hardcoded to $HOME/gsrc/linux-2.6, but I think everyone with a bit of intuition should be able to change that ...

So it's not a "git pull" for me, but "update-linux".

Best regards Uwe

-- 
Uwe Kleine-König

main(){char*a="main(){char*a=%c%s%c;printf(a,34,a,34%c";printf(a,34,a,34
,10);a=",10);a=%c%s%c;printf(a,34,a,34,10);}%c";printf(a,34,a,34,10);}


#! /usr/bin/env python

import os, re, subprocess, sys

silent = False

git_dir = os.path.join(os.getenv('HOME'), 'gsrc', 'linux-2.6', '.git')
os.putenv('GIT_DIR', git_dir)

devnull = open('/dev/null', 'w', 0)
if silent:
  subprocess_stdout = devnull
else:
  subprocess_stdout = None

if not silent:
  print 'fetch origin'
subprocess.call(['git-fetch', 'origin'], stdout=subprocess_stdout)

sp_describe = subprocess.Popen(['git-describe', 'origin'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
sp_describe_stdin, sp_describe_stderr = sp_describe.communicate()

re_linuxver = re.compile('v2\.6\.(?P<minor>\d+)(?P<stable>\.\d+)?(?P<rc>-rc\d+)?(?P<git>-g[0-9a-fA-F]+)?')
mo = re_linuxver.match(sp_describe_stdin)

if not mo:
  print 'cannot parse version of origin\'s HEAD'
  sys.exit(1)

modict = mo.groupdict()

if modict['rc'] and not modict['stable']:
  last_stable = int(modict['minor']) - 1
else:
  last_stable = int(modict['minor'])

for stable in (16, last_stable - 1, last_stable):
  if subprocess.call(['git', 'repo-config', 'remote.v2.6.%d.y.url' % stable], stdout=devnull) != 0:
    subprocess.call(['git', 'repo-config', 'remote.v2.6.%d.y.url' % stable, 'git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-2.6.%d.y.git' % stable])
    subprocess.call(['git', 'repo-config', 'remote.v2.6.%d.y.fetch' % stable, 'refs/heads/master:refs/remotes/stable/v2.6.%d.y' % stable])
    subprocess.call(['git', 'repo-config', 'branch.v2.6.%d.y.remote' % stable, 'v2.6.%d.y' % stable])
    subprocess.call(['git', 'repo-config', 'branch.v2.6.%d.y.remote' % stable, 'v2.6.%d.y' % stable])
    subprocess.call(['git', 'repo-config', 'branch.v2.6.%d.y.merge' % stable, 'refs/heads/master'])

  if not silent:
    print 'fetch v2.6.%d.y' % stable
  subprocess.call(['git-fetch', 'v2.6.%d.y' % stable], stdout=subprocess_stdout)

← back to recent threads