diff options
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java index 84c2ec43dc..1a98d79f99 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java @@ -184,10 +184,27 @@ public class PatchApplier { @Nullable HunkHeader hh; - Error(String msg, String oldFileName, @Nullable HunkHeader hh) { + final boolean isGitConflict; + + Error(String msg, String oldFileName, @Nullable HunkHeader hh, + boolean isGitConflict) { this.msg = msg; this.oldFileName = oldFileName; this.hh = hh; + this.isGitConflict = isGitConflict; + } + + /** + * Signals if as part of encountering this error, conflict markers + * were added to the file. + * + * @return {@code true} if conflict markers were added for this + * error. + * + * @since 6.10 + */ + public boolean isGitConflict() { + return isGitConflict; } @Override @@ -213,12 +230,14 @@ public class PatchApplier { Error error = (Error) o; return Objects.equals(msg, error.msg) && Objects.equals(oldFileName, error.oldFileName) - && Objects.equals(hh, error.hh); + && Objects.equals(hh, error.hh) + && isGitConflict == error.isGitConflict; } @Override public int hashCode() { - return Objects.hash(msg, oldFileName, hh); + return Objects.hash(msg, oldFileName, hh, + Boolean.valueOf(isGitConflict)); } } @@ -257,8 +276,14 @@ public class PatchApplier { return errors; } - private void addError(String msg,String oldFileName, @Nullable HunkHeader hh) { - errors.add(new Error(msg, oldFileName, hh)); + private void addError(String msg, String oldFileName, + @Nullable HunkHeader hh) { + errors.add(new Error(msg, oldFileName, hh, false)); + } + + private void addErrorWithGitConflict(String msg, String oldFileName, + @Nullable HunkHeader hh) { + errors.add(new Error(msg, oldFileName, hh, true)); } } @@ -1020,7 +1045,7 @@ public class PatchApplier { // only works if the pre-image SHA is contained in the repo. // If that was the case, cherry-picking the original commit // should be preferred to apply a patch. - result.addError("cannot apply hunk", fh.getOldPath(), hh); //$NON-NLS-1$ + result.addErrorWithGitConflict("cannot apply hunk", fh.getOldPath(), hh); //$NON-NLS-1$ newLines.add(Math.min(applyAt++, newLines.size()), asBytes("<<<<<<< HEAD")); //$NON-NLS-1$ applyAt += hh.getOldImage().lineCount; |