This is an automated email from the ASF dual-hosted git repository.
bamaer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 88f9576f95 Issue #8929 : Show the missing side as empty in the visual
diff of an added or deleted file (#9102)
88f9576f95 is described below
commit 88f9576f9521341ec80050a483867d0158fe95ea
Author: Sai Asish Y <[email protected]>
AuthorDate: Fri Oct 30 23:45:09 2026 -0700
Issue #8929 : Show the missing side as empty in the visual diff of an added
or deleted file (#9102)
Signed-off-by: Sai Asish Y <[email protected]>
---
.../src/main/java/org/apache/hop/git/GitGuiPlugin.java | 16 ++++++++++++----
.../hop/git/info/GitInfoExplorerFileTypeHandler.java | 16 ++++++++++++----
.../src/main/java/org/apache/hop/git/model/UIGit.java | 12 +++++++++++-
.../test/java/org/apache/hop/git/model/UIGitTest.java | 10 ++++++++++
4 files changed, 45 insertions(+), 9 deletions(-)
diff --git
a/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
b/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
index 1ee3dbe178..3190c82739 100644
--- a/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
+++ b/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
@@ -1504,9 +1504,13 @@ public class GitGuiPlugin
InputStream xmlStreamNew = git.open(filename, commitIdNew)) {
PipelineMeta pipelineMetaOld =
- new PipelineMeta(xmlStreamOld, hopGui.getMetadataProvider(),
hopGui.getVariables());
+ xmlStreamOld == null
+ ? new PipelineMeta()
+ : new PipelineMeta(xmlStreamOld, hopGui.getMetadataProvider(),
hopGui.getVariables());
PipelineMeta pipelineMetaNew =
- new PipelineMeta(xmlStreamNew, hopGui.getMetadataProvider(),
hopGui.getVariables());
+ xmlStreamNew == null
+ ? new PipelineMeta()
+ : new PipelineMeta(xmlStreamNew, hopGui.getMetadataProvider(),
hopGui.getVariables());
boolean ignorePosition =
GitConfigSingleton.getConfig().isIgnoringPositionInDiff();
Map<String, String> renamed =
@@ -1566,9 +1570,13 @@ public class GitGuiPlugin
InputStream xmlStreamNew = git.open(filename, commitIdNew)) {
WorkflowMeta workflowMetaOld =
- new WorkflowMeta(xmlStreamOld, hopGui.getMetadataProvider(),
hopGui.getVariables());
+ xmlStreamOld == null
+ ? new WorkflowMeta()
+ : new WorkflowMeta(xmlStreamOld, hopGui.getMetadataProvider(),
hopGui.getVariables());
WorkflowMeta workflowMetaNew =
- new WorkflowMeta(xmlStreamNew, hopGui.getMetadataProvider(),
hopGui.getVariables());
+ xmlStreamNew == null
+ ? new WorkflowMeta()
+ : new WorkflowMeta(xmlStreamNew, hopGui.getMetadataProvider(),
hopGui.getVariables());
boolean ignorePosition =
GitConfigSingleton.getConfig().isIgnoringPositionInDiff();
Map<String, String> renamed =
HopDiff.detectActionRenames(workflowMetaOld, workflowMetaNew);
diff --git
a/plugins/misc/git/src/main/java/org/apache/hop/git/info/GitInfoExplorerFileTypeHandler.java
b/plugins/misc/git/src/main/java/org/apache/hop/git/info/GitInfoExplorerFileTypeHandler.java
index 7b3fbb5a58..bce4e579f1 100644
---
a/plugins/misc/git/src/main/java/org/apache/hop/git/info/GitInfoExplorerFileTypeHandler.java
+++
b/plugins/misc/git/src/main/java/org/apache/hop/git/info/GitInfoExplorerFileTypeHandler.java
@@ -450,9 +450,13 @@ public class GitInfoExplorerFileTypeHandler extends
BaseExplorerFileTypeHandler
InputStream xmlStreamNew = git.open(filename, commitIdNew)) {
PipelineMeta pipelineMetaOld =
- new PipelineMeta(xmlStreamOld, hopGui.getMetadataProvider(),
hopGui.getVariables());
+ xmlStreamOld == null
+ ? new PipelineMeta()
+ : new PipelineMeta(xmlStreamOld, hopGui.getMetadataProvider(),
hopGui.getVariables());
PipelineMeta pipelineMetaNew =
- new PipelineMeta(xmlStreamNew, hopGui.getMetadataProvider(),
hopGui.getVariables());
+ xmlStreamNew == null
+ ? new PipelineMeta()
+ : new PipelineMeta(xmlStreamNew, hopGui.getMetadataProvider(),
hopGui.getVariables());
boolean ignorePosition =
GitConfigSingleton.getConfig().isIgnoringPositionInDiff();
Map<String, String> renamed =
@@ -511,9 +515,13 @@ public class GitInfoExplorerFileTypeHandler extends
BaseExplorerFileTypeHandler
InputStream xmlStreamNew = git.open(filename, commitIdNew)) {
WorkflowMeta workflowMetaOld =
- new WorkflowMeta(xmlStreamOld, hopGui.getMetadataProvider(),
hopGui.getVariables());
+ xmlStreamOld == null
+ ? new WorkflowMeta()
+ : new WorkflowMeta(xmlStreamOld, hopGui.getMetadataProvider(),
hopGui.getVariables());
WorkflowMeta workflowMetaNew =
- new WorkflowMeta(xmlStreamNew, hopGui.getMetadataProvider(),
hopGui.getVariables());
+ xmlStreamNew == null
+ ? new WorkflowMeta()
+ : new WorkflowMeta(xmlStreamNew, hopGui.getMetadataProvider(),
hopGui.getVariables());
boolean ignorePosition =
GitConfigSingleton.getConfig().isIgnoringPositionInDiff();
Map<String, String> renamed =
HopDiff.detectActionRenames(workflowMetaOld, workflowMetaNew);
diff --git a/plugins/misc/git/src/main/java/org/apache/hop/git/model/UIGit.java
b/plugins/misc/git/src/main/java/org/apache/hop/git/model/UIGit.java
index b65ddf3c1d..6843c00913 100644
--- a/plugins/misc/git/src/main/java/org/apache/hop/git/model/UIGit.java
+++ b/plugins/misc/git/src/main/java/org/apache/hop/git/model/UIGit.java
@@ -1187,6 +1187,14 @@ public class UIGit extends VCS {
}
}
+ /**
+ * Open a file as it is in a commit, or in the working tree.
+ *
+ * @param file the path of the file
+ * @param commitId the commit to read the file from, or WORKINGTREE
+ * @return the content of the file, or null when the commit doesn't have the
file
+ * @throws HopException when the file can't be read
+ */
public InputStream open(String file, String commitId) throws HopException {
String normalizedFile = normalizePathForJGit(file);
if (commitId.equals(WORKINGTREE)) {
@@ -1204,7 +1212,9 @@ public class UIGit extends VCS {
tw.addTree(tree);
tw.setFilter(PathFilter.create(normalizedFile));
tw.setRecursive(true);
- tw.next();
+ if (!tw.next()) {
+ return null;
+ }
ObjectLoader loader = git.getRepository().open(tw.getObjectId(0));
return loader.openStream();
} catch (MissingObjectException e) {
diff --git
a/plugins/misc/git/src/test/java/org/apache/hop/git/model/UIGitTest.java
b/plugins/misc/git/src/test/java/org/apache/hop/git/model/UIGitTest.java
index 02b3be7fc8..9938ad1b2b 100644
--- a/plugins/misc/git/src/test/java/org/apache/hop/git/model/UIGitTest.java
+++ b/plugins/misc/git/src/test/java/org/apache/hop/git/model/UIGitTest.java
@@ -571,6 +571,16 @@ public class UIGitTest extends RepositoryTestCase {
writer.close();
}
+ @Test
+ public void testOpenFileAddedByLaterCommit() throws Exception {
+ RevCommit commit = initialCommit();
+ writeTrashFile("Added.txt", "Added");
+ git.add().addFilepattern("Added.txt").call();
+ git.commit().setMessage("add a file").call();
+
+ assertNull(uiGit.open("Added.txt", commit.getName()));
+ }
+
@Test
public void testCheckout() throws Exception {
initialCommit();