]>
Commit | Line | Data |
---|---|---|
b02e8595 DT |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2015 Twitter, Inc | |
4 | # | |
5 | ||
6 | test_description='Test merging of notes trees in multiple worktrees' | |
7 | ||
d6c6b108 | 8 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
9 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
10 | ||
ca089724 | 11 | TEST_PASSES_SANITIZE_LEAK=true |
b02e8595 DT |
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' ' | |
d6c6b108 JS |
43 | git worktree add -b newbranch worktree main && |
44 | git worktree add -b newbranch2 worktree2 main | |
b02e8595 DT |
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 && | |
2f566d66 HWN |
50 | echo "refs/notes/y" >expect && |
51 | git symbolic-ref NOTES_MERGE_REF >actual && | |
52 | test_cmp expect actual | |
b02e8595 DT |
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 && | |
6789275d | 60 | test_grep "a notes merge into refs/notes/y is already in-progress at" err |
b02e8595 | 61 | ) && |
2f566d66 | 62 | test_must_fail git -C worktree symbolic-ref NOTES_MERGE_REF |
b02e8595 DT |
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 && | |
89b9e31d | 69 | test_must_fail git notes merge z >out 2>&1 && |
6789275d | 70 | test_grep "Automatic notes merge failed" out && |
b02e8595 DT |
71 | grep -v "A notes merge into refs/notes/x is already in-progress in" out |
72 | ) && | |
2f566d66 HWN |
73 | echo "refs/notes/x" >expect && |
74 | git -C worktree2 symbolic-ref NOTES_MERGE_REF >actual && | |
75 | test_cmp expect actual | |
b02e8595 DT |
76 | ' |
77 | ||
78 | test_done |