Skip to content

Commit

Permalink
Get tests passing again.
Browse files Browse the repository at this point in the history
* Lots of /bin/sh -> bin/bash changes
* Change "server" directory in tests to be a bare repository
* Remove "lockfile" usage for a plain, always-available "mkdir"

Partially contributed and otherwise prompted by Aaron Boxer.
  • Loading branch information
Stephen Haberman committed Apr 14, 2011
1 parent 850118b commit 4aca6f6
Show file tree
Hide file tree
Showing 49 changed files with 223 additions and 222 deletions.
2 changes: 1 addition & 1 deletion scripts/checkout
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Makes checkout "just work" in terms of checking out the branch whether or not
# it exists locally or remotely.
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-gitconfig
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Creates a separate DAG in your repo for git config files.
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/pull
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Makes pull "just work" by correctly rebasing of local commits on top of new
# incoming commits.
Expand Down
2 changes: 1 addition & 1 deletion scripts/push
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Makes push "just work" by only pushing the current branch to origin.
#
Expand Down
2 changes: 1 addition & 1 deletion scripts/refollow
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

#
# Goes through the ensure-follows branches and makes sure
Expand Down
25 changes: 13 additions & 12 deletions server/functions
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# Sets: new_commits
# Assumes: $oldrev $newrev $refname
Expand Down Expand Up @@ -85,7 +85,7 @@
# "remotes/" will be ignored as well.
#
##################################################
function set_new_commits() {
set_new_commits() {
nl=$'\n'

# Get all the current branches, not'd as we want only new ones
Expand Down Expand Up @@ -114,7 +114,7 @@ function set_new_commits() {
# 0000->1234 (create)
# 1234->2345 (update)
# 2345->0000 (delete)
function set_change_type() {
set_change_type() {
if [ "$oldrev" == "0000000000000000000000000000000000000000" ] ; then
change_type="create"
else
Expand All @@ -129,7 +129,7 @@ function set_change_type() {
# Sets: $newrev_type $oldrev_type $rev $rev_type
# Assumes: $newrev $oldrev
# --- Get the revision types
function set_rev_types() {
set_rev_types() {
newrev_type=$(git cat-file -t "$newrev" 2> /dev/null)
oldrev_type=$(git cat-file -t "$oldrev" 2> /dev/null)
if [ "$newrev" == "0000000000000000000000000000000000000000" ] ; then
Expand All @@ -145,7 +145,7 @@ function set_rev_types() {
# Assumes: $rev
#
# The email subject will contain the best description of the ref that we can build from the parameters
function set_describe() {
set_describe() {
rev_to_describe="$rev"
if [ "$1" != "" ] ; then
rev_to_describe="$1"
Expand All @@ -161,7 +161,7 @@ function set_describe() {
# Assumes: $rev
#
# The email subject will contain the best description of the ref that we can build from the parameters
function set_describe_tags() {
set_describe_tags() {
rev_to_describe="$rev"
if [ "$1" != "" ] ; then
rev_to_describe="$1"
Expand All @@ -179,34 +179,35 @@ function set_describe_tags() {
#
# with_lock "foo.lock" "echo a" # Works
# with_lock "foo.lock" "echo b1 ; echo b2" # Work
# function several() {
# several() {
# echo several1 ; echo several2
# }
# with_lock "foo.lock" several # Works
#
function with_lock() {
with_lock() {
lockfile="$1"
block="$2"
with_lock_has_lock=1

trap with_lock_unlock_if_held INT TERM EXIT
lockfile -1 -r 300 "$lockfile"
# used to use lockfile to try multiple times but it's not always available
mkdir "$lockfile"
with_lock_has_lock=$?
if [ $with_lock_has_lock -ne 0 ] ; then
exit $?
fi
eval "$block"
rm -f "$lockfile"
rmdir "$lockfile"
with_lock_has_lock=1
}

function with_lock_unlock_if_held() {
with_lock_unlock_if_held() {
if [[ "$with_lock_has_lock" -eq 0 ]] ; then
rm -f "$lockfile"
fi
}

function display_error_message() {
display_error_message() {
echo "----------------------------------------------------" >&2
echo "" >&2
echo "" >&2
Expand Down
2 changes: 1 addition & 1 deletion server/post-receive-commitnumbers 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Creates commitnumbers as lightweight tags named "r/X" where X increases
# monotonically.
Expand Down
2 changes: 1 addition & 1 deletion server/post-receive-email
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Copyright (c) 2007 Andy Parkins
# Copyright (c) 2008 Stephen Haberman
Expand Down
2 changes: 1 addition & 1 deletion server/post-receive-gitconfig 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Copyright (c) 2008 Stephen Haberman
#
Expand Down
2 changes: 1 addition & 1 deletion server/post-receive-hudson 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Copyright (c) 2008 Stephen Haberman
#
Expand Down
2 changes: 1 addition & 1 deletion server/post-receive-trac 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. $(dirname $0)/functions

Expand Down
Empty file modified server/post-receive-trac.py 100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion server/post-receive.sample
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

nl=$'\n'
input=""
Expand Down
2 changes: 1 addition & 1 deletion server/update-allow-tags-branches 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# An example hook script to blocks unannotated tags from entering.
# Called by git-receive-pack with arguments: refname sha1-old sha1-new
Expand Down
2 changes: 1 addition & 1 deletion server/update-ensure-follows 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# When updating a branch, ensure it has the latest changes
# from other branches, e.g. stable.
Expand Down
2 changes: 1 addition & 1 deletion server/update-ensure-ticket-reference 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

. $(dirname $0)/functions

Expand Down
2 changes: 1 addition & 1 deletion server/update-lock-check 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
#
# Checks $GIT_DIR/locked and $GIT_DIR/preserved for branches that cannot be
Expand Down
2 changes: 1 addition & 1 deletion server/update-stable 100644 → 100755
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

#
# This enforces stable moving in approved ways.
Expand Down
2 changes: 1 addition & 1 deletion server/update.sample
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

/srv/git/gc/server/update-one $1 $2 $3 &&
/srv/git/gc/server/update-two $1 $2 $3
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile
Expand Up @@ -10,7 +10,7 @@ T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
all: $(T) clean

$(T):
@echo "*** $@ ***"; GIT_CONFIG=.git/config /bin/sh $@ $(GIT_TEST_OPTS)
@echo "*** $@ ***"; GIT_CONFIG=.git/config /bin/bash $@ $(GIT_TEST_OPTS)

clean:
rm -fr 'trash directory'
Expand Down
2 changes: 1 addition & 1 deletion tests/t1000-commit-msg-trac.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

test_description='client commit-msg trac ticket enforcer'

Expand Down
2 changes: 1 addition & 1 deletion tests/t1001-commit-msg-trac-merges.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

test_description='client commit-msg trac ticket enforcer for merges'

Expand Down
8 changes: 4 additions & 4 deletions tests/t2000-update-ensure-ticket-reference.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

test_description='server update trac ticket enforcer'

Expand All @@ -8,9 +8,9 @@ test_expect_success 'setup' '
echo This is a test. >a &&
git add a &&
git commit -m "a" &&
git clone ./. server &&
rm -fr server/.git/hooks &&
git remote add origin ./server &&
git clone --bare -l ./ server.git &&
rm -fr server.git/hooks &&
git remote add origin ./server.git &&
git config --add branch.master.remote origin &&
git config --add branch.master.merge refs/heads/master
'
Expand Down
2 changes: 1 addition & 1 deletion tests/t2001-update-ensure-ticket-reference-merges.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

test_description='server update trac ticket enforcer via shim'

Expand Down
10 changes: 5 additions & 5 deletions tests/t2002-update-ensure-ticket-reference-branches.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

test_description='server update trac ticket enforcer via shim'

Expand All @@ -8,9 +8,9 @@ test_expect_success 'setup' '
echo "setup" >a &&
git add a &&
git commit -m "setup" &&
git clone ./. server &&
rm -fr server/.git/hooks &&
git remote add origin ./server &&
git clone -l . --bare server.git &&
rm -fr server.git/hooks &&
git remote add origin ./server.git &&
git config --add branch.master.remote origin &&
git config --add branch.master.merge refs/heads/master
'
Expand Down Expand Up @@ -75,7 +75,7 @@ test_expect_success 'accept branch that has been excused' '
! git push origin topic5
cd server
cd server.git
git config hooks.update-ensure-ticket-reference.excused topic5
cd ..
Expand Down
10 changes: 5 additions & 5 deletions tests/t2100-update-stable.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

test_description='server update stable enforcer'

Expand All @@ -8,9 +8,9 @@ test_expect_success 'setup' '
echo setup >a &&
git add a &&
git commit -m "a" &&
git clone ./. server &&
git remote add origin ./server &&
rm -fr server/.git/hooks
git clone -l . --bare server.git &&
git remote add origin ./server.git &&
rm -fr server.git/hooks
'

# setup the update hook
Expand Down Expand Up @@ -47,7 +47,7 @@ test_expect_success 'reject fast-forward to candidate branch' '
git checkout stable &&
git merge topic1 >merge.out &&
cat merge.out | grep "Fast forward" &&
cat merge.out | grep "Fast-forward" &&
! git push 2>push.err &&
cat push.err | grep "Moving stable must entail a single commit" &&
git reset --hard ORIG_HEAD
Expand Down
18 changes: 9 additions & 9 deletions tests/t2200-post-receive-email.sh
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

test_description='server post-receive email notification'

Expand All @@ -10,14 +10,14 @@ test_expect_success 'setup' '
echo "setup" >a &&
git add a &&
git commit -m "setup" &&
git clone ./. server &&
rm -fr server/.git/hooks &&
git remote add origin ./server &&
git clone -l . --bare server.git &&
rm -fr server.git/hooks &&
git remote add origin ./server.git &&
git config branch.master.remote origin &&
git config branch.master.merge refs/heads/master &&
GIT_DIR=./server/.git git config hooks.post-receive-email.mailinglist commits@list.com &&
GIT_DIR=./server/.git git config hooks.post-receive-email.debug true &&
echo cbas >./server/.git/description
GIT_DIR=./server.git git config hooks.post-receive-email.mailinglist commits@list.com &&
GIT_DIR=./server.git git config hooks.post-receive-email.debug true &&
echo cbas >./server.git/description
'

install_post_receive_hook 'post-receive-email'
Expand All @@ -34,7 +34,7 @@ test_expect_success 'simple commit' '
new_commit_abbrev=$(git rev-parse --short HEAD) &&
interpolate ../t2200-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_date new_commit_abbrev &&
test_cmp 1.txt server/.git/refs.heads.master.out
test_cmp 1.txt server.git/refs.heads.master.out
'

test_expect_success 'simple commit with commitnumber' '
Expand All @@ -51,7 +51,7 @@ test_expect_success 'simple commit with commitnumber' '
new_commit_abbrev=$(git rev-parse --short HEAD) &&
interpolate ../t2200-2.txt 2.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_date new_commit_abbrev &&
test_cmp 2.txt server/.git/refs.heads.master.out
test_cmp 2.txt server.git/refs.heads.master.out
'

test_done
Expand Down
2 changes: 0 additions & 2 deletions tests/t2201-8.txt
Expand Up @@ -11,8 +11,6 @@ The annotated tag, 2.0 has been deleted

-----------------------------------------------------------------------
tag 2.0
Tagger: C O Mitter <committer@example.com>
Date: $old_tag_date

2.0
$new_commit_hash force update annotated tag
Expand Down

0 comments on commit 4aca6f6

Please sign in to comment.