Next: , Previous: , Up: Integration with existing software   [Index]

Integration with Git

Git version control system already has all necessary tools for store-and-forward networking. git-bundle command is everything you need.

Use it to create bundles containing all required blobs/trees/commits and tags:

$ git bundle create repo-initial.bundle master --tags --branches
$ git tag -f last-bundle
$ nncp-file repo-initial.bundle remote.node:repo-$(date % '+%Y%M%d%H%m%S').bundle

Do usual working with the Git: commit, add, branch, checkout, etc. When you decide to queue your changes for sending, create diff-ed bundle and transfer them:

$ git bundle create repo-$(date '+%Y%M%d%H%m%S').bundle last-bundle..master
or maybe
$ git bundle create repo-$(date '+%Y%M%d').bundle --since=10.days master

Received bundle on remote machine acts like usual remote:

$ git clone -b master repo-XXX.bundle

overwrite repo.bundle file with newer bundles you retrieve and fetch all required branches and commits:

$ git pull # assuming that origin remote points to repo.bundle
$ git fetch repo.bundle master:localRef
$ git ls-remote repo.bundle

Bundles are also useful when cloning huge repositories (like Linux has). Git’s native protocol does not support any kind of interrupted download resuming, so you will start from the beginning if connection is lost. Bundles, being an ordinary files, can be downloaded with native HTTP/FTP/NNCP resuming capabilities. After you fetch repository via the bundle, you can add an ordinary git:// remote and fetch the difference.

Also you can find the following exec-handler useful:

#!/bin/sh -ex

trap "rm -f $tmp" HUP PIPE INT QUIT TERM EXIT
read revs
cd $HOME/git/$1.git
git bundle create $tmp $revs
nncp-file -nice $NNCP_NICE $tmp $NNCP_SENDER:$1-$(date '+%Y%M%d%H%m%S').bundle

And it allows you to request for bundles like that: echo some-old-commit..master | nncp-exec REMOTE bundler REPONAME.

Next: Integration with multimedia streaming, Previous: Downloading service, Up: Integration with existing software   [Index]