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
a4e2c36a
Commit
a4e2c36a
authored
Apr 23, 2014
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge: checkout default shouldn't clobber given
parent
26564d80
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
15 deletions
+14
-15
src/merge.c
+3
-5
tests/merge/workdir/dirty.c
+7
-8
tests/merge/workdir/simple.c
+4
-2
No files found.
src/merge.c
View file @
a4e2c36a
...
@@ -2186,8 +2186,6 @@ static int merge_normalize_checkout_opts(
...
@@ -2186,8 +2186,6 @@ static int merge_normalize_checkout_opts(
const
git_merge_head
**
their_heads
)
const
git_merge_head
**
their_heads
)
{
{
int
error
=
0
;
int
error
=
0
;
unsigned
int
default_checkout_strategy
=
GIT_CHECKOUT_SAFE
|
GIT_CHECKOUT_ALLOW_CONFLICTS
;
GIT_UNUSED
(
repo
);
GIT_UNUSED
(
repo
);
...
@@ -2195,12 +2193,12 @@ static int merge_normalize_checkout_opts(
...
@@ -2195,12 +2193,12 @@ static int merge_normalize_checkout_opts(
memcpy
(
checkout_opts
,
given_checkout_opts
,
sizeof
(
git_checkout_options
));
memcpy
(
checkout_opts
,
given_checkout_opts
,
sizeof
(
git_checkout_options
));
else
{
else
{
git_checkout_options
default_checkout_opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
git_checkout_options
default_checkout_opts
=
GIT_CHECKOUT_OPTIONS_INIT
;
default_checkout_opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
|
GIT_CHECKOUT_ALLOW_CONFLICTS
;
memcpy
(
checkout_opts
,
&
default_checkout_opts
,
sizeof
(
git_checkout_options
));
memcpy
(
checkout_opts
,
&
default_checkout_opts
,
sizeof
(
git_checkout_options
));
}
}
if
(
!
checkout_opts
->
checkout_strategy
)
checkout_opts
->
checkout_strategy
=
default_checkout_strategy
;
/* TODO: for multiple ancestors in merge-recursive, this is "merged common ancestors" */
/* TODO: for multiple ancestors in merge-recursive, this is "merged common ancestors" */
if
(
!
checkout_opts
->
ancestor_label
)
{
if
(
!
checkout_opts
->
ancestor_label
)
{
if
(
ancestor_head
&&
ancestor_head
->
commit
)
if
(
ancestor_head
&&
ancestor_head
->
commit
)
...
...
tests/merge/workdir/dirty.c
View file @
a4e2c36a
...
@@ -86,7 +86,7 @@ static void set_core_autocrlf_to(git_repository *repo, bool value)
...
@@ -86,7 +86,7 @@ static void set_core_autocrlf_to(git_repository *repo, bool value)
git_config_free
(
cfg
);
git_config_free
(
cfg
);
}
}
static
int
merge_branch
(
int
merge_file_favor
,
int
checkout_strategy
)
static
int
merge_branch
(
void
)
{
{
git_oid
their_oids
[
1
];
git_oid
their_oids
[
1
];
git_merge_head
*
their_heads
[
1
];
git_merge_head
*
their_heads
[
1
];
...
@@ -97,8 +97,7 @@ static int merge_branch(int merge_file_favor, int checkout_strategy)
...
@@ -97,8 +97,7 @@ static int merge_branch(int merge_file_favor, int checkout_strategy)
cl_git_pass
(
git_oid_fromstr
(
&
their_oids
[
0
],
MERGE_BRANCH_OID
));
cl_git_pass
(
git_oid_fromstr
(
&
their_oids
[
0
],
MERGE_BRANCH_OID
));
cl_git_pass
(
git_merge_head_from_id
(
&
their_heads
[
0
],
repo
,
&
their_oids
[
0
]));
cl_git_pass
(
git_merge_head_from_id
(
&
their_heads
[
0
],
repo
,
&
their_oids
[
0
]));
merge_opts
.
file_favor
=
merge_file_favor
;
checkout_opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
|
GIT_CHECKOUT_ALLOW_CONFLICTS
;
checkout_opts
.
checkout_strategy
=
checkout_strategy
;
error
=
git_merge
(
repo
,
(
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
]);
git_merge_head_free
(
their_heads
[
0
]);
...
@@ -214,7 +213,7 @@ static int merge_dirty_files(char *dirty_files[])
...
@@ -214,7 +213,7 @@ static int merge_dirty_files(char *dirty_files[])
write_files
(
dirty_files
);
write_files
(
dirty_files
);
error
=
merge_branch
(
0
,
0
);
error
=
merge_branch
();
git_object_free
(
head_object
);
git_object_free
(
head_object
);
git_reference_free
(
head
);
git_reference_free
(
head
);
...
@@ -237,7 +236,7 @@ static int merge_differently_filtered_files(char *files[])
...
@@ -237,7 +236,7 @@ static int merge_differently_filtered_files(char *files[])
cl_git_pass
(
git_index_write
(
repo_index
));
cl_git_pass
(
git_index_write
(
repo_index
));
error
=
merge_branch
(
0
,
0
);
error
=
merge_branch
();
git_object_free
(
head_object
);
git_object_free
(
head_object
);
git_reference_free
(
head
);
git_reference_free
(
head
);
...
@@ -248,7 +247,7 @@ static int merge_differently_filtered_files(char *files[])
...
@@ -248,7 +247,7 @@ static int merge_differently_filtered_files(char *files[])
static
int
merge_staged_files
(
char
*
staged_files
[])
static
int
merge_staged_files
(
char
*
staged_files
[])
{
{
stage_random_files
(
staged_files
);
stage_random_files
(
staged_files
);
return
merge_branch
(
0
,
0
);
return
merge_branch
();
}
}
void
test_merge_workdir_dirty__unaffected_dirty_files_allowed
(
void
)
void
test_merge_workdir_dirty__unaffected_dirty_files_allowed
(
void
)
...
@@ -271,7 +270,7 @@ void test_merge_workdir_dirty__unstaged_deletes_maintained(void)
...
@@ -271,7 +270,7 @@ void test_merge_workdir_dirty__unstaged_deletes_maintained(void)
cl_git_pass
(
p_unlink
(
"merge-resolve/unchanged.txt"
));
cl_git_pass
(
p_unlink
(
"merge-resolve/unchanged.txt"
));
cl_git_pass
(
merge_branch
(
0
,
0
));
cl_git_pass
(
merge_branch
());
git_object_free
(
head_object
);
git_object_free
(
head_object
);
git_reference_free
(
head
);
git_reference_free
(
head
);
...
@@ -309,7 +308,7 @@ void test_merge_workdir_dirty__identical_staged_files_allowed(void)
...
@@ -309,7 +308,7 @@ void test_merge_workdir_dirty__identical_staged_files_allowed(void)
stage_content
(
content
);
stage_content
(
content
);
git_index_write
(
repo_index
);
git_index_write
(
repo_index
);
cl_git_pass
(
merge_branch
(
0
,
0
));
cl_git_pass
(
merge_branch
());
}
}
}
}
...
...
tests/merge/workdir/simple.c
View file @
a4e2c36a
...
@@ -92,7 +92,7 @@ void test_merge_workdir_simple__cleanup(void)
...
@@ -92,7 +92,7 @@ void test_merge_workdir_simple__cleanup(void)
cl_git_sandbox_cleanup
();
cl_git_sandbox_cleanup
();
}
}
static
void
merge_simple_branch
(
int
merge_file_favor
,
int
checkout_strategy
)
static
void
merge_simple_branch
(
int
merge_file_favor
,
int
addl_
checkout_strategy
)
{
{
git_oid
their_oids
[
1
];
git_oid
their_oids
[
1
];
git_merge_head
*
their_heads
[
1
];
git_merge_head
*
their_heads
[
1
];
...
@@ -103,7 +103,9 @@ static void merge_simple_branch(int merge_file_favor, int checkout_strategy)
...
@@ -103,7 +103,9 @@ static void merge_simple_branch(int merge_file_favor, int checkout_strategy)
cl_git_pass
(
git_merge_head_from_id
(
&
their_heads
[
0
],
repo
,
&
their_oids
[
0
]));
cl_git_pass
(
git_merge_head_from_id
(
&
their_heads
[
0
],
repo
,
&
their_oids
[
0
]));
merge_opts
.
file_favor
=
merge_file_favor
;
merge_opts
.
file_favor
=
merge_file_favor
;
checkout_opts
.
checkout_strategy
=
checkout_strategy
;
checkout_opts
.
checkout_strategy
=
GIT_CHECKOUT_SAFE
|
GIT_CHECKOUT_ALLOW_CONFLICTS
|
addl_checkout_strategy
;
cl_git_pass
(
git_merge
(
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
]);
git_merge_head_free
(
their_heads
[
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