From a502d96a860456ec5e8c96761db70f7cabb74751 Mon Sep 17 00:00:00 2001
From: Paul Martin <paul@paulsputer.com>
Date: Sat, 30 Apr 2016 04:19:14 -0400
Subject: [PATCH] Merge pull request #1073 from gitblit/1062-DocEditorUpdates

---
 src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java b/src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java
index b203d47..c49d23b 100644
--- a/src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java
+++ b/src/main/java/com/gitblit/transport/ssh/git/BaseGitCommand.java
@@ -1,4 +1,5 @@
 /*
+ * Copyright (C) 2009 The Android Open Source Project
  * Copyright 2014 gitblit.com.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,10 +30,6 @@
 import com.gitblit.transport.ssh.SshDaemonClient;
 import com.gitblit.transport.ssh.commands.BaseCommand;
 
-/**
- * @author Eric Myhre
- *
- */
 abstract class BaseGitCommand extends BaseCommand {
 	@Argument(index = 0, metaVar = "REPOSITORY", required = true, usage = "repository name")
 	protected String repository;
@@ -42,6 +39,16 @@
 	protected UploadPackFactory<SshDaemonClient> uploadPackFactory;
 
 	protected Repository repo;
+
+	@Override
+	public void destroy() {
+		super.destroy();
+
+		repositoryResolver = null;
+		receivePackFactory = null;
+		uploadPackFactory = null;
+		repo = null;
+	}
 
 	@Override
 	public void start(final Environment env) {
@@ -79,12 +86,11 @@
 		repository = repository.replace('\\', '/');
 		// ssh://git@thishost/path should always be name="/path" here
 		//
-		if (!repository.startsWith("/")) {
-			throw new Failure(1, "fatal: '" + repository + "': not starts with / character");
+		if (repository.startsWith("/")) {
+			repository = repository.substring(1);
 		}
-		repository = repository.substring(1);
 		try {
-			return repositoryResolver.open(ctx.getClient(), repository);
+			return repositoryResolver.open(getContext().getClient(), repository);
 		} catch (Exception e) {
 			throw new Failure(1, "fatal: '" + repository + "': not a git archive", e);
 		}

--
Gitblit v1.9.1