#!/bin/sh # # Copyright (c) 2008 Stephen Haberman # # Auto-deploys the contents of the gitconfig branch to $GIT_DIR. # # The config file is handled specially--instead of the $GIT_DIR's config file # being copied over entirely, the gitconfig:config is evaluated line by line # with calls to `git config`. This means you can have settings in # $GIT_DIR/config that are not in the gitconfig:config and they will not be # overwritten. Deleting $GIT_DIR/config entries has to be manually. # # Hooks are copied over entirely, but old ones are not deleted. Deleting # existing hooks has to be done manually. # while read oldrev newrev refname ; do if [ "$refname" == "refs/heads/gitconfig" ] ; then config_hash=$(git ls-tree $newrev | grep config | grep -oP '\w{40}') if [[ "$config_hash" != "" ]] ; then git cat-file blob "$config_hash" | while read line ; do key="${line%=*}" value="${line#*=}" git config "${key}" "${value}" done fi hooks_hash=$(git ls-tree $newrev | grep hooks | grep -oP '\w{40}') if [[ "$hooks_hash" != "" ]] ; then git ls-tree "$hooks_hash" | while read mode type file_hash file_name ; do echo "Installing $file_name" git cat-file blob "$file_hash" > "hooks/$file_name" done fi git ls-tree $newrev | grep -v hooks | grep -v config | grep blob | while read mode type file_hash file_name ; do echo "Installing $file_name" git cat-file blob "$file_hash" > "$file_name" done fi done