]>
Commit | Line | Data |
---|---|---|
46232915 JE |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Josh England | |
4 | # | |
5 | ||
6 | test_description='Test the post-merge hook.' | |
966b4be2 | 7 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
8 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
9 | ||
3e3b9321 | 10 | TEST_PASSES_SANITIZE_LEAK=true |
46232915 JE |
11 | . ./test-lib.sh |
12 | ||
13 | test_expect_success setup ' | |
14 | echo Data for commit0. >a && | |
15 | git update-index --add a && | |
16 | tree0=$(git write-tree) && | |
17 | commit0=$(echo setup | git commit-tree $tree0) && | |
18 | echo Changed data for commit1. >a && | |
19 | git update-index a && | |
20 | tree1=$(git write-tree) && | |
21 | commit1=$(echo modify | git commit-tree $tree1 -p $commit0) && | |
966b4be2 | 22 | git update-ref refs/heads/main $commit0 && |
3604e7c5 | 23 | git clone ./. clone1 && |
46232915 | 24 | GIT_DIR=clone1/.git git update-index --add a && |
3604e7c5 | 25 | git clone ./. clone2 && |
46232915 JE |
26 | GIT_DIR=clone2/.git git update-index --add a |
27 | ' | |
28 | ||
60a8a6bf ÆAB |
29 | test_expect_success 'setup clone hooks' ' |
30 | test_when_finished "rm -f hook" && | |
31 | cat >hook <<-\EOF && | |
32 | echo $@ >>$GIT_DIR/post-merge.args | |
33 | EOF | |
34 | ||
35 | test_hook --setup -C clone1 post-merge <hook && | |
36 | test_hook --setup -C clone2 post-merge <hook | |
37 | ' | |
46232915 | 38 | |
41ac414e | 39 | test_expect_success 'post-merge does not run for up-to-date ' ' |
739edb2a | 40 | GIT_DIR=clone1/.git git merge $commit0 && |
41ac414e | 41 | ! test -f clone1/.git/post-merge.args |
46232915 JE |
42 | ' |
43 | ||
44 | test_expect_success 'post-merge runs as expected ' ' | |
739edb2a | 45 | GIT_DIR=clone1/.git git merge $commit1 && |
46232915 JE |
46 | test -e clone1/.git/post-merge.args |
47 | ' | |
48 | ||
49 | test_expect_success 'post-merge from normal merge receives the right argument ' ' | |
739edb2a | 50 | grep 0 clone1/.git/post-merge.args |
46232915 JE |
51 | ' |
52 | ||
53 | test_expect_success 'post-merge from squash merge runs as expected ' ' | |
739edb2a | 54 | GIT_DIR=clone2/.git git merge --squash $commit1 && |
46232915 JE |
55 | test -e clone2/.git/post-merge.args |
56 | ' | |
57 | ||
58 | test_expect_success 'post-merge from squash merge receives the right argument ' ' | |
739edb2a | 59 | grep 1 clone2/.git/post-merge.args |
46232915 JE |
60 | ' |
61 | ||
62 | test_done |