mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
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>
This commit is contained in:
parent
fb7d80edca
commit
e95bafc52f
@ -1916,6 +1916,7 @@ static void initialize_attr_index(struct merge_options *opt)
|
||||
struct index_state *attr_index = &opt->priv->attr_index;
|
||||
struct cache_entry *ce;
|
||||
|
||||
attr_index->repo = opt->repo;
|
||||
attr_index->initialized = 1;
|
||||
|
||||
if (!opt->renormalize)
|
||||
|
@ -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" &&
|
||||
|
Loading…
Reference in New Issue
Block a user