diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2017-08-10 15:03:22 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2017-08-14 14:03:51 +0200 |
commit | df3469f6ad81dccb314bf2d5021a3cec2b184985 (patch) | |
tree | 58c13d7ab44f8df134ce69dbbef9b4244bfa40a6 /org.eclipse.jgit/src/org/eclipse/jgit | |
parent | f5a2c77dc4bc1b0a40ca4b8a8d6a51c3b042ee4a (diff) | |
download | jgit-df3469f6ad81dccb314bf2d5021a3cec2b184985.tar.gz jgit-df3469f6ad81dccb314bf2d5021a3cec2b184985.zip |
Record submodule paths with untracked changes as FileMode.GITLINK
Bug: 520702
Change-Id: I9bb48af9e8f1f2ce7968a82297c7c16f1237f987
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java index e544b72a85..ea573a48d7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/IndexDiff.java @@ -513,14 +513,10 @@ public class IndexDiff { } } - for (int i = 0; i < treeWalk.getTreeCount(); i++) { - Set<String> values = fileModes.get(treeWalk.getFileMode(i)); - String path = treeWalk.getPathString(); - if (path != null) { - if (values == null) - values = new HashSet<>(); - values.add(path); - fileModes.put(treeWalk.getFileMode(i), values); + String path = treeWalk.getPathString(); + if (path != null) { + for (int i = 0; i < treeWalk.getTreeCount(); i++) { + recordFileMode(path, treeWalk.getFileMode(i)); } } } @@ -545,19 +541,21 @@ public class IndexDiff { } Repository subRepo = smw.getRepository(); if (subRepo != null) { + String subRepoPath = smw.getPath(); try { ObjectId subHead = subRepo.resolve("HEAD"); //$NON-NLS-1$ if (subHead != null - && !subHead.equals(smw.getObjectId())) - modified.add(smw.getPath()); - else if (ignoreSubmoduleMode != IgnoreSubmoduleMode.DIRTY) { + && !subHead.equals(smw.getObjectId())) { + modified.add(subRepoPath); + recordFileMode(subRepoPath, FileMode.GITLINK); + } else if (ignoreSubmoduleMode != IgnoreSubmoduleMode.DIRTY) { IndexDiff smid = submoduleIndexDiffs.get(smw .getPath()); if (smid == null) { smid = new IndexDiff(subRepo, smw.getObjectId(), wTreeIt.getWorkingTreeIterator(subRepo)); - submoduleIndexDiffs.put(smw.getPath(), smid); + submoduleIndexDiffs.put(subRepoPath, smid); } if (smid.diff()) { if (ignoreSubmoduleMode == IgnoreSubmoduleMode.UNTRACKED @@ -569,7 +567,8 @@ public class IndexDiff { && smid.getRemoved().isEmpty()) { continue; } - modified.add(smw.getPath()); + modified.add(subRepoPath); + recordFileMode(subRepoPath, FileMode.GITLINK); } } } finally { @@ -593,6 +592,17 @@ public class IndexDiff { return true; } + private void recordFileMode(String path, FileMode mode) { + Set<String> values = fileModes.get(mode); + if (path != null) { + if (values == null) { + values = new HashSet<>(); + fileModes.put(mode, values); + } + values.add(path); + } + } + private boolean isEntryGitLink(AbstractTreeIterator ti) { return ((ti != null) && (ti.getEntryRawMode() == FileMode.GITLINK .getBits())); |