mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-01-26 17:29:12 +01:00
Fix browse of empty repository
In an empty hg repository the Changeset c is null. This leads to an NullPointerException in the original code. So we check whether we have a Changeset and otherwise use the old functionality.
This commit is contained in:
@@ -77,7 +77,9 @@ public class HgBrowseCommand extends AbstractCommand implements BrowseCommand
|
||||
String revision = MoreObjects.firstNonNull(request.getRevision(), "tip");
|
||||
Changeset c = LogCommand.on(getContext().open()).rev(revision).limit(1).single();
|
||||
|
||||
cmd.rev(c.getNode());
|
||||
if (c != null) {
|
||||
cmd.rev(c.getNode());
|
||||
}
|
||||
|
||||
if (!Strings.isNullOrEmpty(request.getPath()))
|
||||
{
|
||||
@@ -100,6 +102,6 @@ public class HgBrowseCommand extends AbstractCommand implements BrowseCommand
|
||||
}
|
||||
|
||||
FileObject file = cmd.execute();
|
||||
return new BrowserResult(c.getNode(), revision, file);
|
||||
return new BrowserResult(c == null? "tip": c.getNode(), revision, file);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user