[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] LsRemoteCommand

On Tue, Apr 26, 2011 at 03:15, egore <eGore@xxxxxx> wrote:
> Hi list,
>
> I'm trying to implement git-ls-remote[1] in jgit. Basically everything necessary should be in place (i.e. FetchProcess and Transport). I uploaded my implementation to https://bugs.eclipse.org/bugs/show_bug.cgi?id=343801 which basically works but fails if I only want to grab the remote tags.

You can't use transport.fetch() for LsRemote. LsRemote should only be
looking at the remote peer... fetch() not only looks, but also copies
the remote repository locally, depending upon the RefSpecs you have
added to the collection it uses.

Instead you need to use:

  Collection<Ref> refs;
  FetchConnection fc = transport.openFetch();
  try {
    refs = fc.getAdvertisedRefs().values();
  } finally {
    fc.close();
  }

and then loop through the refs collection to find the names that are
relevant for output.

-- 
Shawn.