mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-03 00:43:41 +00:00
merge: add simple recursive test
Add a simple recursive test - where multiple ancestors exist and creating a virtual merge base from them would prevent a conflict.
This commit is contained in:
parent
fa78782f67
commit
86c8d02c07
@ -73,17 +73,25 @@ typedef enum {
|
||||
*/
|
||||
GIT_MERGE_FIND_RENAMES = (1 << 0),
|
||||
|
||||
/**
|
||||
* Do not write the REUC extension on the generated index
|
||||
*/
|
||||
GIT_MERGE_SKIP_REUC = (1 << 2),
|
||||
|
||||
/**
|
||||
* If a conflict occurs, exit immediately instead of attempting to
|
||||
* continue resolving conflicts. The merge operation will fail with
|
||||
* GIT_EMERGECONFLICT and no index will be returned.
|
||||
*/
|
||||
GIT_MERGE_FAIL_ON_CONFLICT = (1 << 1),
|
||||
|
||||
/**
|
||||
* Do not write the REUC extension on the generated index
|
||||
*/
|
||||
GIT_MERGE_SKIP_REUC = (1 << 2),
|
||||
|
||||
/**
|
||||
* If the commits being merged have multiple merge bases, do not build
|
||||
* a recursive merge base (by merging the multiple merge bases),
|
||||
* instead simply use the first base. This flag provides a similar
|
||||
* merge base to `git-merge-resolve`.
|
||||
*/
|
||||
GIT_MERGE_NO_RECURSIVE = (1 << 3),
|
||||
} git_merge_flag_t;
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "tree.h"
|
||||
#include "merge_helpers.h"
|
||||
#include "merge.h"
|
||||
#include "index.h"
|
||||
#include "git2/merge.h"
|
||||
#include "git2/sys/index.h"
|
||||
#include "git2/annotated_commit.h"
|
||||
@ -239,7 +240,7 @@ int merge_test_index(git_index *index, const struct merge_index_entry expected[]
|
||||
const git_index_entry *index_entry;
|
||||
|
||||
/*
|
||||
dump_index_entries(&index->entries);
|
||||
merge__dump_index_entries(&index->entries);
|
||||
*/
|
||||
|
||||
if (git_index_entrycount(index) != expected_len)
|
||||
|
110
tests/merge/trees/recursive.c
Normal file
110
tests/merge/trees/recursive.c
Normal file
@ -0,0 +1,110 @@
|
||||
#include "clar_libgit2.h"
|
||||
#include "git2/repository.h"
|
||||
#include "git2/merge.h"
|
||||
#include "merge.h"
|
||||
#include "../merge_helpers.h"
|
||||
|
||||
static git_repository *repo;
|
||||
|
||||
#define TEST_REPO_PATH "merge-recursive"
|
||||
|
||||
void test_merge_trees_recursive__initialize(void)
|
||||
{
|
||||
repo = cl_git_sandbox_init(TEST_REPO_PATH);
|
||||
}
|
||||
|
||||
void test_merge_trees_recursive__cleanup(void)
|
||||
{
|
||||
cl_git_sandbox_cleanup();
|
||||
}
|
||||
|
||||
void test_merge_trees_recursive__one(void)
|
||||
{
|
||||
git_index *index;
|
||||
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "dea7215f259b2cced87d1bda6c72f8b4ce37a2ff", 0, "asparagus.txt" },
|
||||
{ 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" },
|
||||
{ 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
|
||||
{ 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
|
||||
{ 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
|
||||
{ 0100644, "94d2c01087f48213bd157222d54edfefd77c9bba", 0, "veal.txt" },
|
||||
};
|
||||
|
||||
cl_git_pass(merge_commits_from_branches(&index, repo, "branchA-1", "branchA-2", &opts));
|
||||
|
||||
cl_assert(merge_test_index(index, merge_index_entries, 6));
|
||||
|
||||
git_index_free(index);
|
||||
}
|
||||
|
||||
void test_merge_trees_recursive__one_norecursive(void)
|
||||
{
|
||||
git_index *index;
|
||||
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "dea7215f259b2cced87d1bda6c72f8b4ce37a2ff", 0, "asparagus.txt" },
|
||||
{ 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" },
|
||||
{ 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
|
||||
{ 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
|
||||
{ 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
|
||||
{ 0100644, "94d2c01087f48213bd157222d54edfefd77c9bba", 0, "veal.txt" },
|
||||
};
|
||||
|
||||
opts.flags |= GIT_MERGE_NO_RECURSIVE;
|
||||
|
||||
cl_git_pass(merge_commits_from_branches(&index, repo, "branchA-1", "branchA-2", &opts));
|
||||
|
||||
cl_assert(merge_test_index(index, merge_index_entries, 6));
|
||||
|
||||
git_index_free(index);
|
||||
}
|
||||
|
||||
void test_merge_trees_recursive__two(void)
|
||||
{
|
||||
git_index *index;
|
||||
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" },
|
||||
{ 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" },
|
||||
{ 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
|
||||
{ 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
|
||||
{ 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
|
||||
{ 0100644, "666ffdfcf1eaa5641fa31064bf2607327e843c09", 0, "veal.txt" },
|
||||
};
|
||||
|
||||
cl_git_pass(merge_commits_from_branches(&index, repo, "branchB-1", "branchB-2", &opts));
|
||||
|
||||
cl_assert(merge_test_index(index, merge_index_entries, 6));
|
||||
|
||||
git_index_free(index);
|
||||
}
|
||||
|
||||
void test_merge_trees_recursive__two_norecursive(void)
|
||||
{
|
||||
git_index *index;
|
||||
git_merge_options opts = GIT_MERGE_OPTIONS_INIT;
|
||||
|
||||
opts.flags |= GIT_MERGE_NO_RECURSIVE;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "ffb36e513f5fdf8a6ba850a20142676a2ac4807d", 0, "asparagus.txt" },
|
||||
{ 0100644, "68f6182f4c85d39e1309d97c7e456156dc9c0096", 0, "beef.txt" },
|
||||
{ 0100644, "4b7c5650008b2e747fe1809eeb5a1dde0e80850a", 0, "bouilli.txt" },
|
||||
{ 0100644, "c4e6cca3ec6ae0148ed231f97257df8c311e015f", 0, "gravy.txt" },
|
||||
{ 0100644, "68af1fc7407fd9addf1701a87eb1c95c7494c598", 0, "oyster.txt" },
|
||||
{ 0100644, "cb49ad76147f5f9439cbd6133708b76142660660", 1, "veal.txt" },
|
||||
{ 0100644, "b2a81ead9e722af0099fccfb478cea88eea749a2", 2, "veal.txt" },
|
||||
{ 0100644, "4e21d2d63357bde5027d1625f5ec6b430cdeb143", 3, "veal.txt" },
|
||||
};
|
||||
|
||||
cl_git_pass(merge_commits_from_branches(&index, repo, "branchB-1", "branchB-2", &opts));
|
||||
|
||||
cl_assert(merge_test_index(index, merge_index_entries, 8));
|
||||
|
||||
git_index_free(index);
|
||||
}
|
||||
|
BIN
tests/resources/merge-recursive/.gitted/HEAD
Normal file
BIN
tests/resources/merge-recursive/.gitted/HEAD
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/.gitted/config
Normal file
BIN
tests/resources/merge-recursive/.gitted/config
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/.gitted/index
Normal file
BIN
tests/resources/merge-recursive/.gitted/index
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/.gitted/info/refs
Normal file
BIN
tests/resources/merge-recursive/.gitted/info/refs
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
tests/resources/merge-recursive/.gitted/refs/heads/branchA-1
Normal file
BIN
tests/resources/merge-recursive/.gitted/refs/heads/branchA-1
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/.gitted/refs/heads/branchA-2
Normal file
BIN
tests/resources/merge-recursive/.gitted/refs/heads/branchA-2
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/.gitted/refs/heads/branchB-1
Normal file
BIN
tests/resources/merge-recursive/.gitted/refs/heads/branchB-1
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/.gitted/refs/heads/branchB-2
Normal file
BIN
tests/resources/merge-recursive/.gitted/refs/heads/branchB-2
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/asparagus.txt
Normal file
BIN
tests/resources/merge-recursive/asparagus.txt
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/beef.txt
Normal file
BIN
tests/resources/merge-recursive/beef.txt
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/bouilli.txt
Normal file
BIN
tests/resources/merge-recursive/bouilli.txt
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/gravy.txt
Normal file
BIN
tests/resources/merge-recursive/gravy.txt
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/oyster.txt
Normal file
BIN
tests/resources/merge-recursive/oyster.txt
Normal file
Binary file not shown.
BIN
tests/resources/merge-recursive/veal.txt
Normal file
BIN
tests/resources/merge-recursive/veal.txt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user