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
903a7616
Commit
903a7616
authored
Sep 16, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2561 from jacquesg/merge-skip
No files merged may result in bogus merge conflict error
parents
52e9120c
dc68ee8d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
3 deletions
+52
-3
src/merge.c
+11
-3
tests/cherrypick/workdir.c
+41
-0
No files found.
src/merge.c
View file @
903a7616
...
...
@@ -2338,7 +2338,6 @@ done:
static
int
merge_check_workdir
(
size_t
*
conflicts
,
git_repository
*
repo
,
git_index
*
index_new
,
git_vector
*
merged_paths
)
{
git_index
*
index_repo
=
NULL
;
git_diff
*
wd_diff_list
=
NULL
;
git_diff_options
opts
=
GIT_DIFF_OPTIONS_INIT
;
int
error
=
0
;
...
...
@@ -2347,6 +2346,16 @@ static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_inde
*
conflicts
=
0
;
/* We need to have merged at least 1 file for the possibility to exist to
* have conflicts with the workdir. Passing 0 as the pathspec count paramter
* will consider all files in the working directory, that is, we may detect
* a conflict if there were untracked files in the workdir prior to starting
* the merge. This typically happens when cherry-picking a commmit whose
* changes have already been applied.
*/
if
(
merged_paths
->
length
==
0
)
return
0
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_UNTRACKED
;
/* Workdir changes may exist iff they do not conflict with changes that
...
...
@@ -2356,13 +2365,12 @@ static int merge_check_workdir(size_t *conflicts, git_repository *repo, git_inde
opts
.
pathspec
.
count
=
merged_paths
->
length
;
opts
.
pathspec
.
strings
=
(
char
**
)
merged_paths
->
contents
;
if
((
error
=
git_diff_index_to_workdir
(
&
wd_diff_list
,
repo
,
index_repo
,
&
opts
))
<
0
)
if
((
error
=
git_diff_index_to_workdir
(
&
wd_diff_list
,
repo
,
NULL
,
&
opts
))
<
0
)
goto
done
;
*
conflicts
=
wd_diff_list
->
deltas
.
length
;
done:
git_index_free
(
index_repo
);
git_diff_free
(
wd_diff_list
);
return
error
;
...
...
tests/cherrypick/workdir.c
View file @
903a7616
...
...
@@ -92,6 +92,47 @@ void test_cherrypick_workdir__automerge(void)
git_signature_free
(
signature
);
}
/* git reset --hard cfc4f0999a8367568e049af4f72e452d40828a15
* git cherry-pick a43a050c588d4e92f11a6b139680923e9728477d*/
void
test_cherrypick_workdir__empty_result
(
void
)
{
git_oid
head_oid
;
git_signature
*
signature
=
NULL
;
git_commit
*
head
=
NULL
,
*
commit
=
NULL
;
git_oid
cherry_oid
;
const
char
*
cherrypick_oid
=
"a43a050c588d4e92f11a6b139680923e9728477d"
;
struct
merge_index_entry
merge_index_entries
[]
=
{
{
0100644
,
"19c5c7207054604b69c84d08a7571ef9672bb5c2"
,
0
,
"file1.txt"
},
{
0100644
,
"a58ca3fee5eb68b11adc2703e5843f968c9dad1e"
,
0
,
"file2.txt"
},
{
0100644
,
"28d9eb4208074ad1cc84e71ccc908b34573f05d2"
,
0
,
"file3.txt"
},
};
cl_git_pass
(
git_signature_new
(
&
signature
,
"Picker"
,
"picker@example.org"
,
time
(
NULL
),
0
));
git_oid_fromstr
(
&
head_oid
,
"cfc4f0999a8367568e049af4f72e452d40828a15"
);
/* Create an untracked file that should not conflict */
cl_git_mkfile
(
TEST_REPO_PATH
"/file4.txt"
,
""
);
cl_assert
(
git_path_exists
(
TEST_REPO_PATH
"/file4.txt"
));
cl_git_pass
(
git_commit_lookup
(
&
head
,
repo
,
&
head_oid
));
cl_git_pass
(
git_reset
(
repo
,
(
git_object
*
)
head
,
GIT_RESET_HARD
,
NULL
,
NULL
));
git_oid_fromstr
(
&
cherry_oid
,
cherrypick_oid
);
cl_git_pass
(
git_commit_lookup
(
&
commit
,
repo
,
&
cherry_oid
));
cl_git_pass
(
git_cherrypick
(
repo
,
commit
,
NULL
));
/* The resulting tree should not have changed, the change was already on HEAD */
cl_assert
(
merge_test_index
(
repo_index
,
merge_index_entries
,
3
));
git_commit_free
(
head
);
git_commit_free
(
commit
);
git_signature_free
(
signature
);
}
/* git reset --hard bafbf6912c09505ac60575cd43d3f2aba3bd84d8
* git cherry-pick e9b63f3655b2ad80c0ff587389b5a9589a3a7110
*/
...
...
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