diff options
author | Lee Worrall <worrall.la@gmail.com> | 2020-10-10 11:31:19 +0800 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2020-11-26 21:14:08 +0100 |
commit | 9ebbfe93bb3ba0ea170d330fe227f1d8182d7d64 (patch) | |
tree | 52d2401beac6b58d2eb485cd9aebe7958d3469b2 /org.eclipse.jgit.pgm | |
parent | dfa29458e7b187b45e9fb48791ddb71ffac5ad93 (diff) | |
download | jgit-9ebbfe93bb3ba0ea170d330fe227f1d8182d7d64.tar.gz jgit-9ebbfe93bb3ba0ea170d330fe227f1d8182d7d64.zip |
Add support for reading symrefs from pack capabilities
A SymbolicRef is added to the advertised refs for any symref in
capabilities whose target is an advertised ref; this may replace an
existing entry, such as HEAD.
When cloning, if any advertised HEAD is symbolic then use the target
rather than looking for an advertised ref with a matching objectId.
Add --symref option to LsRemote command.
Bug: 514052
Change-Id: Idfb48e6f6e8dcfe57a6896883fe6d84d533aa9d0
Signed-off-by: Lee Worrall <worrall.la@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r-- | org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties | 1 | ||||
-rw-r--r-- | org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties index c116437c64..6112a272e4 100644 --- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties +++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties @@ -256,6 +256,7 @@ usage_LsFiles=Show information about files in the index and the working tree usage_LsRemote=List references in a remote repository usage_lsRemoteHeads=Show only refs starting with refs/heads usage_lsRemoteTags=Show only refs starting with refs/tags +usage_lsRemoteSymref=In addition to the object pointed at, show the underlying ref pointed at when showing a symbolic ref. usage_LsTree=List the contents of a tree object usage_MakeCacheTree=Show the current cache tree structure usage_Match=Only consider tags matching the given glob(7) pattern or patterns, excluding the "refs/tags/" prefix. diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java index 36812c03a4..055b48a157 100644 --- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java +++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/LsRemote.java @@ -34,6 +34,9 @@ class LsRemote extends TextBuiltin { @Option(name = "--timeout", metaVar = "metaVar_service", usage = "usage_abortConnectionIfNoActivity") int timeout = -1; + @Option(name = "--symref", usage = "usage_lsRemoteSymref") + private boolean symref; + @Argument(index = 0, metaVar = "metaVar_uriish", required = true) private String remote; @@ -47,6 +50,9 @@ class LsRemote extends TextBuiltin { try { refs.addAll(command.call()); for (Ref r : refs) { + if (symref && r.isSymbolic()) { + show(r.getTarget(), r.getName()); + } show(r.getObjectId(), r.getName()); if (r.getPeeledObjectId() != null) { show(r.getPeeledObjectId(), r.getName() + "^{}"); //$NON-NLS-1$ @@ -70,4 +76,13 @@ class LsRemote extends TextBuiltin { outw.print(name); outw.println(); } + + private void show(Ref ref, String name) + throws IOException { + outw.print("ref: "); + outw.print(ref.getName()); + outw.print('\t'); + outw.print(name); + outw.println(); + } } |