mrsetup and the rest of the toys

martin f krafft madduck at
Thu Jul 17 22:15:37 CEST 2008

also sprach Yaroslav Halchenko <lists at> [2008.07.17.2000 +0200]:
> I have ran into your git repository while looking for a nice zsh
> config to start with. So I got interested in the way you setup
> management of the account configuration and projects within mr.
> I kept thinking to move my home CVS (at least parts) under similar
> setup, but I am lacking the rationale behind few decisions you've
> made. If you get a chance, could you either reply to me or
> describe your setup and typical workflow in your blog?

I've been meaning to do this as soon as I am comfortable with my
setup. It's okay up to now, but there are still some rough edges.

> now specific questions:

For the others, this is the repo of mrsetup, which I use to
bootstrap my accounts:

> 1. why did you decide to go with .fgits and git_fake_bare_checkout. How
> do you adjust and propagate your changes in lets say .ssh/config back
> into the repository and the rest of the nodes? how could those changes
> become MY_ACCOUNT specific
>  alternative seems to have .ssh/.git (instead of ssh.git/.{ssh,git}), ie
>  explicit clone of ssh.git under home dir, and to allow MY_ACCOUNT
>  specific branch within .ssh/ git repository (which gets pushed back to
>  repository). That allows easy modification of .ssh/* and immediate
>  'reflection' of the change, and later on push into repository (including
>  cherry picking into master branch which supposed to be common to all
>  the ACCOUNTs)

I used to do the subdirectory approach you describe and symlinked
files into ~ where needed, but that just turned out really ugly and
I had some problems with it.

I always wanted to just have files in ~ and be under version
control, so I briefly considered merging all the config repos into
a single account-specific branch which is checked out into ~, but
then that got to the point where I lost track.

So instead I started to experiment with detached worktrees: the git
repo is in ~/.fgits/ssh and it has core.worktree=../../ so that ~ is
its worktree (don't ask me where the name ~/.fgits came from). By
itself this works, but it's cumbersome to manage.

Therefore I use two tools to my rescue: mr and vcsh.

mr is Joey Hess' multiple repository tool and I configure it like
this:;;hb=HEAD. On
each machine I symlink those collections in ./roles to ~/.mr (which
is what you see at the link). ~/.mrconfig then simply includes them
and mr manages all my repos, including those under ~/.fgits

This works well and to pull in changes, I simply run `mr -i up` when
I need to sync an account. Right now, it all insists on ssh://, but
I want to integrate dynamic support for git:// instead for accounts
to which I don't forward my SSH agent socket.

The problem was for a long time how to commit changes, and to deal
with that, I wrote vcsh, which drops me into a subshell in which
GIT_DIR and GIT_WORK_TREE are setup up properly:;f=.zsh/func/vcsh;hb=HEAD

So after I made a change to, say ~/.zsh/zshrc, I would then do

  vcsh zsh

and get a prompt like this:


there I then add, commit, and push as needed. I am starting to like
this approach more and more because it enforces the modularity. In
fact, if I am about to make a change to the zsh config, I do so in
the vcsh zsh subshell... YMMV, of course.

SSH is an interesting case because I wanted to keep run-parts-style
modularity, but SSH only reads single files for authorized_keys and
known_hosts. Thus, I coded up a Makefile to compile those:;f=.ssh/Makefile;hb=HEAD

and told mr to invoke it. Sometimes this has caused me to scratch my
head, at other times it was really nice to be able to edit the
configuration file or known_hosts, knowing that the changes are
temporary and the file would be restored. I use aliases in [0] (note
how ssh drops stuff into ~/.zsh and thus registers completion and
aliases) to help me manage known_hosts.


crontabs [1] are another case where I use a Makefile, and where
I expect other tools (such as mutt [2]) to drop files into
~/.crontab.d. This is all still work in progress still...


I also handle the configuration file with the Makefile simply
because some accounts on older machines wouldn't have support for
all the options; those are now commented out on compilation.

This brings me to account-specific branches: I opted against them
and instead made my configuration global so that it applies
everywhere. This is much more straight forward than remembering to
cherry-pick local changes into the central config and then not to
forget to merge the central config into all local branches.

> 2. thus what exactly is destined to be kept under account/host specific
> configuration under ~/git/accounts/* ? for instance if I need ACCOUNT
> specific change in .ssh/config (which is a git_fake_bare_checkout), I
> guess I shouldn't add .ssh/config to ~/.git, right?

I am not sure about ~/git/accounts yet. Right now, I only store
~/.mrsetup in there, but I can also put account-specific stuff

One of the major problems with my setup that I still have to work on
is how to properly handle .gitignore. I can't have a central
.gitignore file (unless I write a merge handler), and
.git/info/exclude is not shared with other accounts, so it would
mean to duplicate all the exclusions. I am thinking about
~/.gitignore.d/$MODULENAME and then an automatic hook to register
that as ignore file, but I haven't gotten there yet.

> BTW -- tiny fix for mrsetup is to
> -MR_REPO_URL=ssh://
> +MR_REPO_URL=ssh://${MY_GIT_SERVER}/~/git/pub/code/mr.git


> also on my attempts mrsetup doesn't complete since 
> echo I: setting up base...
> $MR_CODE/mr -v co
> fails since 
> mr checkout: /raid/home/yoh/.fgits/mr.git/ already exists, skipping checkout
> since it checked out already as a part of 
> echo I: cloning mr configuration...
> $MR_CODE/mr co

is /raid/home/yoh/.fgits/mr.git/ a git repo or an empty directory?

martin | |
kill ugly radio
                                                        -- frank zappa
spamtraps: madduck.bogus at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature (see
URL: <>

More information about the vcs-home mailing list