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
eff531e1
Commit
eff531e1
authored
May 27, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify GIT_MERGE_CONFIG -> GIT_MERGE_PREFERENCE
parent
de3f851e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
31 deletions
+32
-31
include/git2/merge.h
+7
-6
src/merge.c
+7
-7
tests/merge/workdir/analysis.c
+18
-18
No files found.
include/git2/merge.h
View file @
eff531e1
...
...
@@ -270,22 +270,23 @@ typedef enum {
typedef
enum
{
/*
* No configuration was found that suggests a behavior for merge.
* No configuration was found that suggests a preferred behavior for
* merge.
*/
GIT_MERGE_
CONFIG
_NONE
=
0
,
GIT_MERGE_
PREFERENCE
_NONE
=
0
,
/**
* There is a `merge.ff=false` configuration setting, suggesting that
* the user does not want to allow a fast-forward merge.
*/
GIT_MERGE_
CONFIG
_NO_FASTFORWARD
=
(
1
<<
0
),
GIT_MERGE_
PREFERENCE
_NO_FASTFORWARD
=
(
1
<<
0
),
/**
* There is a `merge.ff=only` configuration setting, suggesting that
* the user only wants fast-forward merges.
*/
GIT_MERGE_
CONFIG
_FASTFORWARD_ONLY
=
(
1
<<
1
),
}
git_merge_
config
_t
;
GIT_MERGE_
PREFERENCE
_FASTFORWARD_ONLY
=
(
1
<<
1
),
}
git_merge_
preference
_t
;
/**
* Analyzes the given branch(es) and determines the opportunities for
...
...
@@ -299,7 +300,7 @@ typedef enum {
*/
GIT_EXTERN
(
int
)
git_merge_analysis
(
git_merge_analysis_t
*
analysis_out
,
git_merge_
config_t
*
config
_out
,
git_merge_
preference_t
*
preference
_out
,
git_repository
*
repo
,
const
git_merge_head
**
their_heads
,
size_t
their_heads_len
);
...
...
src/merge.c
View file @
eff531e1
...
...
@@ -2564,13 +2564,13 @@ done:
return
error
;
}
static
int
merge_
config
(
git_merge_config
_t
*
out
,
git_repository
*
repo
)
static
int
merge_
preference
(
git_merge_preference
_t
*
out
,
git_repository
*
repo
)
{
git_config
*
config
;
const
char
*
value
;
int
bool_value
,
error
=
0
;
*
out
=
GIT_MERGE_
CONFIG
_NONE
;
*
out
=
GIT_MERGE_
PREFERENCE
_NONE
;
if
((
error
=
git_repository_config_snapshot
(
&
config
,
repo
))
<
0
)
goto
done
;
...
...
@@ -2586,10 +2586,10 @@ static int merge_config(git_merge_config_t *out, git_repository *repo)
if
(
git_config_parse_bool
(
&
bool_value
,
value
)
==
0
)
{
if
(
!
bool_value
)
*
out
|=
GIT_MERGE_
CONFIG
_NO_FASTFORWARD
;
*
out
|=
GIT_MERGE_
PREFERENCE
_NO_FASTFORWARD
;
}
else
{
if
(
strcasecmp
(
value
,
"only"
)
==
0
)
*
out
|=
GIT_MERGE_
CONFIG
_FASTFORWARD_ONLY
;
*
out
|=
GIT_MERGE_
PREFERENCE
_FASTFORWARD_ONLY
;
}
done:
...
...
@@ -2599,7 +2599,7 @@ done:
int
git_merge_analysis
(
git_merge_analysis_t
*
analysis_out
,
git_merge_
config_t
*
config
_out
,
git_merge_
preference_t
*
preference
_out
,
git_repository
*
repo
,
const
git_merge_head
**
their_heads
,
size_t
their_heads_len
)
...
...
@@ -2607,7 +2607,7 @@ int git_merge_analysis(
git_merge_head
*
ancestor_head
=
NULL
,
*
our_head
=
NULL
;
int
error
=
0
;
assert
(
analysis_out
&&
config
_out
&&
repo
&&
their_heads
);
assert
(
analysis_out
&&
preference
_out
&&
repo
&&
their_heads
);
if
(
their_heads_len
!=
1
)
{
giterr_set
(
GITERR_MERGE
,
"Can only merge a single branch"
);
...
...
@@ -2617,7 +2617,7 @@ int git_merge_analysis(
*
analysis_out
=
GIT_MERGE_ANALYSIS_NONE
;
if
((
error
=
merge_
config
(
config
_out
,
repo
))
<
0
)
if
((
error
=
merge_
preference
(
preference
_out
,
repo
))
<
0
)
goto
done
;
if
(
git_repository_head_unborn
(
repo
))
{
...
...
tests/merge/workdir/analysis.c
View file @
eff531e1
...
...
@@ -38,7 +38,7 @@ void test_merge_workdir_analysis__cleanup(void)
static
void
analysis_from_branch
(
git_merge_analysis_t
*
merge_analysis
,
git_merge_
config_t
*
merge_config
,
git_merge_
preference_t
*
merge_pref
,
const
char
*
branchname
)
{
git_buf
refname
=
GIT_BUF_INIT
;
...
...
@@ -50,7 +50,7 @@ static void analysis_from_branch(
cl_git_pass
(
git_reference_lookup
(
&
their_ref
,
repo
,
git_buf_cstr
(
&
refname
)));
cl_git_pass
(
git_merge_head_from_ref
(
&
their_head
,
repo
,
their_ref
));
cl_git_pass
(
git_merge_analysis
(
merge_analysis
,
merge_
config
,
repo
,
(
const
git_merge_head
**
)
&
their_head
,
1
));
cl_git_pass
(
git_merge_analysis
(
merge_analysis
,
merge_
pref
,
repo
,
(
const
git_merge_head
**
)
&
their_head
,
1
));
git_buf_free
(
&
refname
);
git_merge_head_free
(
their_head
);
...
...
@@ -60,9 +60,9 @@ static void analysis_from_branch(
void
test_merge_workdir_analysis__fastforward
(
void
)
{
git_merge_analysis_t
merge_analysis
;
git_merge_
config_t
merge_config
;
git_merge_
preference_t
merge_pref
;
analysis_from_branch
(
&
merge_analysis
,
&
merge_
config
,
FASTFORWARD_BRANCH
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
pref
,
FASTFORWARD_BRANCH
);
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_FASTFORWARD
,
(
merge_analysis
&
GIT_MERGE_ANALYSIS_FASTFORWARD
));
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_NORMAL
,
(
merge_analysis
&
GIT_MERGE_ANALYSIS_NORMAL
));
}
...
...
@@ -70,40 +70,40 @@ void test_merge_workdir_analysis__fastforward(void)
void
test_merge_workdir_analysis__no_fastforward
(
void
)
{
git_merge_analysis_t
merge_analysis
;
git_merge_
config_t
merge_config
;
git_merge_
preference_t
merge_pref
;
analysis_from_branch
(
&
merge_analysis
,
&
merge_
config
,
NOFASTFORWARD_BRANCH
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
pref
,
NOFASTFORWARD_BRANCH
);
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_NORMAL
,
merge_analysis
);
}
void
test_merge_workdir_analysis__uptodate
(
void
)
{
git_merge_analysis_t
merge_analysis
;
git_merge_
config_t
merge_config
;
git_merge_
preference_t
merge_pref
;
analysis_from_branch
(
&
merge_analysis
,
&
merge_
config
,
UPTODATE_BRANCH
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
pref
,
UPTODATE_BRANCH
);
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_UP_TO_DATE
,
merge_analysis
);
}
void
test_merge_workdir_analysis__uptodate_merging_prev_commit
(
void
)
{
git_merge_analysis_t
merge_analysis
;
git_merge_
config_t
merge_config
;
git_merge_
preference_t
merge_pref
;
analysis_from_branch
(
&
merge_analysis
,
&
merge_
config
,
PREVIOUS_BRANCH
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
pref
,
PREVIOUS_BRANCH
);
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_UP_TO_DATE
,
merge_analysis
);
}
void
test_merge_workdir_analysis__unborn
(
void
)
{
git_merge_analysis_t
merge_analysis
;
git_merge_
config_t
merge_config
;
git_merge_
preference_t
merge_pref
;
git_buf
master
=
GIT_BUF_INIT
;
git_buf_joinpath
(
&
master
,
git_repository_path
(
repo
),
"refs/heads/master"
);
p_unlink
(
git_buf_cstr
(
&
master
));
analysis_from_branch
(
&
merge_analysis
,
&
merge_
config
,
NOFASTFORWARD_BRANCH
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
pref
,
NOFASTFORWARD_BRANCH
);
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_FASTFORWARD
,
(
merge_analysis
&
GIT_MERGE_ANALYSIS_FASTFORWARD
));
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_UNBORN
,
(
merge_analysis
&
GIT_MERGE_ANALYSIS_UNBORN
));
...
...
@@ -114,27 +114,27 @@ void test_merge_workdir_analysis__fastforward_with_config_noff(void)
{
git_config
*
config
;
git_merge_analysis_t
merge_analysis
;
git_merge_
config_t
merge_config
;
git_merge_
preference_t
merge_pref
;
git_repository_config
(
&
config
,
repo
);
git_config_set_string
(
config
,
"merge.ff"
,
"false"
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
config
,
FASTFORWARD_BRANCH
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
pref
,
FASTFORWARD_BRANCH
);
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_FASTFORWARD
,
(
merge_analysis
&
GIT_MERGE_ANALYSIS_FASTFORWARD
));
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_NORMAL
,
(
merge_analysis
&
GIT_MERGE_ANALYSIS_NORMAL
));
cl_assert_equal_i
(
GIT_MERGE_
CONFIG_NO_FASTFORWARD
,
(
merge_config
&
GIT_MERGE_CONFIG
_NO_FASTFORWARD
));
cl_assert_equal_i
(
GIT_MERGE_
PREFERENCE_NO_FASTFORWARD
,
(
merge_pref
&
GIT_MERGE_PREFERENCE
_NO_FASTFORWARD
));
}
void
test_merge_workdir_analysis__no_fastforward_with_config_ffonly
(
void
)
{
git_config
*
config
;
git_merge_analysis_t
merge_analysis
;
git_merge_
config_t
merge_config
;
git_merge_
preference_t
merge_pref
;
git_repository_config
(
&
config
,
repo
);
git_config_set_string
(
config
,
"merge.ff"
,
"only"
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
config
,
NOFASTFORWARD_BRANCH
);
analysis_from_branch
(
&
merge_analysis
,
&
merge_
pref
,
NOFASTFORWARD_BRANCH
);
cl_assert_equal_i
(
GIT_MERGE_ANALYSIS_NORMAL
,
(
merge_analysis
&
GIT_MERGE_ANALYSIS_NORMAL
));
cl_assert_equal_i
(
GIT_MERGE_
CONFIG_FASTFORWARD_ONLY
,
(
merge_config
&
GIT_MERGE_CONFIG
_FASTFORWARD_ONLY
));
cl_assert_equal_i
(
GIT_MERGE_
PREFERENCE_FASTFORWARD_ONLY
,
(
merge_pref
&
GIT_MERGE_PREFERENCE
_FASTFORWARD_ONLY
));
}
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