@@ -1681,29 +1681,20 @@ static int checkout_write_merge(
1681
1681
{
1682
1682
git_buf our_label = GIT_BUF_INIT , their_label = GIT_BUF_INIT ,
1683
1683
path_suffixed = GIT_BUF_INIT , path_workdir = GIT_BUF_INIT ;
1684
- git_merge_file_options merge_file_opts = GIT_MERGE_FILE_OPTIONS_INIT ;
1685
- git_merge_file_input ancestor = GIT_MERGE_FILE_INPUT_INIT ,
1686
- ours = GIT_MERGE_FILE_INPUT_INIT ,
1687
- theirs = GIT_MERGE_FILE_INPUT_INIT ;
1688
- git_merge_file_result result = GIT_MERGE_FILE_RESULT_INIT ;
1684
+ git_merge_file_options opts = GIT_MERGE_FILE_OPTIONS_INIT ;
1685
+ git_merge_file_result result = {0 };
1689
1686
git_filebuf output = GIT_FILEBUF_INIT ;
1690
1687
int error = 0 ;
1691
1688
1692
1689
if (data -> opts .checkout_strategy & GIT_CHECKOUT_CONFLICT_STYLE_DIFF3 )
1693
- merge_file_opts .style = GIT_MERGE_FILE_STYLE_DIFF3 ;
1694
-
1695
- if ((conflict -> ancestor &&
1696
- (error = git_merge_file_input_from_index_entry (
1697
- & ancestor , data -> repo , conflict -> ancestor )) < 0 ) ||
1698
- (error = git_merge_file_input_from_index_entry (
1699
- & ours , data -> repo , conflict -> ours )) < 0 ||
1700
- (error = git_merge_file_input_from_index_entry (
1701
- & theirs , data -> repo , conflict -> theirs )) < 0 )
1702
- goto done ;
1690
+ opts .flags |= GIT_MERGE_FILE_STYLE_DIFF3 ;
1703
1691
1704
- ancestor .label = data -> opts .ancestor_label ? data -> opts .ancestor_label : "ancestor" ;
1705
- ours .label = data -> opts .our_label ? data -> opts .our_label : "ours" ;
1706
- theirs .label = data -> opts .their_label ? data -> opts .their_label : "theirs" ;
1692
+ opts .ancestor_label = data -> opts .ancestor_label ?
1693
+ data -> opts .ancestor_label : "ancestor" ;
1694
+ opts .our_label = data -> opts .our_label ?
1695
+ data -> opts .our_label : "ours" ;
1696
+ opts .their_label = data -> opts .their_label ?
1697
+ data -> opts .their_label : "theirs" ;
1707
1698
1708
1699
/* If all the paths are identical, decorate the diff3 file with the branch
1709
1700
* names. Otherwise, append branch_name:path.
@@ -1712,16 +1703,17 @@ static int checkout_write_merge(
1712
1703
strcmp (conflict -> ours -> path , conflict -> theirs -> path ) != 0 ) {
1713
1704
1714
1705
if ((error = conflict_entry_name (
1715
- & our_label , ours . label , conflict -> ours -> path )) < 0 ||
1706
+ & our_label , opts . our_label , conflict -> ours -> path )) < 0 ||
1716
1707
(error = conflict_entry_name (
1717
- & their_label , theirs . label , conflict -> theirs -> path )) < 0 )
1708
+ & their_label , opts . their_label , conflict -> theirs -> path )) < 0 )
1718
1709
goto done ;
1719
1710
1720
- ours . label = git_buf_cstr (& our_label );
1721
- theirs . label = git_buf_cstr (& their_label );
1711
+ opts . our_label = git_buf_cstr (& our_label );
1712
+ opts . their_label = git_buf_cstr (& their_label );
1722
1713
}
1723
1714
1724
- if ((error = git_merge_files (& result , & ancestor , & ours , & theirs , & merge_file_opts )) < 0 )
1715
+ if ((error = git_merge_file_from_index (& result , data -> repo ,
1716
+ conflict -> ancestor , conflict -> ours , conflict -> theirs , & opts )) < 0 )
1725
1717
goto done ;
1726
1718
1727
1719
if (result .path == NULL || result .mode == 0 ) {
@@ -1739,17 +1731,14 @@ static int checkout_write_merge(
1739
1731
1740
1732
if ((error = git_futils_mkpath2file (path_workdir .ptr , 0755 )) < 0 ||
1741
1733
(error = git_filebuf_open (& output , path_workdir .ptr , GIT_FILEBUF_DO_NOT_BUFFER , result .mode )) < 0 ||
1742
- (error = git_filebuf_write (& output , result .data , result .len )) < 0 ||
1734
+ (error = git_filebuf_write (& output , result .ptr , result .len )) < 0 ||
1743
1735
(error = git_filebuf_commit (& output )) < 0 )
1744
1736
goto done ;
1745
1737
1746
1738
done :
1747
1739
git_buf_free (& our_label );
1748
1740
git_buf_free (& their_label );
1749
1741
1750
- git_merge_file_input_free (& ancestor );
1751
- git_merge_file_input_free (& ours );
1752
- git_merge_file_input_free (& theirs );
1753
1742
git_merge_file_result_free (& result );
1754
1743
git_buf_free (& path_workdir );
1755
1744
git_buf_free (& path_suffixed );
0 commit comments