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
fea24c53
Commit
fea24c53
authored
Mar 16, 2015
by
Jeff Hostetler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PERF: In MERGE, lazily compute is_binary
parent
d675982a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
9 deletions
+19
-9
src/merge.c
+19
-8
src/merge.h
+0
-1
No files found.
src/merge.c
View file @
fea24c53
...
@@ -61,6 +61,11 @@ struct merge_diff_df_data {
...
@@ -61,6 +61,11 @@ struct merge_diff_df_data {
git_merge_diff
*
prev_conflict
;
git_merge_diff
*
prev_conflict
;
};
};
GIT_INLINE
(
int
)
merge_diff_detect_binary
(
bool
*
binary_out
,
git_repository
*
repo
,
const
git_merge_diff
*
conflict
);
/* Merge base computation */
/* Merge base computation */
...
@@ -662,6 +667,7 @@ static int merge_conflict_resolve_automerge(
...
@@ -662,6 +667,7 @@ static int merge_conflict_resolve_automerge(
git_odb
*
odb
=
NULL
;
git_odb
*
odb
=
NULL
;
git_oid
automerge_oid
;
git_oid
automerge_oid
;
int
error
=
0
;
int
error
=
0
;
bool
binary
=
false
;
assert
(
resolved
&&
diff_list
&&
conflict
);
assert
(
resolved
&&
diff_list
&&
conflict
);
...
@@ -697,7 +703,9 @@ static int merge_conflict_resolve_automerge(
...
@@ -697,7 +703,9 @@ static int merge_conflict_resolve_automerge(
return
0
;
return
0
;
/* Reject binary conflicts */
/* Reject binary conflicts */
if
(
conflict
->
binary
)
if
((
error
=
merge_diff_detect_binary
(
&
binary
,
diff_list
->
repo
,
conflict
))
<
0
)
return
error
;
if
(
binary
)
return
0
;
return
0
;
ancestor
=
GIT_MERGE_INDEX_ENTRY_EXISTS
(
conflict
->
ancestor_entry
)
?
ancestor
=
GIT_MERGE_INDEX_ENTRY_EXISTS
(
conflict
->
ancestor_entry
)
?
...
@@ -1303,35 +1311,39 @@ GIT_INLINE(int) merge_diff_detect_type(
...
@@ -1303,35 +1311,39 @@ GIT_INLINE(int) merge_diff_detect_type(
}
}
GIT_INLINE
(
int
)
merge_diff_detect_binary
(
GIT_INLINE
(
int
)
merge_diff_detect_binary
(
bool
*
binary_out
,
git_repository
*
repo
,
git_repository
*
repo
,
git_merge_diff
*
conflict
)
const
git_merge_diff
*
conflict
)
{
{
git_blob
*
ancestor_blob
=
NULL
,
*
our_blob
=
NULL
,
*
their_blob
=
NULL
;
git_blob
*
ancestor_blob
=
NULL
,
*
our_blob
=
NULL
,
*
their_blob
=
NULL
;
int
error
=
0
;
int
error
=
0
;
bool
binary
=
false
;
if
(
GIT_MERGE_INDEX_ENTRY_ISFILE
(
conflict
->
ancestor_entry
))
{
if
(
GIT_MERGE_INDEX_ENTRY_ISFILE
(
conflict
->
ancestor_entry
))
{
if
((
error
=
git_blob_lookup
(
&
ancestor_blob
,
repo
,
&
conflict
->
ancestor_entry
.
id
))
<
0
)
if
((
error
=
git_blob_lookup
(
&
ancestor_blob
,
repo
,
&
conflict
->
ancestor_entry
.
id
))
<
0
)
goto
done
;
goto
done
;
conflict
->
binary
=
git_blob_is_binary
(
ancestor_blob
);
binary
=
git_blob_is_binary
(
ancestor_blob
);
}
}
if
(
!
conflict
->
binary
&&
if
(
!
binary
&&
GIT_MERGE_INDEX_ENTRY_ISFILE
(
conflict
->
our_entry
))
{
GIT_MERGE_INDEX_ENTRY_ISFILE
(
conflict
->
our_entry
))
{
if
((
error
=
git_blob_lookup
(
&
our_blob
,
repo
,
&
conflict
->
our_entry
.
id
))
<
0
)
if
((
error
=
git_blob_lookup
(
&
our_blob
,
repo
,
&
conflict
->
our_entry
.
id
))
<
0
)
goto
done
;
goto
done
;
conflict
->
binary
=
git_blob_is_binary
(
our_blob
);
binary
=
git_blob_is_binary
(
our_blob
);
}
}
if
(
!
conflict
->
binary
&&
if
(
!
binary
&&
GIT_MERGE_INDEX_ENTRY_ISFILE
(
conflict
->
their_entry
))
{
GIT_MERGE_INDEX_ENTRY_ISFILE
(
conflict
->
their_entry
))
{
if
((
error
=
git_blob_lookup
(
&
their_blob
,
repo
,
&
conflict
->
their_entry
.
id
))
<
0
)
if
((
error
=
git_blob_lookup
(
&
their_blob
,
repo
,
&
conflict
->
their_entry
.
id
))
<
0
)
goto
done
;
goto
done
;
conflict
->
binary
=
git_blob_is_binary
(
their_blob
);
binary
=
git_blob_is_binary
(
their_blob
);
}
}
*
binary_out
=
binary
;
done
:
done
:
git_blob_free
(
ancestor_blob
);
git_blob_free
(
ancestor_blob
);
git_blob_free
(
our_blob
);
git_blob_free
(
our_blob
);
...
@@ -1411,7 +1423,6 @@ static int merge_diff_list_insert_conflict(
...
@@ -1411,7 +1423,6 @@ static int merge_diff_list_insert_conflict(
if
((
conflict
=
merge_diff_from_index_entries
(
diff_list
,
tree_items
))
==
NULL
||
if
((
conflict
=
merge_diff_from_index_entries
(
diff_list
,
tree_items
))
==
NULL
||
merge_diff_detect_type
(
conflict
)
<
0
||
merge_diff_detect_type
(
conflict
)
<
0
||
merge_diff_detect_df_conflict
(
merge_df_data
,
conflict
)
<
0
||
merge_diff_detect_df_conflict
(
merge_df_data
,
conflict
)
<
0
||
merge_diff_detect_binary
(
diff_list
->
repo
,
conflict
)
<
0
||
git_vector_insert
(
&
diff_list
->
conflicts
,
conflict
)
<
0
)
git_vector_insert
(
&
diff_list
->
conflicts
,
conflict
)
<
0
)
return
-
1
;
return
-
1
;
...
...
src/merge.h
View file @
fea24c53
...
@@ -107,7 +107,6 @@ typedef struct {
...
@@ -107,7 +107,6 @@ typedef struct {
git_index_entry
their_entry
;
git_index_entry
their_entry
;
git_delta_t
their_status
;
git_delta_t
their_status
;
int
binary
:
1
;
}
git_merge_diff
;
}
git_merge_diff
;
int
git_merge__bases_many
(
int
git_merge__bases_many
(
...
...
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