FlightGear Git

From FlightGear wiki
Revision as of 08:11, 1 June 2012 by Jomo (talk | contribs) (General review to try making it simpler for "newbies in design". Part 1 = up to creating local master --> will be continued)
Jump to navigation Jump to search

Git is a version control system used by the FlightGear project to store all of the files required to build the FlightGear, including all the programs, the data (e.g. aircraft), supporting tools, etc. Git tracks updates to every file as developers around the world work together concurrently to create new versions.

While new FlightGear features and additions are in development, they are available from Git before they are available in the standard release version. Using Git allows users to build the newest possible version of FlightGear from the latest source files, to experiment with new aircraft or other features. However, it's not a beginner's tool. Using Git can expose the user to unstable features that show ugly error messages, or crash the computer.

In May 2010, after a hardware failure on the CVS servers, the FlightGear project changed version control system from CVS to Git. The Git repositories are located at Gitorious and a mirror is hosted at the Mapserver.

Due to the "recent" switch, we are currently doing our best on providing manuals for obtaining FlightGear through Git. The following articles are work in progress:

Howto:Start using git provides a quick introduction to using git.

Motivation

Much has been written on the advantages of Git over CVS. For the FlightGear project, some advantages are:

  • Much better support for branches and merging branches. This is especially important for creating bug-fix releases for major releases while still allowing work on the next major release to continue. It is also very nice for a developer's personal workflow.
  • Easier path for contributors to submit changes and developers to integrate them.
  • Much better support for everyday tasks like searching the project history for changes, viewing changes, bisecting the project history to find the original source of a bug.

Also, as noted before, the CVS servers had a hardware failure on May 2010, speeding up FlightGear's change to Git.


Manipulating the GIT

Overview

Cloning and manipulating the GIT
For a detailed description see the description of the 4 repositories (A,B,C,D) in the following chapters

A) Repositories and branches

