From 25888636ae3eb414f0c08b9df01bff17e448f0d5 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Thu, 14 Aug 2008 11:21:58 -0500 Subject: [PATCH] Convert git config over to a post receive script. --- cbas/post-receive | 1 + server/post-receive-git-config | 15 +++++++++++++++ server/update-git-config | 19 ------------------- ...> t2800-server-post-receive-git-config.sh} | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) create mode 100644 server/post-receive-git-config delete mode 100644 server/update-git-config rename tests/{t2800-server-update-git-config.sh => t2800-server-post-receive-git-config.sh} (93%) diff --git a/cbas/post-receive b/cbas/post-receive index 19824c1..8c24392 100755 --- a/cbas/post-receive +++ b/cbas/post-receive @@ -11,4 +11,5 @@ done echo -n "$input" | sh /srv/git/hooks/server/post-receive-email echo -n "$input" | sh /srv/git/hooks/server/post-receive-trac +echo -n "$input" | sh /srv/git/hooks/server/post-receive-git-config diff --git a/server/post-receive-git-config b/server/post-receive-git-config new file mode 100644 index 0000000..2936718 --- /dev/null +++ b/server/post-receive-git-config @@ -0,0 +1,15 @@ +#!/bin/sh + +while read oldrev newrev refname ; do + if [ "$refname" == "refs/heads/gitconfig" ] ; then + config_hash=$(git ls-tree $newrev | grep config | gawk '{print $3}') + if [[ "$config_hash" != "" ]] ; then + git cat-file blob "$config_hash" | while read line ; do + key="${line%=*}" + value="${line#*=}" + git config "${key}" "${value}" + done + fi + fi +done + diff --git a/server/update-git-config b/server/update-git-config deleted file mode 100644 index 30b814b..0000000 --- a/server/update-git-config +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -refname="$1" -oldrev="$2" -newrev="$3" - -if [ "$refname" != "refs/heads/gitconfig" ] ; then - exit 0 -fi - -config_hash=$(git ls-tree $newrev | grep config | gawk '{print $3}') -if [[ "$config_hash" != "" ]] ; then - git cat-file blob "$config_hash" | while read line ; do - key="${line%=*}" - value="${line#*=}" - git config "${key}" "${value}" - done -fi - diff --git a/tests/t2800-server-update-git-config.sh b/tests/t2800-server-post-receive-git-config.sh similarity index 93% rename from tests/t2800-server-update-git-config.sh rename to tests/t2800-server-post-receive-git-config.sh index d73df30..2adbd6e 100644 --- a/tests/t2800-server-update-git-config.sh +++ b/tests/t2800-server-post-receive-git-config.sh @@ -16,7 +16,7 @@ test_expect_success 'setup' ' git fetch ' -install_update_hook 'update-git-config' +install_post_receive_hook 'post-receive-git-config' test_expect_success 'pushing initial value works' ' cd server && -- 2.39.5