Configuring Git

Like its predecessors, Git is wonderfully configurable, and many (most?) of us choose to change some of the defaults. But who develops on just a single computer? Adding your Git configuration to MCM makes it easy to synchronise (and track) your changes across machines. Here's an example:


import Admin.Packages as Packages

define git()
	Packages.add package> git

define userconfig(gitemail home userfullname)
	File path> @home/.gitconfig
		content: [user]
			+   name = @userfullname
			+   email = @gitemail
			+ [color]
			+   diff = always
			+   status = always
			+ [alias]
			+   wdiff = diff --color-words
			+   f = fetch
			+   ls = log --oneline --decorate -n 20
			+   lsa = log --oneline --decorate -n 20 --all
			+   ll = log --oneline --decorate -n 20 --numstat
			+   lla = log --oneline --decorate -n 20 --all --numstat
			+   s = status
			+   # Usage: "git export <tag>"
			+   export = !b=`basename $PWD` && git archive --prefix=$b-$1/ -o /tmp/$b-$1.tar.gz
			+   # Usage: "git namedexport <packagename> <tag>"
			+   namedexport = !sh -c 'git archive --prefix=$1-$2/ -o /tmp/$1-$2.tar.gz $2' -

The git() define simply requests that the git package be installed, so can be called from pretty much anywhere (e.g. machine configuration scripts and when a dependent). The userconfig() define is designed to be called from scripts configuring home directories.