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
fc36800e
Commit
fc36800e
authored
Aug 08, 2013
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get rid of some quick hacks
parent
96d799aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
+21
-27
src/checkout_conflicts.c
+21
-27
No files found.
src/checkout_conflicts.c
View file @
fc36800e
...
@@ -23,7 +23,8 @@ typedef struct {
...
@@ -23,7 +23,8 @@ typedef struct {
const
git_index_entry
*
theirs
;
const
git_index_entry
*
theirs
;
int
name_collision
:
1
,
int
name_collision
:
1
,
directoryfile
:
1
;
directoryfile
:
1
,
one_to_two
:
1
;
}
checkout_conflictdata
;
}
checkout_conflictdata
;
GIT_INLINE
(
int
)
checkout_idxentry_cmp
(
GIT_INLINE
(
int
)
checkout_idxentry_cmp
(
...
@@ -104,7 +105,6 @@ GIT_INLINE(int) checkout_conflicts_cmp_entry(
...
@@ -104,7 +105,6 @@ GIT_INLINE(int) checkout_conflicts_cmp_entry(
const
char
*
path
,
const
char
*
path
,
const
git_index_entry
*
entry
)
const
git_index_entry
*
entry
)
{
{
/* TODO: is strcmp right here? should we use index->strcomp ? */
return
strcmp
((
const
char
*
)
path
,
entry
->
path
);
return
strcmp
((
const
char
*
)
path
,
entry
->
path
);
}
}
...
@@ -207,6 +207,8 @@ static int checkout_conflicts_load_byname_entry(
...
@@ -207,6 +207,8 @@ static int checkout_conflicts_load_byname_entry(
if
(
name_entry
->
theirs
)
{
if
(
name_entry
->
theirs
)
{
if
(
strcmp
(
name_entry
->
ancestor
,
name_entry
->
theirs
)
==
0
)
if
(
strcmp
(
name_entry
->
ancestor
,
name_entry
->
theirs
)
==
0
)
theirs
=
ancestor
;
theirs
=
ancestor
;
else
if
(
name_entry
->
ours
&&
strcmp
(
name_entry
->
ours
,
name_entry
->
theirs
)
==
0
)
theirs
=
ours
;
else
if
((
theirs
=
checkout_conflicts_search_branch
(
conflicts
,
name_entry
->
theirs
))
==
NULL
||
else
if
((
theirs
=
checkout_conflicts_search_branch
(
conflicts
,
name_entry
->
theirs
))
==
NULL
||
theirs
->
theirs
==
NULL
)
{
theirs
->
theirs
==
NULL
)
{
giterr_set
(
GITERR_INDEX
,
giterr_set
(
GITERR_INDEX
,
...
@@ -267,6 +269,10 @@ static int checkout_conflicts_coalesce_renames(
...
@@ -267,6 +269,10 @@ static int checkout_conflicts_coalesce_renames(
if
(
their_conflict
->
name_collision
)
if
(
their_conflict
->
name_collision
)
ancestor_conflict
->
name_collision
=
1
;
ancestor_conflict
->
name_collision
=
1
;
}
}
if
(
our_conflict
&&
our_conflict
!=
ancestor_conflict
&&
their_conflict
&&
their_conflict
!=
ancestor_conflict
)
ancestor_conflict
->
one_to_two
=
1
;
}
}
git_vector_remove_matching
(
conflicts
,
checkout_conflictdata_empty
);
git_vector_remove_matching
(
conflicts
,
checkout_conflictdata_empty
);
...
@@ -275,29 +281,27 @@ done:
...
@@ -275,29 +281,27 @@ done:
return
error
;
return
error
;
}
}
/* TODO: does this exist elsewhere? */
GIT_INLINE
(
void
)
path_equal_or_prefixed
(
GIT_INLINE
(
void
)
path_equal_or_prefixed
(
bool
*
path_eq
,
bool
*
path_eq
,
bool
*
path_prefixed
,
bool
*
path_prefixed
,
const
char
*
parent
,
const
char
*
parent
,
const
char
*
child
)
const
char
*
child
)
{
{
size_t
child_len
=
strlen
(
child
);
const
char
*
p
,
*
c
;
size_t
parent_len
=
strlen
(
parent
);
if
(
child_len
==
parent_len
)
{
*
path_eq
=
(
strcmp
(
parent
,
child
)
==
0
);
*
path_prefixed
=
0
;
return
;
}
*
path_eq
=
0
;
*
path_eq
=
0
;
*
path_prefixed
=
0
;
if
(
child_len
<
parent_len
||
for
(
p
=
parent
,
c
=
child
;
*
p
&&
*
c
;
p
++
,
c
++
)
{
strncmp
(
parent
,
child
,
parent_len
)
!=
0
)
if
(
*
p
!=
*
c
)
*
path_prefixed
=
0
;
return
;
else
}
*
path_prefixed
=
(
child
[
parent_len
]
==
'/'
);
if
(
!*
p
)
*
path_prefixed
=
(
*
c
==
'/'
);
if
(
!*
p
&&
!*
c
)
*
path_eq
=
1
;
}
}
static
int
checkout_conflicts_mark_directoryfile
(
static
int
checkout_conflicts_mark_directoryfile
(
...
@@ -483,7 +487,6 @@ static int checkout_write_merge(
...
@@ -483,7 +487,6 @@ static int checkout_write_merge(
/* Rename 2->1 conflicts need the branch name appended */
/* Rename 2->1 conflicts need the branch name appended */
if
(
conflict
->
name_collision
)
{
if
(
conflict
->
name_collision
)
{
/* TODO: strcmp? */
if
((
error
=
conflict_path_suffixed
(
&
path_suffixed
,
result
.
path
,
if
((
error
=
conflict_path_suffixed
(
&
path_suffixed
,
result
.
path
,
(
strcmp
(
result
.
path
,
conflict
->
ours
->
path
)
==
0
?
(
strcmp
(
result
.
path
,
conflict
->
ours
->
path
)
==
0
?
our_label_raw
:
their_label_raw
)))
<
0
)
our_label_raw
:
their_label_raw
)))
<
0
)
...
@@ -514,15 +517,6 @@ done:
...
@@ -514,15 +517,6 @@ done:
return
error
;
return
error
;
}
}
GIT_INLINE
(
bool
)
conflict_is_1_to_2
(
checkout_conflictdata
*
conflict
)
{
/* TODO: can't we detect these when we coalesce? */
return
conflict
->
ancestor
&&
conflict
->
ours
&&
conflict
->
theirs
&&
(
strcmp
(
conflict
->
ancestor
->
path
,
conflict
->
ours
->
path
)
!=
0
&&
strcmp
(
conflict
->
ancestor
->
path
,
conflict
->
theirs
->
path
)
!=
0
&&
strcmp
(
conflict
->
ours
->
path
,
conflict
->
theirs
->
path
)
!=
0
);
}
int
git_checkout__conflicts
(
checkout_data
*
data
)
int
git_checkout__conflicts
(
checkout_data
*
data
)
{
{
git_vector
conflicts
=
GIT_VECTOR_INIT
;
git_vector
conflicts
=
GIT_VECTOR_INIT
;
...
@@ -569,7 +563,7 @@ int git_checkout__conflicts(checkout_data *data)
...
@@ -569,7 +563,7 @@ int git_checkout__conflicts(checkout_data *data)
/* Add/add conflicts and rename 1->2 conflicts, write the
/* Add/add conflicts and rename 1->2 conflicts, write the
* ours/theirs sides (potentially name mangled).
* ours/theirs sides (potentially name mangled).
*/
*/
else
if
(
conflict
_is_1_to_2
(
conflict
)
)
else
if
(
conflict
->
one_to_two
)
error
=
checkout_write_entries
(
data
,
conflict
);
error
=
checkout_write_entries
(
data
,
conflict
);
/* If all sides are links, write the ours side */
/* If all sides are links, write the ours side */
...
...
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