aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2024-12-05 23:33:50 +0000
committerGerrit Code Review <support@gerrithub.io>2024-12-05 23:33:50 +0000
commit46bc9c14d93c9609b277cf545eb2be21c6ed219e (patch)
tree202048b705ed82f4ad6eb62eb4dc43b20d620a9b /org.eclipse.jgit/src/org/eclipse
parentfb6adb0366bc3e15f30952fe49456b1f96bcf1af (diff)
parent4156bdfe8ef8af2cc1d48a185e62fdf83e14c8ed (diff)
downloadjgit-46bc9c14d93c9609b277cf545eb2be21c6ed219e.tar.gz
jgit-46bc9c14d93c9609b277cf545eb2be21c6ed219e.zip
Merge changes I172c43ff,I2a4c5743,Icc4b8d2f into stable-6.10
* changes: Mark Attribute#getValue as @Nullable Fix potential NPE in ResolveMerger#getAttributesContentMergeStrategy Fix NPE in DiffFormatter#getDiffDriver
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java9
3 files changed, 20 insertions, 10 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java
index fe3e22a21f..9c4d8700a2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/attributes/Attribute.java
@@ -9,6 +9,8 @@
*/
package org.eclipse.jgit.attributes;
+import org.eclipse.jgit.annotations.Nullable;
+
/**
* Represents an attribute.
* <p>
@@ -139,6 +141,7 @@ public final class Attribute {
*
* @return the attribute value (may be <code>null</code>)
*/
+ @Nullable
public String getValue() {
return value;
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
index fa446e18cd..6375a60383 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/DiffFormatter.java
@@ -1356,13 +1356,17 @@ public class DiffFormatter implements AutoCloseable {
private DiffDriver getDiffDriver(DiffEntry entry) {
Attribute diffAttr = entry.getDiffAttribute();
- if (diffAttr != null) {
- try {
- return DiffDriver.valueOf(diffAttr.getValue());
- } catch (IllegalArgumentException e) {
- return null;
- }
+ if (diffAttr == null) {
+ return null;
+ }
+ String diffAttrValue = diffAttr.getValue();
+ if (diffAttrValue == null) {
+ return null;
+ }
+ try {
+ return DiffDriver.valueOf(diffAttrValue);
+ } catch (IllegalArgumentException e) {
+ return null;
}
- return null;
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
index a6a287bcf4..a50a6440b9 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
@@ -1507,9 +1507,12 @@ public class ResolveMerger extends ThreeWayMerger {
private ContentMergeStrategy getAttributesContentMergeStrategy(
Attributes attributes, ContentMergeStrategy strategy) {
Attribute attr = attributes.get(Constants.ATTR_MERGE);
- if (attr != null && attr.getValue()
- .equals(Constants.ATTR_BUILTIN_UNION_MERGE_DRIVER)) {
- return ContentMergeStrategy.UNION;
+ if (attr != null) {
+ String attrValue = attr.getValue();
+ if (attrValue != null && attrValue
+ .equals(Constants.ATTR_BUILTIN_UNION_MERGE_DRIVER)) {
+ return ContentMergeStrategy.UNION;
+ }
}
return strategy;
}