private String remote = Constants.DEFAULT_REMOTE_NAME;
private boolean heads;
+
private boolean tags;
+
private String uploadPack;
/**
/**
* The full path of git-upload-pack on the remote host
- *
+ *
* @param uploadPack
*/
public void setUploadPack(String uploadPack) {
try {
Collection<RefSpec> refSpecs = new ArrayList<RefSpec>(1);
- if (tags) {
+ if (tags)
refSpecs.add(new RefSpec(
"refs/tags/*:refs/remotes/origin/tags/*"));
- }
- if (heads) {
+ if (heads)
refSpecs.add(new RefSpec(
"refs/heads/*:refs/remotes/origin/*"));
- }
Collection<Ref> refs;
Map<String, Ref> refmap = new HashMap<String, Ref>();
FetchConnection fc = transport.openFetch();
try {
refs = fc.getRefs();
- for (Ref r : refs) {
- boolean found = refSpecs.isEmpty();
- for (RefSpec rs : refSpecs) {
- if (rs.matchSource(r)) {
- found = true;
- break;
- }
- }
- if (found) {
+ if (refSpecs.isEmpty())
+ for (Ref r : refs)
refmap.put(r.getName(), r);
- }
-
- }
+ else
+ for (Ref r : refs)
+ for (RefSpec rs : refSpecs)
+ if (rs.matchSource(r)) {
+ refmap.put(r.getName(), r);
+ break;
+ }
} finally {
fc.close();
}