Fix compatibility with git-lfs v3

git-lfs v3 introduced a breaking change in the way
it calls git-lfs-authenticate over SSH [1,2] in that,
for ssh:// URLs like the ones used with Gerrit (to
specify the custom 29418 port) it will no longer
strip the first "/", so it'll pass "/projectname"
when git-lfs v2 passed "projectname".
This results in the generated token to later be
rejected at the HTTP endpoints because the 'project'
doesn't match.
The fix here is to simply strip the leading "/", if
any, in the git-lfs-authenticate command.


Bug: Issue 15139
Change-Id: I875c460ee969a0c6740af6054a5a84d9ca354d1b
diff --git a/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/ b/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/
index 3dd7a86..16f204a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/
+++ b/src/main/java/com/googlesource/gerrit/plugins/lfs/auth/
@@ -52,6 +52,9 @@
       URL url = new URL(canonicalWebUrl);
       String path = url.getPath();
       String project = args.get(0);
+      if (project.startsWith("/")) {
+        project = project.substring(1);
+      }
       String operation = args.get(1);
       StringBuilder href =
           new StringBuilder(url.getProtocol())