Add ArchiveFormat.unregisterAll() method

Users of JGit's archive package are supposed to unregister archive
formats when they're done with them. Since formats in Gitiles are
created/registered in the static initializer of ArchiveFormat, they
will stick around for the lifetime of the Gitiles classloader, but
may still need to be unloaded if a caller knows Gitiles itself is
going to be unloaded.

Change-Id: I4c098f5a21749571f49a49b23615f281886adc3d
diff --git a/gitiles-servlet/src/main/java/com/google/gitiles/ArchiveFormat.java b/gitiles-servlet/src/main/java/com/google/gitiles/ArchiveFormat.java
index 4ca5d3e..85d5d48 100644
--- a/gitiles-servlet/src/main/java/com/google/gitiles/ArchiveFormat.java
+++ b/gitiles-servlet/src/main/java/com/google/gitiles/ArchiveFormat.java
@@ -26,7 +26,7 @@
 import org.eclipse.jgit.archive.TxzFormat;
 import org.eclipse.jgit.lib.Config;
 
-enum ArchiveFormat {
+public enum ArchiveFormat {
   TGZ("application/x-gzip", new TgzFormat()),
   TAR("application/x-tar", new TarFormat()),
   TBZ2("application/x-bzip2", new Tbz2Format()),
@@ -45,13 +45,20 @@
     BY_EXT = byExt.build();
   }
 
+  /** Unregister all JGit archive formats supported by Gitiles. */
+  public static void unregisterAll() {
+    for (ArchiveFormat fmt : values()) {
+      ArchiveCommand.unregisterFormat(fmt.getShortName());
+    }
+  }
+
   private final ArchiveCommand.Format<?> format;
   private final String mimeType;
 
   private ArchiveFormat(String mimeType, ArchiveCommand.Format<?> format) {
     this.format = format;
     this.mimeType = mimeType;
-    ArchiveCommand.registerFormat(name(), format);
+    ArchiveCommand.registerFormat(getShortName(), format);
   }
 
   String getShortName() {