]> git.madduck.net Git - code/myrepos.git/blob - mrconfig.git-fake-bare

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:

fixed git fake bare checkout
[code/myrepos.git] / mrconfig.git-fake-bare
1 # An example of how to add a new revision control system type to mr.
2 # git fake bare repositories have a detached workspace. One potential
3 # application is storing dotfiles in git, keeping them checked out in
4 # one $HOME, but checked into different git repositories. This file adds
5 # support for them, separate from the normal git support.
6
7 # To make mr use this file, add a line like this inside the [DEFAULT]
8 # section of your ~/.mrconfig
9 #include = cat /path/to/mrconfig.git-fake-bare
10
11 lib =
12         # git doesn't have an easy way to check out such a repo, so
13         # do it by hand
14         git_fake_bare_checkout() {
15                 set -x
16                 url="$1"
17                 repo="$2"
18                 worktree="${3%%/}/"
19                 git clone --no-checkout "$url" "$repo"
20                 cd "$repo"
21                 git read-tree HEAD
22                 git config core.worktree "$worktree"
23                 git checkout-index -a --prefix="$worktree" || true
24                 mv .git/* .
25                 rmdir .git
26         }
27
28 git_fake_bare_test = 
29         test -d "$MR_REPO"/refs/heads && test -d "$MR_REPO"/refs/tags &&
30         test -d "$MR_REPO"/objects && test -f "$MR_REPO"/config &&
31         test "$(GIT_CONFIG="$MR_REPO"/config git-config --get core.bare)" = false
32
33 git_fake_bare_update =
34         # all this is because of a bug in git-fetch, which requires GIT_DIR set
35         local git_dir_override; git_dir_override=.git
36         case "$(get_git_repo_type "$MR_REPO")" in
37                 fake-bare) git_dir_override="$MR_REPO";;
38         esac
39         args="$@"
40         [ -z "$args" ] && args="-t origin master"
41         eval GIT_DIR="$git_dir_override" git pull "$args"
42
43 git_fake_bare_status = git status "$@" || true
44
45 git_fake_bare_commit = error "commit does not work for fake bare git repositories (yet)."
46
47 git_fake_bare_diff = error "diff does not work for fake bare git repositories (yet)."
48
49 git_fake_bare_log = git log "$@"
50
51 git_fake_bare_register = 
52         url="$(LANG=C GIT_CONFIG=config git-config --get remote.origin.url)" || true
53         if [ -z "$url" ]; then
54                 error "cannot determine git url"
55         fi
56         worktree="$(git-config --get core.worktree)" || true
57         if [ -z "$worktree" ]; then
58                 error "git worktree is not set"
59         fi
60         worktree="${worktree%%/}/"
61         if [ ! -d "$worktree" ]; then
62                 error "git worktree $worktree does not exist"
63         fi
64         mr -c "$MR_CONFIG" config "`pwd`" \
65                 lib="GIT_WORK_TREE=$work_tree; export GIT_WORK_TREE"
66         echo "Registering git url: $url in $MR_CONFIG (with worktree $worktree)"
67         mr -c "$MR_CONFIG" config "`pwd`" checkout="git_fake_bare_checkout '$url' '$MR_REPO' '$worktree'"