?TableOfContents

Git

The repositories for the packaging in git is stored in a different manner than they are under svn. Each package has its own git repository (and thus its own directory) under the /git/pkg-games directory on the alioth servers.

This guide assumes that you are uploading the packaging files for a package for the first time.

A separate section will describe how to import the packaging that was stored in the svn repository in the future.

Environment variables

These are some environment variables that git uses when you commit changes. It's best to set these environment variables so that git doesn't rely on your system's username or hostname. Place this snippet in your ~/.bashrc configuration file.

# Git variables
export GIT_AUTHOR_NAME='<your name>'
export GIT_AUTHOR_EMAIL='<your email>'
export GIT_COMMITTER_NAME='<your name>'
export GIT_COMMITTER_EMAIL='<your email>'

Creating a git repository

First, create a repository in the /git/pkg-games directory on the alioth servers.

$ mkdir <package>.git
$ cd <package>.git
$ git --bare init --shared

Now edit the 'description' file in the directory you just created to one that is appropriate for the package.

$ echo "Packaging for <package>" >description

Let's also enable the use of 'hooks/post-update'.

$ chmod a+x hooks/post-update

The following will enable the games team to receive commit mails and irc notifications about commits. Please do the following.

$ git-config --add hooks.mailinglist "pkg-games-commits@lists.alioth.debian.org"
$ git-config --add hooks.cia-project debian-pkg-games
$ cat >hooks/post-receive <<END
#!/bin/sh
exec /usr/local/bin/git-commit-notice
END
$ chmod a+x hooks/post-receive

Now we're done creating a repository for the package. You could also use the 'setup-repository' script that's in the pkg-games directory. That script is really a symlink to the script that's used in the collab-maint directory. This however will not setup the hook scripts.

./setup-repository <package> '<package description>'

Please see the documentation about mr below, and add the new repository to list of games team repositories in the .mrconfig file.

Uploading a package to the repository

Now let's import the package into a git repository. This is easy using 'git-import-dsc' from the 'git-buildpackage' package.

$ git-import-dsc --pristine-tar <package>.dsc

(The --pristine-tar option is optional; if you have pristine-tar installed this will store enough information in the git repository to reproduce the pristine upstream tarball later.)

A directory with the name of the source package should have been made. Change into that directory.

$ cd <package>

Ensure the tags that are created reflect if a package has been released. git-buildpackage creates tags for the debian branch and the upstream branch. If the tag created for the debian branch reflects an unreleased version, you'll have to delete that "debian" tag.

$ git-tag -l
$ git-tag -d 'debian/<unreleased version>'

Finally, push the repository up to the repository on alioth.

$ git-remote add alioth git+ssh://<username>@git.debian.org/git/pkg-games/<package>.git
$ git-push alioth master
$ git-push alioth upstream
$ git-push alioth pristine-tar
$ git-push alioth --tags

(Again the pristine-tar step is optional.)

Accessing a repository

To get a repository, do the following.

$ git-clone git+ssh://<username>@git.debian.org/git/pkg-games/<package>.git

You can also enjoy read-only access by using the following.

$ git-clone git://git.debian.org/git/pkg-games/<package>.git
$ git-clone http://git.debian.org/git/pkg-games/<package>.git

To view a summary of the repository on your favorite web browser, go to the following address.

http://git.debian.org/?p=pkg-games/<package>.git

Committing changes

To commit a change, first commit into your local repository.

$ git-commit -m "<some comment>"

You could also do a commit of all files that were changed using the '-a' option.

$ git-commit -a -m "<some comment>"

Push your changes.

$ git-push #If you cloned the repository
$ git-push alioth #If you created the repository using the above example

Updating

To keep updated simply do the following

$ git-pull #If you cloned the repository
$ git-pull alioth #If you created the repository using the above exmple

Tagging

To tag a release, you could build it using 'git-buildpackage' with the '--git-tag' option.

$ git-buildpackage --git-tag --pristine-tar

(As usual, the --pristine-tar bit is optional, but it will allow git-buildpackage to extract the pristine .orig.tar.gz.)

You could also manually tag the package. Ensure that you are in the correct branch (should be 'master').

$ git-checkout master
$ git-tag debian/<revision> -m "Debian release <revision>" #Please use this format

