]> git.karo-electronics.de Git - karo-tx-linux.git/blob - Next/rr-cache
Add linux-next specific files for 20131024
[karo-tx-linux.git] / Next / rr-cache
1 #!/bin/bash
2
3 #
4 # This script is intended to help with sharing a recorded resolution cache for
5 # use with git's rerere. It assumes that the cache is available in an orphaned
6 # branch of a remote repository.
7 #
8 # Run the following command to initialize the repository with a cache:
9 #
10 #   $ rr-cache init [branch]
11 #
12 # Where branch is the name of the (remote) branch that contains the cache. If
13 # omitted, origin/rr-cache will be used by default. The init command creates a
14 # local branch named rr-cache and clones it into the .git/rr-cache directory.
15 #
16 # Commands other than init are passed unmodified to git and are run on the new
17 # repository created in the .git/rr-cache subdirectory.
18 #
19
20 case $1 in
21         init)
22                 if test -d .git/rr-cache; then
23                         echo "error: directory .git/rr-cache already exists"
24                         exit 1
25                 fi
26
27                 if test -z "$2"; then
28                         ref=origin/rr-cache
29                 else
30                         ref="$2"
31                 fi
32
33                 remote=${ref%/*}
34                 branch=${ref#*/}
35
36                 if test "$remote" != "$ref" -o "$branch" != "$ref"; then
37                         echo "initializing rr-cache using remote branch $remote/$branch"
38                         git branch rr-cache "$remote/$branch"
39                         branch=rr-cache
40                 else
41                         echo "initializing rr-cache using local branch $branch"
42                 fi
43
44                 git clone -b $branch . .git/rr-cache
45                 ;;
46
47         *)
48                 git --git-dir=.git/rr-cache/.git --work-tree=.git/rr-cache "$@"
49                 ;;
50 esac