Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
Programming Linux

Linus On Branching Practices 90

rocket22 writes "Not long ago Linus Torvalds made some comments about issues the kernel maintainers were facing while applying the 'feature branch' pattern. They are using Git (which is very strong with branching and merging) but still need to take care of the branching basics to avoid ending up with unstable branches due to unstable starting points. While most likely your team doesn't face the same issues that kernel development does, and even if you're using a different DVCS like Mercurial, it's worth taking a look at the description of the problem and the clear solution to be followed in order to avoid repeating the same mistakes. The same basics can be applied to every version control system with good merge tracking, so let's avoid religious wars and focus on the technical details."
This discussion has been archived. No new comments can be posted.

Linus On Branching Practices

Comments Filter:
  • by Shandalar ( 1152907 ) on Tuesday November 30, 2010 @01:50PM (#34391162)
    Here is the actual article that the submitter should have linked to. [lkml.org] It's Linus's post. Instead, the submitter linked to his or her advert site, which is a blog that has ads which hawk their own, non-git source control system, all of which you get to read before you are given the link to Linus's actual post.
  • by Americano ( 920576 ) on Tuesday November 30, 2010 @01:55PM (#34391244)

    Yep, this is standard practice if your scm support knows what they're doing. The only reason it's not "desirable" to only branch off of stable, 'known-good' baselines is developer laziness. It can take more time setting up the branch, and sometimes that quick checkout-edit-checkin on the trunk is just SOOOO tempting as a shortcut. I see this a lot in groups working on new products, too - "it's never been released to production, so we'll just branch from wherever, and call it a day." Usually they grow out of this type of practice after they spend a few days untangling a mess they've created, but there are some die-hards who just hate having to deal with anybody else, and insist on doing their own thing.

    This is why it's important to have:
    1) Management / leadership that understands the value of proper configuration management, and expects good practices to be used;
    2) Support for your SCM system that knows how to set up these practices and is empowered to enforce them;
    3) Mature developers who understand that "fastest" isn't always "best";

    (Full disclosure: part of my role in my current job involves clearcase admin, and i've also worked with svn, cvs, pvcs, and (shudder) vss in varying capacities)

  • by gstoddart ( 321705 ) on Tuesday November 30, 2010 @02:05PM (#34391472) Homepage

    For most projects I’ve been involved with, the path to success is keeping the trunk in a stable state, and using _that_ as the baseline. Dev code should never be in the trunk imo... the trunk should always be in a ready to release (or proceed to formal testing, or whatever) state. Everyone branches from the trunk.. everyone can update their branch to the latest trunk.. and everyone merges back down into the trunk when it’s good and ready.

    He's also saying that everybody should branch from the exact same point along the branch or trunk. That way everybody has a set of diffs against the same baseline to merge back in.

    If you always branch from trunk, then as more stuff gets added, you start from a different point than you might otherwise.

    The specifically labeled "point in time" means that three separate changes can more readily be integrated as they'll be all from the exact same baseline.

    If the trunk is ready for formal testing, and it affects your other branches, you have a harder time if you fix things and need to push them back into those branches.

  • by kbielefe ( 606566 ) <karl,bielefeldt&gmail,com> on Tuesday November 30, 2010 @03:00PM (#34392420)

    I hate to break it to you, but even if your trunk is clean, you will still have this problem in some other branch. Let's examine a very common situation where you have an interface being changed, one or more implementations of that interface, and one or more users of that interface. Developers are working simultaneously on both sides of that interface in order to meet a deadline.

    Because of your clean trunk rule, none of the changes can be checked into the trunk until all of the changes are ready, but they still need to be shared among the people working on it, or they will have no idea if it is "good and ready." So those developers create their own branch, which of necessity is sometimes in a temporarily broken state. You might not think of it as a branch, if it's John's working directory and the "checkout" procedure is him emailing files around, but it's conceptually a branch nonetheless.

    Linus is simply acknowledging that temporary brokenness is inevitable when multiple people integrate changes to the same code, and therefore whatever branch contains that messy integration should use tags to communicate the best branch points. I'm not saying keeping a clean trunk isn't a good idea, just that you have to deal with broken branch points one way or another, even if it's just John deciding when the best time is to email out the new header files to his team.

  • by Americano ( 920576 ) on Tuesday November 30, 2010 @05:15PM (#34395044)

    You can do it right with a 4-line config spec. The config spec needs to include that /main/LATEST clause at the bottom because new elements being added to the branch aren't labeled with the baseline you're branching from.

    The config spec should take the form of:

    element * CHECKEDOUT
    element * .../branch/LATEST
    element * BASELINE -mkbranch branch
    element * /main/LATEST -mkbranch branch

    The only time the /main/LATEST rule will ever be evaluated is if an element is added to the branch after the BASELINE is applied, and even then, it will force development out to the branch.

UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. -- Doug Gwyn

Working...