]> git.madduck.net Git - code/myrepos.git/blob - lib/git-remote

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Add git-remote file to lib. This adds a special type of git repository, where the...
[code/myrepos.git] / lib / git-remote
1 # This adds a special type of git repository, where the .git directory
2 # is stored on a file server, to avoid wasting space with it on the client.
3 # One example use is storing a music collection in git, where you can spare
4 # the extra space needed for .git on your file server, but not on your
5 # laptop. This fills basically the same niche as unison.
6
7 # To make mr use this file, add a line like this inside the [DEFAULT]
8 # section of your ~/.mrconfig
9 #include = cat /usr/share/mr/git-remote
10 #
11 # And an example repo using it would look something like:
12 #[lib/sound]
13 #checkout = git_remote_checkout turtle /media/turtle/home/joey/lib sound
14
15 # In this example, the file server's hostname is "turtle", 
16 # and it's mounted on /media/turtle. The file server contains a sound.git
17 # repository in the specified directory under that mount point.
18 # When mr checks out that repository, it will create a sound.hostname
19 # directory on the server, containing just the .git directory, and symlink
20 # the client's .git directory to it. After checkout, normal git and mr
21 # commands can be used, as long as the file server is available.
22
23 lib =
24
25         git_remote_checkout() {
26                 server="$1"
27                 remotebase="$2"
28                 dir="$3"
29                 hostname="$(hostname)"
30                 if [ "$hostname" = "$server" ]; then
31                         git clone "$dir.git" "$dir" 
32                 else
33                         if [ ! -d "$remotebase/$dir.$hostname" ]; then
34                                 git clone --no-checkout "$remotebase/$dir.git" "$remotebase/$dir.$hostname"
35                         fi
36                         mkdir -p $dir
37                         cd $dir
38                         ln -sf $remotebase/$dir/.git
39                         git checkout .
40                 fi
41         }