]> git.ipfire.org Git - thirdparty/git.git/blob - t/t3320-notes-merge-worktrees.sh
The third batch
[thirdparty/git.git] / t / t3320-notes-merge-worktrees.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2015 Twitter, Inc
4 #
5
6 test_description='Test merging of notes trees in multiple worktrees'
7
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
11 TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
13
14 test_expect_success 'setup commit' '
15 test_commit tantrum
16 '
17
18 commit_tantrum=$(git rev-parse tantrum^{commit})
19
20 test_expect_success 'setup notes ref (x)' '
21 git config core.notesRef refs/notes/x &&
22 git notes add -m "x notes on tantrum" tantrum
23 '
24
25 test_expect_success 'setup local branch (y)' '
26 git update-ref refs/notes/y refs/notes/x &&
27 git config core.notesRef refs/notes/y &&
28 git notes remove tantrum
29 '
30
31 test_expect_success 'setup remote branch (z)' '
32 git update-ref refs/notes/z refs/notes/x &&
33 git config core.notesRef refs/notes/z &&
34 git notes add -f -m "conflicting notes on tantrum" tantrum
35 '
36
37 test_expect_success 'modify notes ref ourselves (x)' '
38 git config core.notesRef refs/notes/x &&
39 git notes add -f -m "more conflicting notes on tantrum" tantrum
40 '
41
42 test_expect_success 'create some new worktrees' '
43 git worktree add -b newbranch worktree main &&
44 git worktree add -b newbranch2 worktree2 main
45 '
46
47 test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
48 git config core.notesRef refs/notes/y &&
49 test_must_fail git notes merge z &&
50 echo "refs/notes/y" >expect &&
51 git symbolic-ref NOTES_MERGE_REF >actual &&
52 test_cmp expect actual
53 '
54
55 test_expect_success 'merge z into y while mid-merge in another workdir fails' '
56 (
57 cd worktree &&
58 git config core.notesRef refs/notes/y &&
59 test_must_fail git notes merge z 2>err &&
60 test_grep "a notes merge into refs/notes/y is already in-progress at" err
61 ) &&
62 test_must_fail git -C worktree symbolic-ref NOTES_MERGE_REF
63 '
64
65 test_expect_success 'merge z into x while mid-merge on y succeeds' '
66 (
67 cd worktree2 &&
68 git config core.notesRef refs/notes/x &&
69 test_must_fail git notes merge z >out 2>&1 &&
70 test_grep "Automatic notes merge failed" out &&
71 grep -v "A notes merge into refs/notes/x is already in-progress in" out
72 ) &&
73 echo "refs/notes/x" >expect &&
74 git -C worktree2 symbolic-ref NOTES_MERGE_REF >actual &&
75 test_cmp expect actual
76 '
77
78 test_done