For historical reasons there continue to be separate repositories for SimGear and FlightGear source. For most users and developers the most interesting ones of each are:

  • next The current tip of new development. This branch should always compile and run, but various things could be broken.
  • release/* The branch subdirectory containing former and, if there is one, upcoming releases.

For other available branches have a look at our repository at gitorious.org. The following two branches are as of now (May 2011) very much out of date. Do not use.

  • master The tip of stable, tested new features. If we were to make a new release today, we would start from the tip of this branch. New features that have been "cooking" in the next branch for a few days or weeks will be merged here.
  • maint Bug fixes for the most recently released Flightgear. When a release is made from master, this branch is reset to it.

FlightGear data's branches of interest are:

  • master The one that is used with the next branch of the source.
  • release/* Same as for the source.

This arrangement follows the scheme used by the Git maintainers. This description is very technical; you will surely have achieved git-fu if completely understand it. However, the idea of maintaining several branches of different stability is common in collaborative software projects.

B) Create your own workspace on Gitorious

Prior to be able to manipulate GIT-data you must be a registered User and be logged in as such. See

https://gitorious.org/users/new
https://gitorious.org/login

Then check on http://gitorious.org/fg for the available projects. See e.g.:

  • flightgear
  • simgear
  • fgdata
  • getstart
  • etc.

Create your own "GIT-Clone" (as space to work in) by activating the "Clone repository" button of the wanted project.

By default you will be cloning the next branch of SimGear and FlightGear and the master branch of FGData. That is the actual repository including the newest, not yet formally distributed, changes. That is probably what you want if you want to

  • assist with reporting bugs before they are released as a proper release version
  • or participate in the design
  • or similar

If you are interested in other branches/versions see the button "Source Tree".

The created GIT-cone will be https://gitorious.org/~YourUID ("YourUID" being your ID you logged in with, and do not forgett the "~" in front of it!)</small)

C) Create a "master" on your local PC

  1. Create a unique folder on your PC, e.g. "..\GIT"
  2. change into that folder and use the "git clone" commands to clone the wanted repository
    1. if you need/want more informations about those commands, input "git help [command]" (e.g. "git help clone"))
  3. use one of the following commands (or similar) from within that GIT-folder:

Cloning SimGear

git clone git://gitorious.org/fg/simgear.git [target]
the folder target will be created and a clone of the SimGear repo stored inside it. If no target is given the new folder's name is simgear.

cd into the new folder. You are then inside the working tree of this git repo. The repo itself is stored inside the subfolder .git, which we mustn't edit manually. Git will take care of that.

git branch
will show the active branch. Right after download this will be * next, that means the content of the working tree is the bleeding edge of SimGear's source code.
git branch -a
will list all branches of a git repository. The one marked with an asterisk (*) is the active one.
git checkout master
will change the active branch to master. Means, that the content of the working tree will be changed to that state.
git checkout v2.0.0
will activate the state of the code inside the master branch at the time FG 2.0.0 was released.
git tag
will show all tags of the history of the active branch.
git pull
will update the local repo from the remote one.

Cloning FlightGear

Except for the initial clone command this is identical to Cloning SimGear.

git clone git://gitorious.org/fg/flightgear.git [target]

To successfully compile fgfs Flight- and SimGear's working tree must have the same state.

Cloning fgdata

At the time of writing the data repository is about 3.4 GB. Continuing an interrupted cloning of a repository is not supported with git. Therefore, if you have a slow or unstable connection to the internet, it is recommended to download the fgdata.bundle.

Also have in mind, that the repository plus the working tree will be more than twice the size of the download on your local filesystem.

There is neither a next branch nor any tags in that repository. If you want to build FlightGear 2.0.0 you may fetch the data (FlightGear-data-2.0.0.tar.bz2) at one of the mirrors.

git clone git://mapserver.flightgear.org/fgdata/ [target]
if no target is given the new folder's name is fgdata

cd into the new directory and verify it's state with git branch. If it isn't * master, do a git checkout master.

fgdata.bundle

For the FlightGear-data there are also bundles (snapshots) available that can be retrieved with your favourite download manager. This way you can resume interrupted downloads. After unpacking only a comparatively small amount of data has to be transferred from the git server to synchronize your repository.

Download the bundle from

$ wget http://flightgear.mxchange.org/pub/fgfs/fgdata.bundle

The bundle may be periodically updated and bundles from different sources need not be the same. The file size for the above bundle dated 2011-12-13 is almost 4GB :-), while the md5 checksum is

$ md5sum fgdata.bundle
145f4e190fd1a02fd75c1d508b8c2ec3  fgdata.bundle 
Caution: should be that. If the bundle is updated, not be the same.

Do the following steps to extract the bundle and bring the repository up to date:

$ git clone fgdata.bundle fgdata
$ cd fgdata
$ git checkout -b master-tmp
Switched to a new branch 'master-tmp'
$ git remote rm origin
$ git remote add origin git://gitorious.org/fg/fgdata
$ git fetch origin
$ git branch --track master origin/master
$ git checkout master
$ git branch -D master-tmp

If you get an error at git fetch origin try:

$ git remote rm origin
$ git remote add origin git://mapserver.flightgear.org/fgdata/
$ git fetch origin

You should be suspicious if based on the printed progress you estimate the data download during the fetch will exceed 1GB (assuming the bundle is not terribly outdated).


D) Editing Data

To make individual changes, like editing a joystick file, add a plane to fgdata or patch the source code, it is recommended to create a local branch inside that repository. The following commands will describe a way to achieve this. But have in mind, that this is very basic and only suits for users who have minor changes.

cd into the repositories folder, e.g. fgdata:

git checkout -b master.local master
a new branch master.local is created out of the master branch and set as the active one. You may now apply your individual stuff there and start FlightGear to verify the changes are proper.

If you conclude they are, you have to tell git about those changes:

git status
will give you a list of files that have been altered or that are new.
git add -i
will show the files that have been altered and give you options on what to do next. git add does not actually add the changes to master.local but adds them to the index.
[a]dd will add new paths/files (called untracked in status) from the working tree to the index. This has to be done only if you have added paths/files, like an aircraft, to the working tree.
If git finds more than one untracked file/path, it will give you a numbered list and prompt to select which ones should be added. An empty input will exit this mode. See "Interactive mode" in man git add for more details.
[u]pdate is the next step and will update the altered and tracked files to the index in the same manner as explained in add untracked paths above.
git commit
will commit the indexed updates to the master.local branch. It opens a list of the updates in your standard editor. You may add a comment to that file describing the object of the commit. Save and exit the editor. You have now committed your changes inside the working tree to your personal branch.

To update that personal branch from the remote one do the following steps:

git fetch                     # update repo
git checkout master           # switch to master branch
git rebase origin/master      # update master branch
git checkout master.local     # switch back to the individual branch
git rebase master             # update it

Some more helpful commands

git help
git help [commad]
git apply
apply a patch to files and/or to the index http://www.kernel.org/pub/software/scm/git/docs/git-apply.html
git checkout -f
may be used to throw away any local changes to the working tree. Use with care, as any option that name is -f or --force, and only after reading git checkout help!

Tracking a release branch

git branch -t -l release/2.6.0 origin/release/2.6.0
git checkout -b release/2.6.0


For future updates just do a git pull.

Merge your Data into the GIT

Edit and "Commit" the changes

Creating a merge request at Gitorious.

Make a clone of fgdata, by clicking the clone repository button on Gitorious. Commit your stuff first to your local repository (git commit), then perform the following commands:

=== Rebase the master

  • git fetch to get the latest commits from fgdata/
  • git rebase origin/master place your own commit on top of the latest commits/

Push your changes to your clone on Gitorious

  • git push git@gitorious.org:~name/fg/namess-fgdata.git push your commits to your fgdata clone. Replace the url with your fgdata-clone's SSH url!

Go to your fgdata-clone on Gitorious and click the "Request merge" button on the right. Write a short summary in which you explain what your commit(s) do. Then choose the following settings:

Target directory: fgdata
Target branch: master
Source branch: master

Next select the commits you'd like to include in your merge request and click "Create merge request".

Commit the changes into the GIT

This step is for developers with fgdata commit access only!

To push merge request to fgdata, the following workflow can be followed:

git checkout -b integration						# the integration branch should not yet exist. You can use any name you'd like
git pull git://gitorious.org/fg/fgdata.git refs/merge-requests/1	# make sure you change 1 to the id of the merge request
git rebase master							# place the new commits on top of existing commits (without ugly "Merge branch into ...")
git checkout master
git cherry-pick b049e1d							# repeat this for each commit you'd like to push
git push

External links

Git tutorials and resources