interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t3320-notes-merge-worktrees.sh

77 lines · 2173 bytes Raw Blame History
1#!/bin/sh
2#
3# Copyright (c) 2015 Twitter, Inc
4#
5
6test_description='Test merging of notes trees in multiple worktrees'
7
8GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
11. ./test-lib.sh
12
13test_expect_success 'setup commit' '
14 test_commit tantrum
15'
16
17commit_tantrum=$(git rev-parse tantrum^{commit})
18
19test_expect_success 'setup notes ref (x)' '
20 git config core.notesRef refs/notes/x &&
21 git notes add -m "x notes on tantrum" tantrum
22'
23
24test_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
28'
29
30test_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
34'
35
36test_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
39'
40
41test_expect_success 'create some new worktrees' '
42 git worktree add -b newbranch worktree main &&
43 git worktree add -b newbranch2 worktree2 main
44'
45
46test_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 "refs/notes/y" >expect &&
50 git symbolic-ref NOTES_MERGE_REF >actual &&
51 test_cmp expect actual
52'
53
54test_expect_success 'merge z into y while mid-merge in another workdir fails' '
55 (
56 cd worktree &&
57 git config core.notesRef refs/notes/y &&
58 test_must_fail git notes merge z 2>err &&
59 test_grep "a notes merge into refs/notes/y is already in-progress at" err
60 ) &&
61 test_must_fail git -C worktree symbolic-ref NOTES_MERGE_REF
62'
63
64test_expect_success 'merge z into x while mid-merge on y succeeds' '
65 (
66 cd worktree2 &&
67 git config core.notesRef refs/notes/x &&
68 test_must_fail git notes merge z >out 2>&1 &&
69 test_grep "Automatic notes merge failed" out &&
70 test_grep -v "A notes merge into refs/notes/x is already in-progress in" out
71 ) &&
72 echo "refs/notes/x" >expect &&
73 git -C worktree2 symbolic-ref NOTES_MERGE_REF >actual &&
74 test_cmp expect actual
75'
76
77test_done