diff options
author | John Cai <johncai86@gmail.com> | 2023-10-09 16:21:00 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-10-10 00:42:02 +0300 |
commit | e95bafc52f095b33b5a283179e08a44279c293d0 (patch) | |
tree | 7ca13bb2c7fa80f96a82f7dc7b68cc08d8034ffd /t/t4300-merge-tree.sh | |
parent | fb7d80edcae482f4fa5d4be0227dc3054734e5f3 (diff) |
merge-ort: initialize repo in index state
initialize_attr_index() does not initialize the repo member of
attr_index. Starting in 44451a2e5e (attr: teach "--attr-source=<tree>"
global option to "git", 2023-05-06), this became a problem because
istate->repo gets passed down the call chain starting in
git_check_attr(). This gets passed all the way down to
replace_refs_enabled(), which segfaults when accessing r->gitdir.
Fix this by initializing the repository in the index state.
Signed-off-by: John Cai <johncai86@gmail.com>
Helped-by: Christian Couder <christian.couder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4300-merge-tree.sh')
-rwxr-xr-x | t/t4300-merge-tree.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh index 57c4f26e46..9c197260d5 100755 --- a/t/t4300-merge-tree.sh +++ b/t/t4300-merge-tree.sh @@ -86,6 +86,33 @@ EXPECTED test_cmp expected actual ' +test_expect_success '3-way merge with --attr-source' ' + test_when_finished rm -rf 3-way && + git init 3-way && + ( + cd 3-way && + test_commit initial file1 foo && + base=$(git rev-parse HEAD) && + git checkout -b brancha && + echo bar >>file1 && + git commit -am "adding bar" && + source=$(git rev-parse HEAD) && + git checkout @{-1} && + git checkout -b branchb && + echo baz >>file1 && + git commit -am "adding baz" && + merge=$(git rev-parse HEAD) && + git checkout -b gitattributes && + test_commit "gitattributes" .gitattributes "file1 merge=union" && + git checkout @{-1} && + tree=$(git --attr-source=gitattributes merge-tree --write-tree \ + --merge-base "$base" --end-of-options "$source" "$merge") && + test_write_lines foo bar baz >expect && + git cat-file -p "$tree:file1" >actual && + test_cmp expect actual + ) +' + test_expect_success 'file change A, B (same)' ' git reset --hard initial && test_commit "change-a-b-same-A" "initial-file" "AAA" && |