To tag an earlier revision, you'll need to find out it's commit object, then tag that object.

$ git-rev-list --pretty --since="1 month" --all #'1 month' is just an example of course
$ git-tag debian/<revision> <commit object> -m "Debian release <revision>"

Finally, push the tags

$ git-push --tags

Converting from svn repository

To convert from the svn repository, first setup the git repository on the alioth servers as described above. Afterwards, do the following.

$ mkdir <package>
$ cd <package>
$ git-svn init --no-metadata \
    --trunk svn://svn.debian.org/svn/pkg-games/packages/trunk/<package> \
    --branches svn://svn.debian.org/svn/pkg-games/packages/branches/<package> \
    --tags svn://svn.debian.org/svn/pkg-games/packages/tags/<package>
$ git-svn fetch

Note: Doing git-svn fetch will take some time depending on how many commits were done in the svn repository.

After fetching from the svn repository, it's now time to import the contents of the orig source.

$ git-symbolic-ref HEAD refs/heads/upstream
$ git-rm --cached -r .
$ git-commit --allow-empty -m 'initial upstream branch'
$ git-checkout -f master
$ git-merge upstream
$ git-import-orig <path_to_tarball>

After this step, push the contents of your local repository.

$ git-remote add alioth git+ssh://<username>@git.debian.org/git/pkg-games/<package>.git
$ git-push alioth master
$ git-push alioth upstream
$ git-push alioth --tags

This step here is a way to push the tags and branches that were imported from svn (an explanation about this is below). Do this to push all tags and branches that were imported.

$ for REMOTES in `find .git/refs/remotes -type f ! -regex '.*trunk$' ! -regex '.*\/alioth\/.*'`; \
  do git-push alioth $(echo $REMOTES | sed 's|\.git/refs/||'); done

Cloning and pulling

Anyone pulling from a converted repository will have two steps to perform. The first step is the usual cloning.

$ git-clone git+ssh://<username>@git.debian.org/git/pkg-games/<package>.git

And then the next step involves pulling the "remotes" branches and tags that were pushed.

$ cd <package>
$ git-pull origin +refs/remotes/*:refs/remotes/*

Possible problems

There is a chance you'll receive an error similar to this one.

dch: fatal error at line 963:
New version specified (1.4.8.dfsg1-1) is less than
the current version number (1.4.8.dfsg1-1)!  Use -b to force.
dch returned 25
Dch failed.
Import of ../../build-area/ogre_1.4.8.dfsg1.orig.tar.gz failed

This is fine as it should only be a problem with dch.

Note about tags and branches

Tags and branches are preserved using what's called "git remotes". This means that there are no real git tags and branches visible, but that the SVN trunk, tags and branches are tracked as separate repositories. Downside is that you need to switch to to the remotes individually before you can update them.

All tags and branches are listed under .git/refs/remotes/ and can be checked out, but it is somewhat confusing as all old schemes for using tags and branches are there too...

So to checkout a branch do the following.

$ git-checkout remotes/<some_branch>

And for tags.

$ git-checkout remotes/tags/<some_tag>

mr

The mr command can be used to checkout, update, and commit to multiple repositories. In the pkg-games svn repository, is a packages/trunk/.mrconfig file that configures mr for all the repositories used by the games team.

New git repositories should be added to this .mrconfig file.

To use it, install the mr package, and create a ~/.mrconfig file letting mr know about the pkg-games svn repository. In this example, it will be checked out to ~/src/packages/games, but you can modify to suit. If you already have a pkg-games svn checkout, you can change the directory to point to that.

[src/packages/games]
chain = true
checkout = svn co svn+ssh://svn.debian.org/svn/pkg-games/packages/trunk games

Then run "mr checkout", which will checkout the svn repository into ~/src/packages/games.

A second "mr checkout" (necessary because of bug #447553) will checkout the additional git repositories, into subdirectories of ~/src/packages/games/.

Now you can use mr to act on all configured repositories at once.

Update all repositories:

% mr update

Get status of all checkouts:

% mr status

List all repositories that mr knows about:

% mr list

Or even commit changes in each repository:

% mr commit

If you've added a new git repository in ~/src/packages/games/<foo> and are in that directory, you can have mr automatically add it to the pkg-games .mrconfig file by running "mr register". (Don't forget to commit the file.)

See Also