oidtree: avoid nested struct oidtree_node
[git/debian.git] / t / t3320-notes-merge-worktrees.sh
blob052516e6c6ab9d6f78e289d0339f8192379bad98
1 #!/bin/sh
3 # Copyright (c) 2015 Twitter, Inc
6 test_description='Test merging of notes trees in multiple worktrees'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
11 . ./test-lib.sh
13 test_expect_success 'setup commit' '
14 test_commit tantrum
17 commit_tantrum=$(git rev-parse tantrum^{commit})
19 test_expect_success 'setup notes ref (x)' '
20 git config core.notesRef refs/notes/x &&
21 git notes add -m "x notes on tantrum" tantrum
24 test_expect_success 'setup local branch (y)' '
25 git update-ref refs/notes/y refs/notes/x &&
26 git config core.notesRef refs/notes/y &&
27 git notes remove tantrum
30 test_expect_success 'setup remote branch (z)' '
31 git update-ref refs/notes/z refs/notes/x &&
32 git config core.notesRef refs/notes/z &&
33 git notes add -f -m "conflicting notes on tantrum" tantrum
36 test_expect_success 'modify notes ref ourselves (x)' '
37 git config core.notesRef refs/notes/x &&
38 git notes add -f -m "more conflicting notes on tantrum" tantrum
41 test_expect_success 'create some new worktrees' '
42 git worktree add -b newbranch worktree main &&
43 git worktree add -b newbranch2 worktree2 main
46 test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
47 git config core.notesRef refs/notes/y &&
48 test_must_fail git notes merge z &&
49 echo "ref: refs/notes/y" >expect &&
50 test_cmp expect .git/NOTES_MERGE_REF
53 test_expect_success 'merge z into y while mid-merge in another workdir fails' '
55 cd worktree &&
56 git config core.notesRef refs/notes/y &&
57 test_must_fail git notes merge z 2>err &&
58 test_i18ngrep "a notes merge into refs/notes/y is already in-progress at" err
59 ) &&
60 test_path_is_missing .git/worktrees/worktree/NOTES_MERGE_REF
63 test_expect_success 'merge z into x while mid-merge on y succeeds' '
65 cd worktree2 &&
66 git config core.notesRef refs/notes/x &&
67 test_must_fail git notes merge z >out 2>&1 &&
68 test_i18ngrep "Automatic notes merge failed" out &&
69 grep -v "A notes merge into refs/notes/x is already in-progress in" out
70 ) &&
71 echo "ref: refs/notes/x" >expect &&
72 test_cmp expect .git/worktrees/worktree2/NOTES_MERGE_REF
75 test_done