Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
d9fdee6e
Commit
d9fdee6e
authored
Mar 12, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove `git_merge_result` as it's now unnecessary
parent
5aa2ac6d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
39 additions
and
239 deletions
+39
-239
include/git2/merge.h
+4
-60
src/merge.c
+1
-47
src/merge.h
+0
-10
tests/merge/merge_helpers.c
+2
-2
tests/merge/merge_helpers.h
+1
-1
tests/merge/workdir/dirty.c
+7
-24
tests/merge/workdir/renames.c
+3
-11
tests/merge/workdir/setup.c
+2
-6
tests/merge/workdir/simple.c
+16
-69
tests/merge/workdir/submodules.c
+2
-6
tests/merge/workdir/trivial.c
+1
-3
No files found.
include/git2/merge.h
View file @
d9fdee6e
...
...
@@ -472,27 +472,11 @@ GIT_EXTERN(int) git_merge_commits(
const
git_merge_options
*
opts
);
/**
* Merges the given commit(s) into HEAD
and either returns immediately
*
if there was no merge to perform (the specified commits have already
*
been merged or would produce a fast-forward) or performs the merge
*
and writes the results into the working directory
.
* Merges the given commit(s) into HEAD
, writing the results into the working
*
directory. Any changes are staged for commit and any conflicts are written
*
to the index. Callers should inspect the repository's index after this
*
completes, resolve any conflicts and prepare a commit
.
*
* Callers should inspect the `git_merge_result`:
*
* If `git_merge_result_is_uptodate` is true, there is no work to perform.
*
* If `git_merge_result_is_fastforward` is true, the caller should update
* any necessary references to the commit ID returned by
* `git_merge_result_fastforward_id` and check that out in order to complete
* the fast-forward.
*
* Otherwise, callers should inspect the resulting index, resolve any
* conflicts and prepare a commit.
*
* The resultant `git_merge_result` should be free with
* `git_merge_result_free`.
*
* @param out the results of the merge
* @param repo the repository to merge
* @param merge_heads the heads to merge into
* @param merge_heads_len the number of heads to merge
...
...
@@ -501,52 +485,12 @@ GIT_EXTERN(int) git_merge_commits(
* @return 0 on success or error code
*/
GIT_EXTERN
(
int
)
git_merge
(
git_merge_result
**
out
,
git_repository
*
repo
,
const
git_merge_head
**
their_heads
,
size_t
their_heads_len
,
const
git_merge_options
*
merge_opts
,
const
git_checkout_options
*
checkout_opts
);
/**
* Returns true if a merge is "up-to-date", meaning that the commit(s)
* that were provided to `git_merge` are already included in `HEAD`
* and there is no work to do.
*
* @return true if the merge is up-to-date, false otherwise
*/
GIT_EXTERN
(
int
)
git_merge_result_is_uptodate
(
git_merge_result
*
merge_result
);
/**
* Returns true if a merge is eligible to be "fast-forwarded", meaning that
* the commit that was provided to `git_merge` need not be merged, it can
* simply be checked out, because the current `HEAD` is the merge base of
* itself and the given commit. To perform the fast-forward, the caller
* should check out the results of `git_merge_result_fastforward_id`.
*
* This will never be true if `GIT_MERGE_NO_FASTFORWARD` is supplied as
* a merge option.
*
* @return true if the merge is fast-forwardable, false otherwise
*/
GIT_EXTERN
(
int
)
git_merge_result_is_fastforward
(
git_merge_result
*
merge_result
);
/**
* Gets the fast-forward OID if the merge was a fastforward.
*
* @param out pointer to populate with the OID of the fast-forward
* @param merge_result the results of the merge
* @return 0 on success or error code
*/
GIT_EXTERN
(
int
)
git_merge_result_fastforward_id
(
git_oid
*
out
,
git_merge_result
*
merge_result
);
/**
* Frees a `git_merge_result`.
*
* @param result merge result to free
*/
GIT_EXTERN
(
void
)
git_merge_result_free
(
git_merge_result
*
merge_result
);
/** @} */
GIT_END_DECL
#endif
src/merge.c
View file @
d9fdee6e
...
...
@@ -2548,14 +2548,12 @@ done:
}
int
git_merge
(
git_merge_result
**
out
,
git_repository
*
repo
,
const
git_merge_head
**
their_heads
,
size_t
their_heads_len
,
const
git_merge_options
*
merge_opts
,
const
git_checkout_options
*
given_checkout_opts
)
{
git_merge_result
*
result
;
git_reference
*
our_ref
=
NULL
;
git_checkout_options
checkout_opts
;
git_merge_head
*
ancestor_head
=
NULL
,
*
our_head
=
NULL
;
...
...
@@ -2564,18 +2562,13 @@ int git_merge(
size_t
i
;
int
error
=
0
;
assert
(
out
&&
repo
&&
their_heads
);
*
out
=
NULL
;
assert
(
repo
&&
their_heads
);
if
(
their_heads_len
!=
1
)
{
giterr_set
(
GITERR_MERGE
,
"Can only merge a single branch"
);
return
-
1
;
}
result
=
git__calloc
(
1
,
sizeof
(
git_merge_result
));
GITERR_CHECK_ALLOC
(
result
);
their_trees
=
git__calloc
(
their_heads_len
,
sizeof
(
git_tree
*
));
GITERR_CHECK_ALLOC
(
their_trees
);
...
...
@@ -2610,16 +2603,12 @@ int git_merge(
(
error
=
git_checkout_index
(
repo
,
index_repo
,
&
checkout_opts
))
<
0
)
goto
on_error
;
result
->
index
=
index_new
;
*
out
=
result
;
goto
done
;
on_error:
merge_state_cleanup
(
repo
);
git_index_free
(
index_new
);
git__free
(
result
);
done:
git_index_free
(
index_repo
);
...
...
@@ -2640,41 +2629,6 @@ done:
return
error
;
}
/* Merge result data */
int
git_merge_result_is_uptodate
(
git_merge_result
*
merge_result
)
{
assert
(
merge_result
);
return
merge_result
->
is_uptodate
;
}
int
git_merge_result_is_fastforward
(
git_merge_result
*
merge_result
)
{
assert
(
merge_result
);
return
merge_result
->
is_fastforward
;
}
int
git_merge_result_fastforward_id
(
git_oid
*
out
,
git_merge_result
*
merge_result
)
{
assert
(
out
&&
merge_result
);
git_oid_cpy
(
out
,
&
merge_result
->
fastforward_oid
);
return
0
;
}
void
git_merge_result_free
(
git_merge_result
*
merge_result
)
{
if
(
merge_result
==
NULL
)
return
;
git_index_free
(
merge_result
->
index
);
merge_result
->
index
=
NULL
;
git__free
(
merge_result
);
}
/* Merge heads are the input to merge */
static
int
merge_head_init
(
...
...
src/merge.h
View file @
d9fdee6e
...
...
@@ -120,16 +120,6 @@ struct git_merge_head {
git_commit
*
commit
;
};
/** Internal structure for merge results */
struct
git_merge_result
{
bool
is_uptodate
;
bool
is_fastforward
;
git_oid
fastforward_oid
;
git_index
*
index
;
};
int
git_merge__bases_many
(
git_commit_list
**
out
,
git_revwalk
*
walk
,
...
...
tests/merge/merge_helpers.c
View file @
d9fdee6e
...
...
@@ -79,7 +79,7 @@ int merge_commits_from_branches(
return
0
;
}
int
merge_branches
(
git_
merge_result
**
result
,
git_
repository
*
repo
,
int
merge_branches
(
git_repository
*
repo
,
const
char
*
ours_branch
,
const
char
*
theirs_branch
,
git_merge_options
*
merge_opts
,
git_checkout_options
*
checkout_opts
)
{
...
...
@@ -95,7 +95,7 @@ int merge_branches(git_merge_result **result, git_repository *repo,
cl_git_pass
(
git_reference_lookup
(
&
theirs_ref
,
repo
,
theirs_branch
));
cl_git_pass
(
git_merge_head_from_ref
(
&
theirs_head
,
repo
,
theirs_ref
));
cl_git_pass
(
git_merge
(
re
sult
,
re
po
,
(
const
git_merge_head
**
)
&
theirs_head
,
1
,
merge_opts
,
checkout_opts
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
&
theirs_head
,
1
,
merge_opts
,
checkout_opts
));
git_reference_free
(
head_ref
);
git_reference_free
(
theirs_ref
);
...
...
tests/merge/merge_helpers.h
View file @
d9fdee6e
...
...
@@ -92,7 +92,7 @@ int merge_commits_from_branches(
const
char
*
ours_name
,
const
char
*
theirs_name
,
git_merge_options
*
opts
);
int
merge_branches
(
git_
merge_result
**
result
,
git_
repository
*
repo
,
int
merge_branches
(
git_repository
*
repo
,
const
char
*
ours_branch
,
const
char
*
theirs_branch
,
git_merge_options
*
merge_opts
,
git_checkout_options
*
checkout_opts
);
...
...
tests/merge/workdir/dirty.c
View file @
d9fdee6e
...
...
@@ -86,7 +86,7 @@ static void set_core_autocrlf_to(git_repository *repo, bool value)
git_config_free
(
cfg
);
}
static
int
merge_branch
(
git_merge_result
**
result
,
int
merge_file_favor
,
int
checkout_strategy
)
static
int
merge_branch
(
int
merge_file_favor
,
int
checkout_strategy
)
{
git_oid
their_oids
[
1
];
git_merge_head
*
their_heads
[
1
];
...
...
@@ -99,7 +99,7 @@ static int merge_branch(git_merge_result **result, int merge_file_favor, int che
merge_opts
.
file_favor
=
merge_file_favor
;
checkout_opts
.
checkout_strategy
=
checkout_strategy
;
error
=
git_merge
(
re
sult
,
re
po
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
&
checkout_opts
);
error
=
git_merge
(
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
&
checkout_opts
);
git_merge_head_free
(
their_heads
[
0
]);
...
...
@@ -177,7 +177,6 @@ static void stage_content(char *content[])
{
git_reference
*
head
;
git_object
*
head_object
;
git_merge_result
*
result
=
NULL
;
git_buf
path
=
GIT_BUF_INIT
;
char
*
filename
,
*
text
;
size_t
i
;
...
...
@@ -198,7 +197,6 @@ static void stage_content(char *content[])
cl_git_pass
(
git_index_add_bypath
(
repo_index
,
filename
));
}
git_merge_result_free
(
result
);
git_object_free
(
head_object
);
git_reference_free
(
head
);
git_buf_free
(
&
path
);
...
...
@@ -208,7 +206,6 @@ static int merge_dirty_files(char *dirty_files[])
{
git_reference
*
head
;
git_object
*
head_object
;
git_merge_result
*
result
=
NULL
;
int
error
;
cl_git_pass
(
git_repository_head
(
&
head
,
repo
));
...
...
@@ -217,9 +214,8 @@ static int merge_dirty_files(char *dirty_files[])
write_files
(
dirty_files
);
error
=
merge_branch
(
&
result
,
0
,
0
);
error
=
merge_branch
(
0
,
0
);
git_merge_result_free
(
result
);
git_object_free
(
head_object
);
git_reference_free
(
head
);
...
...
@@ -230,7 +226,6 @@ static int merge_differently_filtered_files(char *files[])
{
git_reference
*
head
;
git_object
*
head_object
;
git_merge_result
*
result
=
NULL
;
int
error
;
cl_git_pass
(
git_repository_head
(
&
head
,
repo
));
...
...
@@ -242,9 +237,8 @@ static int merge_differently_filtered_files(char *files[])
cl_git_pass
(
git_index_write
(
repo_index
));
error
=
merge_branch
(
&
result
,
0
,
0
);
error
=
merge_branch
(
0
,
0
);
git_merge_result_free
(
result
);
git_object_free
(
head_object
);
git_reference_free
(
head
);
...
...
@@ -252,17 +246,9 @@ static int merge_differently_filtered_files(char *files[])
}
static
int
merge_staged_files
(
char
*
staged_files
[])
{
git_merge_result
*
result
=
NULL
;
int
error
;
{
stage_random_files
(
staged_files
);
error
=
merge_branch
(
&
result
,
0
,
0
);
git_merge_result_free
(
result
);
return
error
;
return
merge_branch
(
0
,
0
);
}
void
test_merge_workdir_dirty__unaffected_dirty_files_allowed
(
void
)
...
...
@@ -297,7 +283,6 @@ void test_merge_workdir_dirty__staged_files_in_index_disallowed(void)
void
test_merge_workdir_dirty__identical_staged_files_allowed
(
void
)
{
git_merge_result
*
result
;
char
**
content
;
size_t
i
;
...
...
@@ -307,9 +292,7 @@ void test_merge_workdir_dirty__identical_staged_files_allowed(void)
stage_content
(
content
);
git_index_write
(
repo_index
);
cl_git_pass
(
merge_branch
(
&
result
,
0
,
0
));
git_merge_result_free
(
result
);
cl_git_pass
(
merge_branch
(
0
,
0
));
}
}
...
...
tests/merge/workdir/renames.c
View file @
d9fdee6e
...
...
@@ -34,7 +34,6 @@ void test_merge_workdir_renames__cleanup(void)
void
test_merge_workdir_renames__renames
(
void
)
{
git_merge_result
*
result
;
git_merge_options
merge_opts
=
GIT_MERGE_OPTIONS_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -67,16 +66,13 @@ void test_merge_workdir_renames__renames(void)
merge_opts
.
flags
|=
GIT_MERGE_TREE_FIND_RENAMES
;
merge_opts
.
rename_threshold
=
50
;
cl_git_pass
(
merge_branches
(
&
result
,
repo
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_OURS
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_THEIRS
,
&
merge_opts
,
NULL
));
cl_git_pass
(
merge_branches
(
repo
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_OURS
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_THEIRS
,
&
merge_opts
,
NULL
));
cl_assert
(
merge_test_workdir
(
repo
,
merge_index_entries
,
24
));
git_merge_result_free
(
result
);
}
void
test_merge_workdir_renames__ours
(
void
)
{
git_index
*
index
;
git_merge_result
*
result
;
git_merge_options
merge_opts
=
GIT_MERGE_OPTIONS_INIT
;
git_checkout_options
checkout_opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
...
...
@@ -107,18 +103,16 @@ void test_merge_workdir_renames__ours(void)
merge_opts
.
rename_threshold
=
50
;
checkout_opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
|
GIT_CHECKOUT_USE_OURS
;
cl_git_pass
(
merge_branches
(
&
result
,
repo
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_OURS
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_THEIRS
,
&
merge_opts
,
&
checkout_opts
));
cl_git_pass
(
merge_branches
(
repo
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_OURS
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_THEIRS
,
&
merge_opts
,
&
checkout_opts
));
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
cl_git_pass
(
git_index_write
(
index
));
cl_assert
(
merge_test_workdir
(
repo
,
merge_index_entries
,
20
));
git_merge_result_free
(
result
);
git_index_free
(
index
);
}
void
test_merge_workdir_renames__similar
(
void
)
{
git_merge_result
*
result
;
git_merge_options
merge_opts
=
GIT_MERGE_OPTIONS_INIT
;
/*
...
...
@@ -156,9 +150,7 @@ void test_merge_workdir_renames__similar(void)
merge_opts
.
flags
|=
GIT_MERGE_TREE_FIND_RENAMES
;
merge_opts
.
rename_threshold
=
50
;
cl_git_pass
(
merge_branches
(
&
result
,
repo
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_OURS
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_THEIRS
,
&
merge_opts
,
NULL
));
cl_git_pass
(
merge_branches
(
repo
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_OURS
,
GIT_REFS_HEADS_DIR
BRANCH_RENAME_THEIRS
,
&
merge_opts
,
NULL
));
cl_assert
(
merge_test_workdir
(
repo
,
merge_index_entries
,
24
));
git_merge_result_free
(
result
);
}
tests/merge/workdir/setup.c
View file @
d9fdee6e
...
...
@@ -970,7 +970,6 @@ void test_merge_workdir_setup__retained_after_success(void)
git_oid
our_oid
;
git_reference
*
octo1_ref
;
git_merge_head
*
our_head
,
*
their_heads
[
1
];
git_merge_result
*
result
;
cl_git_pass
(
git_oid_fromstr
(
&
our_oid
,
ORIG_HEAD
));
cl_git_pass
(
git_merge_head_from_id
(
&
our_head
,
repo
,
&
our_oid
));
...
...
@@ -979,7 +978,7 @@ void test_merge_workdir_setup__retained_after_success(void)
cl_git_pass
(
git_merge_head_from_ref
(
&
their_heads
[
0
],
repo
,
octo1_ref
));
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
&
their_heads
[
0
],
1
,
NULL
,
NULL
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
&
their_heads
[
0
],
1
,
NULL
,
NULL
));
cl_assert
(
test_file_contents
(
GIT_MERGE_HEAD_FILE
,
OCTO1_OID
"
\n
"
));
cl_assert
(
test_file_contents
(
GIT_ORIG_HEAD_FILE
,
ORIG_HEAD
"
\n
"
));
...
...
@@ -990,7 +989,6 @@ void test_merge_workdir_setup__retained_after_success(void)
git_merge_head_free
(
our_head
);
git_merge_head_free
(
their_heads
[
0
]);
git_merge_result_free
(
result
);
}
void
test_merge_workdir_setup__removed_after_failure
(
void
)
...
...
@@ -998,7 +996,6 @@ void test_merge_workdir_setup__removed_after_failure(void)
git_oid
our_oid
;
git_reference
*
octo1_ref
;
git_merge_head
*
our_head
,
*
their_heads
[
1
];
git_merge_result
*
result
;
cl_git_pass
(
git_oid_fromstr
(
&
our_oid
,
ORIG_HEAD
));
cl_git_pass
(
git_merge_head_from_id
(
&
our_head
,
repo
,
&
our_oid
));
...
...
@@ -1010,7 +1007,7 @@ void test_merge_workdir_setup__removed_after_failure(void)
"Conflicting file!
\n\n
Merge will fail!
\n
"
);
cl_git_fail
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
&
their_heads
[
0
],
1
,
NULL
,
NULL
));
repo
,
(
const
git_merge_head
**
)
&
their_heads
[
0
],
1
,
NULL
,
NULL
));
cl_assert
(
!
git_path_exists
(
"merge-resolve/"
GIT_MERGE_HEAD_FILE
));
cl_assert
(
!
git_path_exists
(
"merge-resolve/"
GIT_ORIG_HEAD_FILE
));
...
...
@@ -1021,5 +1018,4 @@ void test_merge_workdir_setup__removed_after_failure(void)
git_merge_head_free
(
our_head
);
git_merge_head_free
(
their_heads
[
0
]);
git_merge_result_free
(
result
);
}
tests/merge/workdir/simple.c
View file @
d9fdee6e
...
...
@@ -92,11 +92,10 @@ void test_merge_workdir_simple__cleanup(void)
cl_git_sandbox_cleanup
();
}
static
git_merge_result
*
merge_simple_branch
(
int
merge_file_favor
,
int
checkout_strategy
)
static
void
merge_simple_branch
(
int
merge_file_favor
,
int
checkout_strategy
)
{
git_oid
their_oids
[
1
];
git_merge_head
*
their_heads
[
1
];
git_merge_result
*
result
;
git_merge_options
merge_opts
=
GIT_MERGE_OPTIONS_INIT
;
git_checkout_options
checkout_opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
...
...
@@ -105,11 +104,9 @@ static git_merge_result *merge_simple_branch(int merge_file_favor, int checkout_
merge_opts
.
file_favor
=
merge_file_favor
;
checkout_opts
.
checkout_strategy
=
checkout_strategy
;
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
&
checkout_opts
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
&
checkout_opts
));
git_merge_head_free
(
their_heads
[
0
]);
return
result
;
}
static
void
set_core_autocrlf_to
(
git_repository
*
repo
,
bool
value
)
...
...
@@ -126,7 +123,6 @@ void test_merge_workdir_simple__automerge(void)
{
git_index
*
index
;
const
git_index_entry
*
entry
;
git_merge_result
*
result
;
git_buf
automergeable_buf
=
GIT_BUF_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -151,8 +147,7 @@ void test_merge_workdir_simple__automerge(void)
set_core_autocrlf_to
(
repo
,
false
);
cl_assert
(
result
=
merge_simple_branch
(
0
,
0
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
0
,
0
);
cl_git_pass
(
git_futils_readbuffer
(
&
automergeable_buf
,
TEST_REPO_PATH
"/automergeable.txt"
));
...
...
@@ -162,8 +157,6 @@ void test_merge_workdir_simple__automerge(void)
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
8
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
3
));
git_merge_result_free
(
result
);
git_repository_index
(
&
index
,
repo
);
cl_assert
((
entry
=
git_index_get_bypath
(
index
,
"automergeable.txt"
,
0
))
!=
NULL
);
...
...
@@ -177,8 +170,6 @@ void test_merge_workdir_simple__automerge_crlf(void)
#ifdef GIT_WIN32
git_index
*
index
;
const
git_index_entry
*
entry
;
git_merge_result
*
result
;
git_buf
automergeable_buf
=
GIT_BUF_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -202,8 +193,7 @@ void test_merge_workdir_simple__automerge_crlf(void)
set_core_autocrlf_to
(
repo
,
true
);
cl_assert
(
result
=
merge_simple_branch
(
0
,
0
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
0
,
0
);
cl_git_pass
(
git_futils_readbuffer
(
&
automergeable_buf
,
TEST_REPO_PATH
"/automergeable.txt"
));
...
...
@@ -213,8 +203,6 @@ void test_merge_workdir_simple__automerge_crlf(void)
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
8
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
3
));
git_merge_result_free
(
result
);
git_repository_index
(
&
index
,
repo
);
cl_assert
((
entry
=
git_index_get_bypath
(
index
,
"automergeable.txt"
,
0
))
!=
NULL
);
...
...
@@ -226,7 +214,6 @@ void test_merge_workdir_simple__automerge_crlf(void)
void
test_merge_workdir_simple__mergefile
(
void
)
{
git_merge_result
*
result
;
git_buf
conflicting_buf
=
GIT_BUF_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -248,8 +235,7 @@ void test_merge_workdir_simple__mergefile(void)
REMOVED_IN_MASTER_REUC_ENTRY
};
cl_assert
(
result
=
merge_simple_branch
(
0
,
0
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
0
,
0
);
cl_git_pass
(
git_futils_readbuffer
(
&
conflicting_buf
,
TEST_REPO_PATH
"/conflicting.txt"
));
...
...
@@ -258,13 +244,10 @@ void test_merge_workdir_simple__mergefile(void)
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
8
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
3
));
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__diff3
(
void
)
{
git_merge_result
*
result
;
git_buf
conflicting_buf
=
GIT_BUF_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -286,8 +269,7 @@ void test_merge_workdir_simple__diff3(void)
REMOVED_IN_MASTER_REUC_ENTRY
};
cl_assert
(
result
=
merge_simple_branch
(
0
,
GIT_CHECKOUT_CONFLICT_STYLE_DIFF3
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
0
,
GIT_CHECKOUT_CONFLICT_STYLE_DIFF3
);
cl_git_pass
(
git_futils_readbuffer
(
&
conflicting_buf
,
TEST_REPO_PATH
"/conflicting.txt"
));
...
...
@@ -296,13 +278,10 @@ void test_merge_workdir_simple__diff3(void)
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
8
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
3
));
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__union
(
void
)
{
git_merge_result
*
result
;
git_buf
conflicting_buf
=
GIT_BUF_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -325,8 +304,7 @@ void test_merge_workdir_simple__union(void)
set_core_autocrlf_to
(
repo
,
false
);
cl_assert
(
result
=
merge_simple_branch
(
GIT_MERGE_FILE_FAVOR_UNION
,
0
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
GIT_MERGE_FILE_FAVOR_UNION
,
0
);
cl_git_pass
(
git_futils_readbuffer
(
&
conflicting_buf
,
TEST_REPO_PATH
"/conflicting.txt"
));
...
...
@@ -335,13 +313,10 @@ void test_merge_workdir_simple__union(void)
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
6
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
4
));
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__diff3_from_config
(
void
)
{
git_merge_result
*
result
;
git_config
*
config
;
git_buf
conflicting_buf
=
GIT_BUF_INIT
;
...
...
@@ -367,8 +342,7 @@ void test_merge_workdir_simple__diff3_from_config(void)
cl_git_pass
(
git_repository_config
(
&
config
,
repo
));
cl_git_pass
(
git_config_set_string
(
config
,
"merge.conflictstyle"
,
"diff3"
));
cl_assert
(
result
=
merge_simple_branch
(
0
,
0
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
0
,
0
);
cl_git_pass
(
git_futils_readbuffer
(
&
conflicting_buf
,
TEST_REPO_PATH
"/conflicting.txt"
));
...
...
@@ -378,13 +352,11 @@ void test_merge_workdir_simple__diff3_from_config(void)
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
8
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
3
));
git_merge_result_free
(
result
);
git_config_free
(
config
);
}
void
test_merge_workdir_simple__merge_overrides_config
(
void
)
{
git_merge_result
*
result
;
git_config
*
config
;
git_buf
conflicting_buf
=
GIT_BUF_INIT
;
...
...
@@ -410,8 +382,7 @@ void test_merge_workdir_simple__merge_overrides_config(void)
cl_git_pass
(
git_repository_config
(
&
config
,
repo
));
cl_git_pass
(
git_config_set_string
(
config
,
"merge.conflictstyle"
,
"diff3"
));
cl_assert
(
result
=
merge_simple_branch
(
0
,
GIT_CHECKOUT_CONFLICT_STYLE_MERGE
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
0
,
GIT_CHECKOUT_CONFLICT_STYLE_MERGE
);
cl_git_pass
(
git_futils_readbuffer
(
&
conflicting_buf
,
TEST_REPO_PATH
"/conflicting.txt"
));
...
...
@@ -421,14 +392,11 @@ void test_merge_workdir_simple__merge_overrides_config(void)
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
8
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
3
));
git_merge_result_free
(
result
);
git_config_free
(
config
);
}
void
test_merge_workdir_simple__checkout_ours
(
void
)
{
git_merge_result
*
result
;
struct
merge_index_entry
merge_index_entries
[]
=
{
ADDED_IN_MASTER_INDEX_ENTRY
,
AUTOMERGEABLE_INDEX_ENTRY
,
...
...
@@ -448,21 +416,16 @@ void test_merge_workdir_simple__checkout_ours(void)
REMOVED_IN_MASTER_REUC_ENTRY
};
cl_assert
(
result
=
merge_simple_branch
(
0
,
GIT_CHECKOUT_SAFE
|
GIT_CHECKOUT_USE_OURS
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
0
,
GIT_CHECKOUT_SAFE
|
GIT_CHECKOUT_USE_OURS
);
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
8
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
3
));
cl_assert
(
git_path_exists
(
TEST_REPO_PATH
"/conflicting.txt"
));
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__favor_ours
(
void
)
{
git_merge_result
*
result
;
struct
merge_index_entry
merge_index_entries
[]
=
{
ADDED_IN_MASTER_INDEX_ENTRY
,
AUTOMERGEABLE_INDEX_ENTRY
,
...
...
@@ -479,19 +442,14 @@ void test_merge_workdir_simple__favor_ours(void)
REMOVED_IN_MASTER_REUC_ENTRY
,
};
cl_assert
(
result
=
merge_simple_branch
(
GIT_MERGE_FILE_FAVOR_OURS
,
0
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
GIT_MERGE_FILE_FAVOR_OURS
,
0
);
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
6
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
4
));
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__favor_theirs
(
void
)
{
git_merge_result
*
result
;
struct
merge_index_entry
merge_index_entries
[]
=
{
ADDED_IN_MASTER_INDEX_ENTRY
,
AUTOMERGEABLE_INDEX_ENTRY
,
...
...
@@ -508,13 +466,10 @@ void test_merge_workdir_simple__favor_theirs(void)
REMOVED_IN_MASTER_REUC_ENTRY
,
};
cl_assert
(
result
=
merge_simple_branch
(
GIT_MERGE_FILE_FAVOR_THEIRS
,
0
));
cl_assert
(
!
git_merge_result_is_fastforward
(
result
));
merge_simple_branch
(
GIT_MERGE_FILE_FAVOR_THEIRS
,
0
);
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
6
));
cl_assert
(
merge_test_reuc
(
repo_index
,
merge_reuc_entries
,
4
));
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__directory_file
(
void
)
...
...
@@ -522,7 +477,6 @@ void test_merge_workdir_simple__directory_file(void)
git_reference
*
head
;
git_oid
their_oids
[
1
],
head_commit_id
;
git_merge_head
*
their_heads
[
1
];
git_merge_result
*
result
;
git_merge_options
merge_opts
=
GIT_MERGE_OPTIONS_INIT
;
git_commit
*
head_commit
;
...
...
@@ -558,21 +512,19 @@ void test_merge_workdir_simple__directory_file(void)
cl_git_pass
(
git_merge_head_from_id
(
&
their_heads
[
0
],
repo
,
&
their_oids
[
0
]));
merge_opts
.
file_favor
=
0
;
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
NULL
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
NULL
));
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
20
));
git_reference_free
(
head
);
git_commit_free
(
head_commit
);
git_merge_head_free
(
their_heads
[
0
]);
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__unrelated
(
void
)
{
git_oid
their_oids
[
1
];
git_merge_head
*
their_heads
[
1
];
git_merge_result
*
result
;
git_merge_options
merge_opts
=
GIT_MERGE_OPTIONS_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -591,19 +543,17 @@ void test_merge_workdir_simple__unrelated(void)
cl_git_pass
(
git_merge_head_from_id
(
&
their_heads
[
0
],
repo
,
&
their_oids
[
0
]));
merge_opts
.
file_favor
=
0
;
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
NULL
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
NULL
));
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
9
));
git_merge_head_free
(
their_heads
[
0
]);
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__unrelated_with_conflicts
(
void
)
{
git_oid
their_oids
[
1
];
git_merge_head
*
their_heads
[
1
];
git_merge_result
*
result
;
git_merge_options
merge_opts
=
GIT_MERGE_OPTIONS_INIT
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -624,12 +574,11 @@ void test_merge_workdir_simple__unrelated_with_conflicts(void)
cl_git_pass
(
git_merge_head_from_id
(
&
their_heads
[
0
],
repo
,
&
their_oids
[
0
]));
merge_opts
.
file_favor
=
0
;
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
NULL
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
&
merge_opts
,
NULL
));
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
11
));
git_merge_head_free
(
their_heads
[
0
]);
git_merge_result_free
(
result
);
}
void
test_merge_workdir_simple__binary
(
void
)
...
...
@@ -637,7 +586,6 @@ void test_merge_workdir_simple__binary(void)
git_oid
our_oid
,
their_oid
,
our_file_oid
;
git_commit
*
our_commit
;
git_merge_head
*
their_head
;
git_merge_result
*
result
;
const
git_index_entry
*
binary_entry
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -654,7 +602,7 @@ void test_merge_workdir_simple__binary(void)
cl_git_pass
(
git_merge_head_from_id
(
&
their_head
,
repo
,
&
their_oid
));
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
&
their_head
,
1
,
NULL
,
NULL
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
&
their_head
,
1
,
NULL
,
NULL
));
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
3
));
...
...
@@ -665,6 +613,5 @@ void test_merge_workdir_simple__binary(void)
cl_assert
(
git_oid_cmp
(
&
binary_entry
->
id
,
&
our_file_oid
)
==
0
);
git_merge_head_free
(
their_head
);
git_merge_result_free
(
result
);
git_commit_free
(
our_commit
);
}
tests/merge/workdir/submodules.c
View file @
d9fdee6e
...
...
@@ -31,7 +31,6 @@ void test_merge_workdir_submodules__automerge(void)
git_reference
*
our_ref
,
*
their_ref
;
git_commit
*
our_commit
;
git_merge_head
*
their_head
;
git_merge_result
*
result
;
git_index
*
index
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -50,13 +49,12 @@ void test_merge_workdir_submodules__automerge(void)
cl_git_pass
(
git_reference_lookup
(
&
their_ref
,
repo
,
"refs/heads/"
SUBMODULE_OTHER_BRANCH
));
cl_git_pass
(
git_merge_head_from_ref
(
&
their_head
,
repo
,
their_ref
));
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
&
their_head
,
1
,
NULL
,
NULL
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
&
their_head
,
1
,
NULL
,
NULL
));
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
cl_assert
(
merge_test_index
(
index
,
merge_index_entries
,
6
));
git_index_free
(
index
);
git_merge_result_free
(
result
);
git_merge_head_free
(
their_head
);
git_commit_free
(
our_commit
);
git_reference_free
(
their_ref
);
...
...
@@ -68,7 +66,6 @@ void test_merge_workdir_submodules__take_changed(void)
git_reference
*
our_ref
,
*
their_ref
;
git_commit
*
our_commit
;
git_merge_head
*
their_head
;
git_merge_result
*
result
;
git_index
*
index
;
struct
merge_index_entry
merge_index_entries
[]
=
{
...
...
@@ -85,13 +82,12 @@ void test_merge_workdir_submodules__take_changed(void)
cl_git_pass
(
git_reference_lookup
(
&
their_ref
,
repo
,
"refs/heads/"
SUBMODULE_OTHER2_BRANCH
));
cl_git_pass
(
git_merge_head_from_ref
(
&
their_head
,
repo
,
their_ref
));
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
&
their_head
,
1
,
NULL
,
NULL
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
&
their_head
,
1
,
NULL
,
NULL
));
cl_git_pass
(
git_repository_index
(
&
index
,
repo
));
cl_assert
(
merge_test_index
(
index
,
merge_index_entries
,
4
));
git_index_free
(
index
);
git_merge_result_free
(
result
);
git_merge_head_free
(
their_head
);
git_commit_free
(
our_commit
);
git_reference_free
(
their_ref
);
...
...
tests/merge/workdir/trivial.c
View file @
d9fdee6e
...
...
@@ -34,7 +34,6 @@ static int merge_trivial(const char *ours, const char *theirs)
git_checkout_options
checkout_opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
git_reference
*
our_ref
,
*
their_ref
;
git_merge_head
*
their_heads
[
1
];
git_merge_result
*
result
;
checkout_opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
...
...
@@ -48,13 +47,12 @@ static int merge_trivial(const char *ours, const char *theirs)
cl_git_pass
(
git_reference_lookup
(
&
their_ref
,
repo
,
branch_buf
.
ptr
));
cl_git_pass
(
git_merge_head_from_ref
(
&
their_heads
[
0
],
repo
,
their_ref
));
cl_git_pass
(
git_merge
(
&
result
,
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
NULL
,
NULL
));
cl_git_pass
(
git_merge
(
repo
,
(
const
git_merge_head
**
)
their_heads
,
1
,
NULL
,
NULL
));
git_buf_free
(
&
branch_buf
);
git_reference_free
(
our_ref
);
git_reference_free
(
their_ref
);
git_merge_head_free
(
their_heads
[
0
]);
git_merge_result_free
(
result
);
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment