3 test_description
='test tg merge setup behavior
5 All non-read-only tg commands set up the merge configuration as well
6 as the pre-commit hook and repository attributes. This is called
9 Make sure it works properly in a top-level as well as subdirectory.
10 It probably should not work in a bare repo but it does so test that too.
12 The Git 2.5+ worktree stuff also throws a wrench into things.
19 if vcmp
"$git_version" '>=' "2.5"; then
20 test_set_prereq GIT_2_5
23 if vcmp
"$git_version" '>=' "2.9"; then
24 test_set_prereq GIT_2_9
29 # Note that the initial branch name in bare.git does
30 # not affect these tests in any way
31 test_expect_success
'test setup' '
32 git init --bare --quiet --template="$EMPTY_DIRECTORY" bare.git &&
33 test_create_repo r1 &&
34 test_create_repo r2 &&
36 test_create_repo r3 &&
37 (cd r3 && test_commit initial) &&
38 test_create_repo r4 &&
40 (cd r4 && test_commit initial)
43 test_expect_success GIT_2_5
'test setup worktrees' '
44 git -C r3 worktree add "$PWD/w3" >/dev/null 2>&1 &&
45 git -C r4 worktree add "$PWD/w4" >/dev/null 2>&1 &&
49 test_expect_success GIT_2_9
'test setup hookspath' '
50 test_create_repo hooksrepo &&
52 git -C hooksrepo config core.hooksPath "$PWD/hookspath"
55 test_tolerate_failure GIT_2_5
'rev-parse --git-common-dir is not broken' '
56 gcd="$(cd r2/subdir && git rev-parse --git-common-dir)" &&
61 test "$(cd r2/subdir && cd "$gcd" && pwd -P)" = "$(cd r2/.git && pwd -P)"
65 test -n "$(git -C "$1" config --get merge.ours.name)" &&
66 test -n "$(git -C "$1" config --get merge.ours.driver)" &&
67 test -s "$1/info/attributes" &&
68 test -s "${2:-$1/hooks}/pre-commit" &&
69 test -f "${2:-$1/hooks}/pre-commit" &&
70 test -x "${2:-$1/hooks}/pre-commit" &&
71 grep -q .topmsg
"$1/info/attributes" &&
72 grep -q .topdeps
"$1/info/attributes" &&
73 grep -q -- --hooks-path "${2:-$1/hooks}/pre-commit"
77 test_might_fail tg
-C "$1" update no-such-branch-name
>/dev
/null
2>&1
80 test_expect_success
'no bare mergesetup' '
81 test_must_fail mergesetup_is_ok bare.git &&
82 do_mergesetup bare.git &&
83 test_must_fail mergesetup_is_ok bare.git
86 test_expect_success
'mergesetup normal top level' '
87 test_must_fail mergesetup_is_ok r1/.git &&
89 mergesetup_is_ok r1/.git
92 test_expect_success
'mergesetup normal subdir' '
93 test_must_fail mergesetup_is_ok r2/.git &&
94 do_mergesetup r2/subdir &&
95 mergesetup_is_ok r2/.git
98 test_expect_success GIT_2_5
'mergesetup worktree top level' '
99 test_must_fail mergesetup_is_ok r3/.git &&
101 mergesetup_is_ok r3/.git
104 test_expect_success GIT_2_5
'mergesetup worktree subdir' '
105 test_must_fail mergesetup_is_ok r4/.git &&
106 do_mergesetup w4/subdir &&
107 mergesetup_is_ok r4/.git
110 test_expect_success GIT_2_9
'mergesetup hookspath' '
111 test_must_fail mergesetup_is_ok hooksrepo/.git hookspath &&
112 do_mergesetup hooksrepo &&
113 mergesetup_is_ok hooksrepo/.git hookspath