Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GitWrapper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Seibt
GitWrapper
Commits
49a39a28
Commit
49a39a28
authored
7 years ago
by
Georg Seibt
Browse files
Options
Downloads
Patches
Plain Diff
improve robustness of LocalRepository#blameUnmergedFile #3
parent
18d93436
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/de/uni_passau/fim/seibt/gitwrapper/repo/LocalRepository.java
+30
-11
30 additions, 11 deletions
...uni_passau/fim/seibt/gitwrapper/repo/LocalRepository.java
with
30 additions
and
11 deletions
src/de/uni_passau/fim/seibt/gitwrapper/repo/LocalRepository.java
+
30
−
11
View file @
49a39a28
...
...
@@ -23,6 +23,10 @@ import java.util.stream.Collectors;
import
de.uni_passau.fim.seibt.gitwrapper.process.ProcessExecutor.ExecRes
;
import
org.apache.commons.io.FileUtils
;
import
static
de
.
uni_passau
.
fim
.
seibt
.
gitwrapper
.
repo
.
LocalRepository
.
ConflictMarker
.
CONFLICT_END
;
import
static
de
.
uni_passau
.
fim
.
seibt
.
gitwrapper
.
repo
.
LocalRepository
.
ConflictMarker
.
CONFLICT_MIDDLE
;
import
static
de
.
uni_passau
.
fim
.
seibt
.
gitwrapper
.
repo
.
LocalRepository
.
ConflictMarker
.
CONFLICT_START
;
/**
* A git {@link Repository}.
*/
...
...
@@ -46,9 +50,24 @@ public class LocalRepository extends Repository {
// The type returned for commits by 'git cat-file -t".
private
static
final
String
TYPE_COMMIT
=
"commit"
;
private
static
final
String
CONFLICT_START
=
"<<<<<<<"
;
private
static
final
String
CONFLICT_MIDDLE
=
"======="
;
private
static
final
String
CONFLICT_END
=
">>>>>>>"
;
/**
* An enumeration of the three possible conflict markers in an unmerged file.
*/
enum
ConflictMarker
{
CONFLICT_START
(
"<<<<<<<"
),
CONFLICT_MIDDLE
(
"======="
),
CONFLICT_END
(
">>>>>>>"
);
/**
* The expected characters at the beginning of a line representing a
* conflict marker.
*/
public
final
String
prefix
;
ConflictMarker
(
String
prefix
)
{
this
.
prefix
=
prefix
;
}
}
// The prefixes of the full symbolic names of (remote) branches.
private
static
final
String
FULL_SYMBOLIC_BRANCH
=
"refs/heads/"
;
...
...
@@ -472,22 +491,22 @@ public class LocalRepository extends Repository {
List
<
BlameLine
>
left
=
null
;
List
<
BlameLine
>
right
=
null
;
String
lastMarker
=
null
;
ConflictMarker
lastMarker
=
null
;
for
(
BlameLine
line
:
blame
.
get
())
{
if
(
line
.
line
.
startsWith
(
CONFLICT_START
))
{
if
(
line
.
line
.
startsWith
(
CONFLICT_START
.
prefix
))
{
left
=
new
ArrayList
<>();
right
=
new
ArrayList
<>();
lastMarker
=
CONFLICT_START
;
}
else
if
(
line
.
line
.
startsWith
(
CONFLICT_MIDDLE
))
{
}
else
if
(
lastMarker
==
CONFLICT_START
&&
line
.
line
.
startsWith
(
CONFLICT_MIDDLE
.
prefix
))
{
lastMarker
=
CONFLICT_MIDDLE
;
}
else
if
(
line
.
line
.
startsWith
(
CONFLICT_END
))
{
}
else
if
(
lastMarker
==
CONFLICT_MIDDLE
&&
line
.
line
.
startsWith
(
CONFLICT_END
.
prefix
))
{
conflicts
.
add
(
new
MergeConflict
(
left
,
right
));
lastMarker
=
CONFLICT_END
;
}
else
if
(
CONFLICT_START
.
equals
(
lastMarker
)
)
{
assert
left
!=
null
;
left
.
add
(
line
);
}
else
if
(
CONFLICT_MIDDLE
.
equals
(
lastMarker
)
)
{
assert
right
!=
null
;
right
.
add
(
line
);
}
else
if
(
CONFLICT_START
==
lastMarker
)
{
left
.
add
(
line
);
}
else
if
(
CONFLICT_MIDDLE
==
lastMarker
)
{
right
.
add
(
line
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment