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

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:

Revert "fix a few more messages for absolute paths"
[code/myrepos.git] / lib / gitless
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/gitless
10 #
11 # And an example repo using it would look something like:
12 #[lib/sound]
13 #checkout = gitless_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         gitless_checkout() {
25                 server="$1"
26                 remotebase="$2"
27                 dir="$3"
28                 hostname="$(hostname)"
29                 if [ "$hostname" = "$server" ]; then
30                         git clone "$dir.git" "$dir" 
31                         cd "$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.$hostname/.git"
39                         git reset --hard
40                 fi
41                 
42                 # disable auto gc, because it breaks repo hard links,
43                 # and is not smart to run over a networked filesystem
44                 git config gc.auto 0
45         }