summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/utils/JGitUtils.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-01-13 18:09:58 -0500
committerJames Moger <james.moger@gitblit.com>2013-01-13 18:09:58 -0500
commit657a6596eb95635abd29c0a21befffc43da49d09 (patch)
treedba4a101b5a8fbda2645274a06989bb0e40e907f /src/com/gitblit/utils/JGitUtils.java
parent19e902522d1d55f042daf076a1f7299b7c220061 (diff)
downloadgitblit-657a6596eb95635abd29c0a21befffc43da49d09.tar.gz
gitblit-657a6596eb95635abd29c0a21befffc43da49d09.zip
Improve history display of a submodule link
Diffstat (limited to 'src/com/gitblit/utils/JGitUtils.java')
-rw-r--r--src/com/gitblit/utils/JGitUtils.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java
index 815f8b5a..1f2ae943 100644
--- a/src/com/gitblit/utils/JGitUtils.java
+++ b/src/com/gitblit/utils/JGitUtils.java
@@ -1616,6 +1616,32 @@ public class JGitUtils {
}
return null;
}
+
+ public static String getSubmoduleCommitId(Repository repository, String path, RevCommit commit) {
+ String commitId = null;
+ RevWalk rw = new RevWalk(repository);
+ TreeWalk tw = new TreeWalk(repository);
+ tw.setFilter(PathFilterGroup.createFromStrings(Collections.singleton(path)));
+ try {
+ tw.reset(commit.getTree());
+ while (tw.next()) {
+ if (tw.isSubtree() && !path.equals(tw.getPathString())) {
+ tw.enterSubtree();
+ continue;
+ }
+ if (FileMode.GITLINK == tw.getFileMode(0)) {
+ commitId = tw.getObjectId(0).getName();
+ break;
+ }
+ }
+ } catch (Throwable t) {
+ error(t, repository, "{0} can't find {1} in commit {2}", path, commit.name());
+ } finally {
+ rw.dispose();
+ tw.release();
+ }
+ return commitId;
+ }
/**
* Returns the list of notes entered about the commit from the refs/notes