@@ -73,7 +73,9 @@ public class LsRemoteCommand extends GitCommand<Collection<Ref>> {
73
73
private String remote = Constants .DEFAULT_REMOTE_NAME ;
74
74
75
75
private boolean heads ;
76
+
76
77
private boolean tags ;
78
+
77
79
private String uploadPack ;
78
80
79
81
/**
@@ -118,7 +120,7 @@ public void setTags(boolean tags) {
118
120
119
121
/**
120
122
* The full path of git-upload-pack on the remote host
121
- *
123
+ *
122
124
* @param uploadPack
123
125
*/
124
126
public void setUploadPack (String uploadPack ) {
@@ -134,32 +136,27 @@ public Collection<Ref> call() throws Exception {
134
136
135
137
try {
136
138
Collection <RefSpec > refSpecs = new ArrayList <RefSpec >(1 );
137
- if (tags ) {
139
+ if (tags )
138
140
refSpecs .add (new RefSpec (
139
141
"refs/tags/*:refs/remotes/origin/tags/*" ));
140
- }
141
- if (heads ) {
142
+ if (heads )
142
143
refSpecs .add (new RefSpec (
143
144
"refs/heads/*:refs/remotes/origin/*" ));
144
- }
145
145
Collection <Ref > refs ;
146
146
Map <String , Ref > refmap = new HashMap <String , Ref >();
147
147
FetchConnection fc = transport .openFetch ();
148
148
try {
149
149
refs = fc .getRefs ();
150
- for (Ref r : refs ) {
151
- boolean found = refSpecs .isEmpty ();
152
- for (RefSpec rs : refSpecs ) {
153
- if (rs .matchSource (r )) {
154
- found = true ;
155
- break ;
156
- }
157
- }
158
- if (found ) {
150
+ if (refSpecs .isEmpty ())
151
+ for (Ref r : refs )
159
152
refmap .put (r .getName (), r );
160
- }
161
-
162
- }
153
+ else
154
+ for (Ref r : refs )
155
+ for (RefSpec rs : refSpecs )
156
+ if (rs .matchSource (r )) {
157
+ refmap .put (r .getName (), r );
158
+ break ;
159
+ }
163
160
} finally {
164
161
fc .close ();
165
162
}
0 commit comments