Community
Participate
Working Groups
As of Git 1.8.5 the symref information is reported as a capability: https://github.com/git/git/commit/7171d8c15f919c760d52f814a0aee1b1253385b1 If you want to get this information, you are required to do all sorts of evil reflection, e.g.: Class<?> basePackConnection = BasePackFetchConnection.class.getSuperclass(); Field remoteCapablities = basePackConnection.getDeclaredField("remoteCapablities"); remoteCapablities.setAccessible(true); try (Transport transport = Transport.open(repo, url)) { transport.setCredentialsProvider(getProvider()); try (FetchConnection fc = transport.openFetch()) { fc.getRefs(); if (fc instanceof BasePackFetchConnection) { Object o = remoteCapablities.get(fc); if (o instanceof Set) { boolean hackWorked = false; for (String capability: (Set<String>)o) { if (capability.startsWith("symref=")) { hackWorked = true; int index = capability.indexOf(":", 7); if (index != -1) { references.put(capability.substring(7, index), capability.substring(index+1)); } } } if (hackWorked) { return references; } } } } } catch (URISyntaxException | NotSupportedException | TransportException e) { // ignore this is a total hack } Please add the ability to get the symbolic reference information from LsRemoteCommand
Note this feature is relevant to the Jenkins project: https://github.com/jenkinsci/git-client-plugin/pull/236 and https://issues.jenkins-ci.org/browse/JENKINS-40834
The Jenkins plugins are currently restricted to JGit 4.5.x due to the requirement for Java 7 bytecode on the current baseline versions of Jenkins that the plugins are maintained against, so we would request that the fix be added to both 4.5.x and 4.6.x
Jenkins git client plugin will soon update to JGit 4.10.0 or later. If this is implemented, it only needs to be implemented on the current development stream, not backported to JGit 4.5.
Jenkins git client plugin is now using JGit 5.6.0. If this is implemented, it is enough to implement on the current JGit.
Gerrit change https://git.eclipse.org/r/c/jgit/jgit/+/171875 was merged to [master]. Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=9ebbfe93bb3ba0ea170d330fe227f1d8182d7d64
(In reply to Eclipse Genie from comment #5) > Gerrit change https://git.eclipse.org/r/c/jgit/jgit/+/171875 was merged to > [master]. > Commit: > http://git.eclipse.org/c/jgit/jgit.git/commit/ > ?id=9ebbfe93bb3ba0ea170d330fe227f1d8182d7d64 This change makes LsRemoteCommand return SymbolicRefs for symrefs advertised through capabilities, if the symref target is also in the refs listed.