1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-25 19:26:38 +02:00
git/t/t5402-post-merge-hook.sh
Johannes Schindelin 966b4be276 t5[0-4]*: adjust the references to the default branch name "main"
Carefully excluding t5310, which is developed independently of the
current patch series at the time of writing, we now use `main` as
default branch in t5[0-4]*. This trick was performed via

	$ (cd t &&
	   sed -i -e 's/master/main/g' -e 's/MASTER/MAIN/g' \
		-e 's/Master/Main/g' -- t5[0-4]*.sh &&
	   git checkout HEAD -- t5310\*)

This allows us to define `GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main`
for those tests.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-11-19 15:44:18 -08:00

60 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
#
# Copyright (c) 2006 Josh England
#
test_description='Test the post-merge hook.'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
echo Data for commit0. >a &&
git update-index --add a &&
tree0=$(git write-tree) &&
commit0=$(echo setup | git commit-tree $tree0) &&
echo Changed data for commit1. >a &&
git update-index a &&
tree1=$(git write-tree) &&
commit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&
git update-ref refs/heads/main $commit0 &&
git clone ./. clone1 &&
GIT_DIR=clone1/.git git update-index --add a &&
git clone ./. clone2 &&
GIT_DIR=clone2/.git git update-index --add a
'
for clone in 1 2; do
cat >clone${clone}/.git/hooks/post-merge <<'EOF'
#!/bin/sh
echo $@ >> $GIT_DIR/post-merge.args
EOF
chmod u+x clone${clone}/.git/hooks/post-merge
done
test_expect_success 'post-merge does not run for up-to-date ' '
GIT_DIR=clone1/.git git merge $commit0 &&
! test -f clone1/.git/post-merge.args
'
test_expect_success 'post-merge runs as expected ' '
GIT_DIR=clone1/.git git merge $commit1 &&
test -e clone1/.git/post-merge.args
'
test_expect_success 'post-merge from normal merge receives the right argument ' '
grep 0 clone1/.git/post-merge.args
'
test_expect_success 'post-merge from squash merge runs as expected ' '
GIT_DIR=clone2/.git git merge --squash $commit1 &&
test -e clone2/.git/post-merge.args
'
test_expect_success 'post-merge from squash merge receives the right argument ' '
grep 1 clone2/.git/post-merge.args
'
test_done