Merge branch 'jk/config-blob-sans-repo'
[git.git] / t / t3320-notes-merge-worktrees.sh
blob10bfc8b94710caf8d33a3a1fa66ad3a4ba394c0f
1 #!/bin/sh
3 # Copyright (c) 2015 Twitter, Inc
6 test_description='Test merging of notes trees in multiple worktrees'
8 . ./test-lib.sh
10 test_expect_success 'setup commit' '
11 test_commit tantrum
14 commit_tantrum=$(git rev-parse tantrum^{commit})
16 test_expect_success 'setup notes ref (x)' '
17 git config core.notesRef refs/notes/x &&
18 git notes add -m "x notes on tantrum" tantrum
21 test_expect_success 'setup local branch (y)' '
22 git update-ref refs/notes/y refs/notes/x &&
23 git config core.notesRef refs/notes/y &&
24 git notes remove tantrum
27 test_expect_success 'setup remote branch (z)' '
28 git update-ref refs/notes/z refs/notes/x &&
29 git config core.notesRef refs/notes/z &&
30 git notes add -f -m "conflicting notes on tantrum" tantrum
33 test_expect_success 'modify notes ref ourselves (x)' '
34 git config core.notesRef refs/notes/x &&
35 git notes add -f -m "more conflicting notes on tantrum" tantrum
38 test_expect_success 'create some new worktrees' '
39 git worktree add -b newbranch worktree master &&
40 git worktree add -b newbranch2 worktree2 master
43 test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
44 git config core.notesRef refs/notes/y &&
45 test_must_fail git notes merge z &&
46 echo "ref: refs/notes/y" >expect &&
47 test_cmp .git/NOTES_MERGE_REF expect
50 test_expect_success 'merge z into y while mid-merge in another workdir fails' '
52 cd worktree &&
53 git config core.notesRef refs/notes/y &&
54 test_must_fail git notes merge z 2>err &&
55 test_i18ngrep "a notes merge into refs/notes/y is already in-progress at" err
56 ) &&
57 test_path_is_missing .git/worktrees/worktree/NOTES_MERGE_REF
60 test_expect_success 'merge z into x while mid-merge on y succeeds' '
62 cd worktree2 &&
63 git config core.notesRef refs/notes/x &&
64 test_must_fail git notes merge z >out 2>&1 &&
65 test_i18ngrep "Automatic notes merge failed" out &&
66 grep -v "A notes merge into refs/notes/x is already in-progress in" out
67 ) &&
68 echo "ref: refs/notes/x" >expect &&
69 test_cmp .git/worktrees/worktree2/NOTES_MERGE_REF expect
72 test_done