chiark / gitweb /
New substitute machinery
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 10 Jun 2016 17:54:20 +0000 (18:54 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 10 Jun 2016 17:54:20 +0000 (18:54 +0100)
infra/substitute [new file with mode: 0755]
infra/template [new file with mode: 0644]
templates/gitconfig.in [new file with mode: 0755]

diff --git a/infra/substitute b/infra/substitute
new file mode 100755 (executable)
index 0000000..112e046
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/bash
+set -e
+
+mode_subst () {
+    $fn >$bfn.new
+}
+
+mode_diff () {
+    diff -u $dot $bfn.new || test $? = 1
+}
+
+mode_install () {
+    mv -f $bfn.new $dot
+}
+
+mode=$1
+case "$mode" in
+subst|diff|install) ;;
+*) echo >&2 'bad mode'; exit 1;
+esac
+shift
+
+for fn in templates/*.in; do
+    bfn=${fn%.in}
+    dot=$HOME/.${bfn#*/}
+    mode_$mode
+done
diff --git a/infra/template b/infra/template
new file mode 100644 (file)
index 0000000..6d1dae0
--- /dev/null
@@ -0,0 +1,5 @@
+# -*- sh -*-
+
+cd dot/configs
+eval `./checkconfig`
+cd ../..
diff --git a/templates/gitconfig.in b/templates/gitconfig.in
new file mode 100755 (executable)
index 0000000..7e874d2
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+set -e
+. infra/template
+
+case "$(hostname -f)" in
+*.xensource.com)
+    email="ian.jackson@eu.citrix.com"
+    cache=git://git-cache.xs.citrite.net:9419
+    ;;
+*)
+    email=ijackson@chiark.greenend.org.uk
+    ;;
+esac
+
+cat <<END
+[user]
+       email="$email"
+[sendemail]
+        bcc = $email
+END
+
+if [ "$cache" ]; then
+    cat <<END
+[url "$cache/git://"]
+        insteadOf = git://
+[url "$cache/git://"]
+        insteadOf = $cache/git://
+[color]
+        diff = false
+        ui = false
+END
+fi