Consider allowReachableSHA1InWant for using object IDs Since JGit 4.1, included in Gerrit 2.12, uploadpack.allowReachableSHA1InWant is used, as well as uploadpack.allowTipSHA1InWant, to determine if requests for an exact SHA1 is allowed. Bug: Issue 175 Change-Id: I3777b0d5261cf149412e85d3ad69f9352f0585ac Signed-off-by: Fredrik Medley <fredrik.medley@gmail.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/GitDownloadCommand.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/GitDownloadCommand.java index 3a1a304..59742ca 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/download/command/GitDownloadCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/GitDownloadCommand.java
@@ -43,7 +43,8 @@ private static final String DOWNLOAD = "download"; private static final String UPLOADPACK = "uploadpack"; - private static final String KEY_ALLOW_TIP_SHA1_IN_WANT = "allowTipSha1InWant"; + private static final String KEY_ALLOW_TIP_SHA1_IN_WANT = "allowTipSHA1InWant"; + private static final String KEY_ALLOW_REACHABLE_SHA1_IN_WANT = "allowReachableSHA1InWant"; private static final String KEY_CHECK_FOR_HIDDEN_CHANGE_REFS = "checkForHiddenChangeRefs"; private static final String KEY_HIDE_REFS = "hideRefs"; @@ -99,7 +100,10 @@ try (Repository repo = repoManager.openRepository(new Project.NameKey(project))) { Config cfg = repo.getConfig(); - if (cfg.getBoolean(UPLOADPACK, KEY_ALLOW_TIP_SHA1_IN_WANT, false) + boolean allowSha1InWant = + cfg.getBoolean(UPLOADPACK, KEY_ALLOW_TIP_SHA1_IN_WANT, false) || + cfg.getBoolean(UPLOADPACK, KEY_ALLOW_REACHABLE_SHA1_IN_WANT, false); + if (allowSha1InWant && Arrays.asList(cfg.getStringList(UPLOADPACK, null, KEY_HIDE_REFS)) .contains(RefNames.REFS_CHANGES)) { ObjectId id = repo.resolve(ref);