-#!/bin/sh
+#!/bin/bash
#
# Makes checkout "just work" in terms of checking out the branch whether or not
# it exists locally or remotely.
-#!/bin/sh
+#!/bin/bash
#
# Creates a separate DAG in your repo for git config files.
#
-#!/bin/sh
+#!/bin/bash
#
# Makes pull "just work" by correctly rebasing of local commits on top of new
# incoming commits.
-#!/bin/sh
+#!/bin/bash
#
# Makes push "just work" by only pushing the current branch to origin.
#
-#!/bin/sh
+#!/bin/bash
#
# Goes through the ensure-follows branches and makes sure
-#!/bin/sh
+#!/bin/bash
# Sets: new_commits
# Assumes: $oldrev $newrev $refname
# "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
# 0000->1234 (create)
# 1234->2345 (update)
# 2345->0000 (delete)
-function set_change_type() {
+set_change_type() {
if [ "$oldrev" == "0000000000000000000000000000000000000000" ] ; then
change_type="create"
else
# 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
# 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"
# 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"
#
# 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
-#!/bin/sh
+#!/bin/bash
#
# Creates commitnumbers as lightweight tags named "r/X" where X increases
# monotonically.
-#!/bin/sh
+#!/bin/bash
#
# Copyright (c) 2007 Andy Parkins
# Copyright (c) 2008 Stephen Haberman
-#!/bin/sh
+#!/bin/bash
#
# Copyright (c) 2008 Stephen Haberman
#
-#!/bin/sh
+#!/bin/bash
#
# Copyright (c) 2008 Stephen Haberman
#
-#!/bin/sh
+#!/bin/bash
. $(dirname $0)/functions
-#!/bin/sh
+#!/bin/bash
nl=$'\n'
input=""
-#!/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
-#!/bin/sh
+#!/bin/bash
#
# When updating a branch, ensure it has the latest changes
# from other branches, e.g. stable.
-#!/bin/sh
+#!/bin/bash
. $(dirname $0)/functions
-#!/bin/sh
+#!/bin/bash
#
#
# Checks $GIT_DIR/locked and $GIT_DIR/preserved for branches that cannot be
-#!/bin/sh
+#!/bin/bash
#
# This enforces stable moving in approved ways.
-#!/bin/sh
+#!/bin/bash
/srv/git/gc/server/update-one $1 $2 $3 &&
/srv/git/gc/server/update-two $1 $2 $3
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'
-#!/bin/sh
+#!/bin/bash
test_description='client commit-msg trac ticket enforcer'
-#!/bin/sh
+#!/bin/bash
test_description='client commit-msg trac ticket enforcer for merges'
-#!/bin/sh
+#!/bin/bash
test_description='server update trac ticket enforcer'
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
'
-#!/bin/sh
+#!/bin/bash
test_description='server update trac ticket enforcer via shim'
-#!/bin/sh
+#!/bin/bash
test_description='server update trac ticket enforcer via shim'
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
'
! git push origin topic5
- cd server
+ cd server.git
git config hooks.update-ensure-ticket-reference.excused topic5
cd ..
-#!/bin/sh
+#!/bin/bash
test_description='server update stable enforcer'
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
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
-#!/bin/sh
+#!/bin/bash
test_description='server post-receive email notification'
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'
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' '
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
-----------------------------------------------------------------------
tag 2.0
-Tagger: C O Mitter <committer@example.com>
-Date: $old_tag_date
2.0
$new_commit_hash force update annotated tag
-#!/bin/sh
+#!/bin/bash
test_description='server post-receive email notification'
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'
eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/1.0) &&
interpolate ../t2201-1.txt 1.txt new_commit_hash tag_hash tag_date &&
- test_cmp 1.txt server/.git/refs.tags.1.0.out
+ test_cmp 1.txt server.git/refs.tags.1.0.out
'
test_expect_success 'commit on annotated tagged branch' '
git push &&
new_commit_abbrev=$(git rev-list -n 1 --pretty=format:%h HEAD | grep -v commit) &&
interpolate ../t2201-2.txt 2.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev prior_commit_hash prior_commit_date old_commit_abbrev prior_commit_abbrev new_commit_abbrev &&
- test_cmp 2.txt server/.git/refs.heads.master.out
+ test_cmp 2.txt server.git/refs.heads.master.out
'
test_expect_success 're-annotated tag branch' '
eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/2.0) &&
interpolate ../t2201-3.txt 3.txt new_commit_hash tag_hash tag_date &&
- test_cmp 3.txt server/.git/refs.tags.2.0.out
+ test_cmp 3.txt server.git/refs.tags.2.0.out
'
test_expect_success 'force update annotated tag' '
eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/2.0) &&
interpolate ../t2201-7.txt 7.txt old_tag_hash new_commit_hash new_tag_hash tag_date &&
- test_cmp 7.txt server/.git/refs.tags.2.0.out
+ test_cmp 7.txt server.git/refs.tags.2.0.out
'
test_expect_success 'delete annotated tag' '
new_commit_hash=$(git rev-parse HEAD) &&
interpolate ../t2201-8.txt 8.txt old_tag_hash old_tag_date new_commit_describe new_commit_hash &&
- test_cmp 8.txt server/.git/refs.tags.2.0.out
+ test_cmp 8.txt server.git/refs.tags.2.0.out
'
test_expect_success 'create lightweight tag' '
new_commit_date=$(git rev-list --no-walk --pretty=format:%ad HEAD | tail -n 1) &&
interpolate ../t2201-4.txt 4.txt new_commit_hash new_commit_describe new_commit_date &&
- test_cmp 4.txt server/.git/refs.tags.2.1.out
+ test_cmp 4.txt server.git/refs.tags.2.1.out
'
test_expect_success 'force update lightweight tag' '
new_commit_date=$(git rev-list --no-walk --pretty=format:%ad HEAD | tail -n 1) &&
interpolate ../t2201-5.txt 5.txt new_commit_hash new_commit_describe new_commit_date old_commit_hash &&
- test_cmp 5.txt server/.git/refs.tags.2.1.out
+ test_cmp 5.txt server.git/refs.tags.2.1.out
'
test_expect_success 'delete lightweight tag' '
git push origin :refs/tags/2.1 &&
interpolate ../t2201-6.txt 6.txt old_commit_hash old_commit_describe &&
- test_cmp 6.txt server/.git/refs.tags.2.1.out
+ test_cmp 6.txt server.git/refs.tags.2.1.out
'
test_done
-#!/bin/sh
+#!/bin/bash
test_description='server post-receive email notification'
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'
git push origin topic &&
interpolate ../t2202-1.txt 1.txt new_commit_hash new_commit_abbrev new_commit_date prior_commit_hash prior_commit_date &&
- test_cmp 1.txt server/.git/refs.heads.topic.out
+ test_cmp 1.txt server.git/refs.heads.topic.out
'
test_expect_success 'create branch with existing commits does not replay them' '
git push origin topic2 &&
interpolate ../t2202-3.txt 3.txt existing_commit_hash existing_commit_abbrev existing_commit_date &&
- test_cmp 3.txt server/.git/refs.heads.topic2.out
+ test_cmp 3.txt server.git/refs.heads.topic2.out
'
test_expect_success 'update branch with existing commits does not replay them' '
git push &&
interpolate ../t2202-4.txt 4.txt old_commit_hash old_commit_abbrev existing_commit_hash existing_commit_abbrev &&
- test_cmp 4.txt server/.git/refs.heads.topic.out
+ test_cmp 4.txt server.git/refs.heads.topic.out
'
test_expect_success 'rewind branch' '
new_commit_hash=$(git rev-parse HEAD) &&
interpolate ../t2202-5.txt 5.txt old_commit_hash new_commit_hash old_commit_abbrev &&
- test_cmp 5.txt server/.git/refs.heads.topic.out
+ test_cmp 5.txt server.git/refs.heads.topic.out
'
test_expect_success 'rewind and continue branch' '
git push --force &&
interpolate ../t2202-6.txt 6.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev old_commit_abbrev &&
- test_cmp 6.txt server/.git/refs.heads.topic.out
+ test_cmp 6.txt server.git/refs.heads.topic.out
'
test_expect_success 'delete branch' '
git push origin :refs/heads/topic &&
interpolate ../t2202-2.txt 2.txt old_commit_hash &&
- test_cmp 2.txt server/.git/refs.heads.topic.out
+ test_cmp 2.txt server.git/refs.heads.topic.out
'
test_done
- Log -----------------------------------------------------------------
commit $new_commit_hash
-Merge: $old_commit_hash $second_stable_hash
+Merge: $old_commit_abbrev $second_stable_abbrev
Author: A U Thor <author@example.com>
Date: $new_commit_date
- Log -----------------------------------------------------------------
commit $new_commit_hash
-Merge: $old_commit_hash $second_stable_hash
+Merge: $old_commit_abbrev $second_stable_abbrev
Author: A U Thor <author@example.com>
Date: $new_commit_date
-#!/bin/sh
+#!/bin/bash
test_description='server post-receive email notification and how it behaves in our stable-based envrionment'
echo "setup" >c &&
git add a b c &&
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 &&
git checkout -b stable &&
git push origin stable
echo "$test_name 2" >b &&
echo "$test_name 2" >c &&
git commit -a -m "move stable 2" &&
- second_stable_hash=$(git rev-parse HEAD) &&
+ second_stable_abbrev=$(git rev-parse --short HEAD) &&
git push origin stable &&
# Merge stable
new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
new_commit_abbrev=$(git rev-parse --short HEAD) &&
- interpolate ../t2203-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date first_stable_hash second_stable_hash &&
- test_cmp 1.txt server/.git/refs.heads.topic1.out
+ interpolate ../t2203-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date first_stable_hash second_stable_abbrev &&
+ test_cmp 1.txt server.git/refs.heads.topic1.out
'
test_expect_success 'merge in stable with conflict' '
echo "$test_name 2" >b &&
echo "$test_name 2" >c &&
git commit -a -m "move stable 2" &&
- second_stable_hash=$(git rev-parse HEAD) &&
+ second_stable_abbrev=$(git rev-parse --short HEAD) &&
git push origin stable &&
# Merge stable
new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
new_commit_abbrev=$(git rev-parse --short HEAD) &&
- interpolate ../t2203-2.txt 2.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date first_stable_hash second_stable_hash &&
- test_cmp 2.txt server/.git/refs.heads.topic1.out
+ interpolate ../t2203-2.txt 2.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date first_stable_hash second_stable_abbrev &&
+ test_cmp 2.txt server.git/refs.heads.topic1.out
'
test_done
- Log -----------------------------------------------------------------
commit $new_commit_hash
-Merge: $old_commit_hash $stable_hash
+Merge: $old_commit_abbrev $stable_abbrev
Author: A U Thor <author@example.com>
Date: $new_commit_date
-#!/bin/sh
+#!/bin/bash
test_description='server post-receive email notification and how it behaves in our stable-based envrionment'
echo "setup" >c &&
git add a b c &&
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 &&
git checkout -b stable &&
git push origin stable
git commit -a -m "lines changed on stable" &&
git push origin stable &&
- stable_hash=$(git rev-parse HEAD) &&
+ stable_abbrev=$(git rev-parse --short HEAD) &&
git checkout topic1 &&
! git merge stable &&
new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
new_commit_abbrev=$(git rev-parse --short HEAD) &&
- interpolate ../t2204-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date stable_hash &&
- test_cmp 1.txt server/.git/refs.heads.topic1.out
+ interpolate ../t2204-1.txt 1.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_abbrev new_commit_date stable_abbrev &&
+ test_cmp 1.txt server.git/refs.heads.topic1.out
'
test_done
-#!/bin/sh
+#!/bin/bash
test_description='server update ensure follows'
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 fetch
'
'
test_expect_success 'branch with unmoved stable is okay' '
- cd server &&
- git config hooks.update-ensure-follows.branches stable &&
- cd .. &&
+ GIT_DIR=server.git git config hooks.update-ensure-follows.branches stable &&
git checkout -b topic1 &&
echo "$test_name" >a.topic1 &&
git push origin stable &&
# Someone fixes stable first
- cd server &&
+ git clone server.git person2 &&
+ cd person2 &&
git checkout -f topic1 &&
- git merge stable &&
+ git remote add server ../server.git &&
+ git merge origin/stable &&
+ git push server topic1 &&
cd .. &&
git checkout topic1 &&
'
test_expect_success 'branch with moved stable as second branch requires merge' '
- cd server &&
- git config hooks.update-ensure-follows.branches "foo stable" &&
- cd .. &&
+ GIT_DIR=server.git git config hooks.update-ensure-follows.branches "foo stable" &&
git checkout stable &&
echo "$test_name" >a &&
git commit -a -m "Change on topic2 again" &&
! git push origin topic2 &&
- cd server &&
- git config hooks.update-ensure-follows.excused topic2 &&
- cd .. &&
+ GIT_DIR=server.git git config hooks.update-ensure-follows.excused topic2 &&
git push origin topic2
'
-#!/bin/sh
+#!/bin/bash
test_description='server update git config'
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 fetch
install_post_receive_hook 'post-receive-gitconfig'
test_expect_success 'pushing initial value works' '
- cd server &&
- ! git config --list | grep foo &&
- cd .. &&
+ ! GIT_DIR=server.git git config --list | grep foo &&
../../scripts/create-gitconfig &&
git checkout gitconfig &&
git commit -a -m "Set foo.foo=bar."
git push origin gitconfig
- cd server &&
- git config --list | grep foo &&
- cd ..
+ GIT_DIR=server.git git config --list | grep foo
'
test_expect_success 'pushing locked works' '
- ! test -f server/.git/locked &&
+ ! test -f server.git/locked &&
git checkout gitconfig &&
echo "foo" > locked &&
git commit -m "Add locked"
git push origin gitconfig
- test -f server/.git/locked
+ test -f server.git/locked
'
test_done
-#!/bin/sh
+#!/bin/bash
test_description='server update git config'
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
'
install_post_receive_hook 'post-receive-gitconfig'
test_expect_success 'adding hook' '
- ls server/.git/hooks | grep post-receive &&
+ ls server.git/hooks | grep post-receive &&
../../scripts/create-gitconfig &&
git checkout gitconfig &&
mkdir hooks &&
cd hooks &&
- echo "#!/bin/sh" > post-receive &&
- echo "../../../../server/post-receive-gitconfig" >> post-receive &&
+ echo "#!/bin/bash" > post-receive &&
+ echo "../../../server/post-receive-gitconfig" >> post-receive &&
echo "echo barbar" >> post-receive &&
- echo "#!/bin/sh" > update &&
+ echo "#!/bin/bash" > update &&
echo "echo foofoo" >> update &&
git add post-receive &&
git add update &&
git push origin gitconfig &&
cd .. &&
- cat server/.git/hooks/post-receive | grep barbar &&
- cat server/.git/hooks/update | grep foofoo
+ cat server.git/hooks/post-receive | grep barbar &&
+ cat server.git/hooks/update | grep foofoo
'
test_expect_success 'changing hook' '
- echo "#!/bin/sh" > hooks/update &&
+ echo "#!/bin/bash" > hooks/update &&
echo "echo lala" >> hooks/update &&
git commit -a -m "changed update" &&
git push origin gitconfig &&
- cat server/.git/hooks/post-receive | grep barbar &&
- ! cat server/.git/hooks/update | grep barbar &&
- cat server/.git/hooks/update | grep lala
+ cat server.git/hooks/post-receive | grep barbar &&
+ ! cat server.git/hooks/update | grep barbar &&
+ cat server.git/hooks/update | grep lala
'
test_expect_success 'removing hook does not work' '
git commit -m "removed update" &&
git push origin gitconfig &&
- ls server/.git/hooks | grep post-receive
- ls server/.git/hooks | grep update
+ ls server.git/hooks | grep post-receive
+ ls server.git/hooks | grep update
'
test_done
-#!/bin/sh
+#!/bin/bash
test_description='server update lock check'
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 fetch
install_update_hook 'update-lock-check'
test_expect_success 'locked branch is rejected' '
- echo master >> server/.git/locked &&
+ echo master >> server.git/locked &&
echo "$test_name" >a &&
git commit -a -m "changed" &&
'
test_expect_success 'locked branch is rejected with multiple branches set' '
- echo foo >> server/.git/locked &&
- echo bar >> server/.git/locked &&
+ echo foo >> server.git/locked &&
+ echo bar >> server.git/locked &&
echo "$test_name" >a &&
git commit -a -m "changed" &&
'
test_expect_success 'preserved branch cannot be deleted' '
- echo > server/.git/locked &&
- echo master > server/.git/preserved &&
+ echo > server.git/locked &&
+ git push origin master:master2 &&
+ echo master2 > server.git/preserved &&
- ! git push origin :master 2>push.err &&
- cat push.err | grep "Branch master cannot be deleted"
+ ! git push origin :master2 2>push.err &&
+ cat push.err | grep "Branch master2 cannot be deleted"
'
test_done
-#!/bin/sh
+#!/bin/bash
test_description='server update lock check'
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
'
install_post_receive_hook 'post-receive-trac'
-#!/bin/sh
+#!/bin/bash
test_description='server post receive trac with commit numbers'
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
'
install_post_receive_hook 'post-receive-commitnumbers' 'post-receive-trac'
-#!/bin/sh
+#!/bin/bash
test_description='server update allow tags and branches'
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
'
install_update_hook 'update-allow-tags-branches'
'
test_expect_success 'moving branch back and deleting tag works' '
- GIT_DIR=./server/.git git config hooks.update-allow-tags-branches.deletetag true
+ GIT_DIR=./server.git git config hooks.update-allow-tags-branches.deletetag true
git reset --hard HEAD^ &&
git push --force origin master:master :r2
'
-#!/bin/sh
+#!/bin/bash
test_description='server assign commit numbers'
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 fetch
test "$(git rev-parse HEAD)" = "$(git rev-parse r/1)" &&
test "$(git describe --tags)" = "r/1" &&
- test "$(git rev-parse HEAD) refs/heads/master" = "$(cat server/.git/commitnumbers)"
+ test "$(git rev-parse HEAD) refs/heads/master" = "$(cat server.git/commitnumbers)"
'
test_expect_success 'assign two new commits' '
-#!/bin/sh
+#!/bin/bash
test_description='script checkout'
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 checkout -b stable &&
git push origin stable
'
test_expect_success 'checkout a new branch clones stable' '
- gc-checkout topic1 &&
+ checkout topic1 &&
git branch | grep topic1 &&
git branch -r | grep origin/topic1 &&
git config --list | grep "branch.topic1.merge=refs/heads/topic1"
'
test_expect_success 'checkout an existing remote branch' '
- cd server &&
- git checkout -b topic2 stable &&
+ git clone server.git person2 &&
+ cd person2 &&
+ git checkout -b topic2 origin/stable &&
echo "$test_name on server" >a &&
git commit -a -m "Made topic2 on server" &&
+ git push origin topic2
cd .. &&
! git branch | grep topic2 &&
- gc-checkout topic2 &&
+ checkout topic2 &&
git branch | grep topic2 &&
git branch -r | grep origin/topic2 &&
git config --list | grep "branch.topic2.merge=refs/heads/topic2" &&
'
test_expect_success 'checkout an existing local branch' '
- gc-checkout topic1
+ checkout topic1
'
test_expect_success 'checkout a revision does not create a new branch' '
git commit -a -m "$test_name" &&
prior=$(git rev-parse HEAD^) &&
- gc-checkout $prior &&
+ checkout $prior &&
git branch | grep "no branch"
'
-#!/bin/sh
+#!/bin/bash
test_description='script create branch'
-#!/bin/sh
+#!/bin/bash
test_description='script pull'
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 checkout -b stable &&
git push origin stable
'
git commit -m "move topic1" &&
# Move topic1 on the server
- cd server &&
+ git clone server.git person2 &&
+ cd person2 &&
git checkout topic1 &&
echo "$test_name" >a &&
git commit -a -m "move topic1 on the server" &&
+ git push origin &&
cd .. &&
# Only one parent
git merge stable &&
# Move topic2 on the server
- cd server &&
- git checkout topic2 &&
+ cd person2 &&
+ git fetch &&
+ git checkout -b topic2 origin/topic2 &&
echo "$test_name" >a.topic2.server &&
git add a.topic2.server &&
git commit -m "move topic2 on the server" &&
+ git push origin &&
cd .. &&
# Merge stable locally too--should conflict
git checkout topic2 &&
# Move topic2 on the server
- cd server &&
- git checkout topic2 &&
+ cd person2 &&
+ git pull &&
echo "$test_name" > a.topic2.server &&
git commit -a -m "move topic2 on the server" &&
+ git push origin &&
cd .. &&
pull &&
-#!/bin/sh
+#!/bin/bash
test_description='script refollow'
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 checkout -b stable &&
git push origin stable
'
test_expect_success 'setup gitconfig' '
- make-gitconfig-branch &&
+ create-gitconfig &&
git checkout gitconfig &&
echo "hooks.update-ensure-follows.branches=stable" >>config &&
echo "hooks.update-ensure-follows.excused=master gitconfig" >>config &&
-#!/bin/sh
+#!/bin/bash
test_description='sanity check of commands listed in GitNotes'
-#!/bin/sh
+#!/bin/bash
#
# Copyright (c) 2005 Junio C Hamano
#
# - not all diff versions understand "-u"
test_cmp() {
+ echo "t=${GIT_TEST_CMP}"
$GIT_TEST_CMP "$@"
}
}
install_server_hook () {
- mkdir -p "server/.git/hooks"
- cp "../../server/$1" "server/.git/hooks/$2"
- chmod +x "server/.git/hooks/$2"
+ mkdir -p "server.git/hooks"
+ cp "../../server.git/$1" "server.git/hooks/$2"
+ chmod +x "server.git/hooks/$2"
}
install_update_hook () {
- mkdir -p "server/.git/hooks"
- hook="server/.git/hooks/update"
+ mkdir -p "server.git/hooks"
+ hook="server.git/hooks/update"
- echo "#!/bin/sh" >$hook
+ echo "#!/bin/bash" >$hook
for ((i=1;i<=$#;i+=1)); do
eval script_name="$"$i
- echo "../../../../server/$script_name \$1 \$2 \$3 &&" >>$hook
+ echo "../../../server/$script_name \$1 \$2 \$3 &&" >>$hook
done
echo "echo >/dev/null" >>$hook
}
install_post_receive_hook () {
- mkdir -p "server/.git/hooks"
- hook="server/.git/hooks/post-receive"
+ mkdir -p "server.git/hooks"
+ hook="server.git/hooks/post-receive"
cat >$hook <<-'EOF'
- #!/bin/sh
+ #!/bin/bash
nl=$'\n'
input=""
while read newref oldref refname ; do
for ((i=1;i<=$#;i+=1)); do
eval script_name="$"$i
- echo "echo -n \"\$input\" | ../../../../server/$script_name" >>$hook
+ echo "echo -n \"\$input\" | ../../../server/$script_name" >>$hook
done
chmod +x $hook