Skip to content

Commit 2b615b0

Browse files
authored
Merge pull request #461 from groldan/bug/pull_nothing_to_fetch
Bug/pull nothing to fetch
2 parents d34a2b2 + 9c3b665 commit 2b615b0

File tree

2 files changed

+21
-22
lines changed
  • src/remoting/src

2 files changed

+21
-22
lines changed

src/remoting/src/main/java/org/locationtech/geogig/remotes/PullOp.java

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import static com.google.common.base.Preconditions.checkNotNull;
1414

1515
import java.util.ArrayList;
16-
import java.util.Collection;
1716
import java.util.List;
1817

1918
import org.eclipse.jdt.annotation.Nullable;
@@ -131,7 +130,8 @@ public boolean isFullDepth() {
131130
}
132131

133132
/**
134-
* @param refSpec the refspec of a remote branch
133+
* @param refSpec specifies a remote ref to fetch and optionally which local ref to update,
134+
* using the format {@code <remote ref>[:<localRef>]}
135135
* @return {@code this}
136136
*/
137137
public PullOp addRefSpec(final String refSpec) {
@@ -233,16 +233,6 @@ protected PullResult _call() {
233233
result.setOldRef(currentBranch);
234234
result.setRemote(suppliedRemote);
235235

236-
// did fetch need to update any contents?
237-
{
238-
final Collection<RefDiff> fetchedRefs = fetchResult.getRefDiffs()
239-
.get(remote.getFetchURL());
240-
if (fetchedRefs == null || fetchedRefs.isEmpty()) {
241-
result.setNewRef(currentBranch);
242-
return result;
243-
}
244-
}
245-
246236
for (LocalRemoteRefSpec fetchspec : remote.getFetchSpecs()) {
247237
final String localRemoteRefName = fetchspec.getLocal();
248238
final Optional<Ref> localRemoteRefOpt = command(RefParse.class)
@@ -286,14 +276,4 @@ private Ref resolveCurrentBranch() {
286276
return command(BranchResolveOp.class).call().orElseThrow(
287277
() -> new IllegalStateException("Repository has no HEAD, can't pull."));
288278
}
289-
290-
/**
291-
* @param ref the ref to find
292-
* @return an {@link Optional} of the ref, or {@link Optional#absent()} if it wasn't found
293-
*/
294-
public Optional<Ref> findRemoteRef(String ref) {
295-
296-
String remoteRef = Ref.REMOTES_PREFIX + remote.get().get().getName() + "/" + ref;
297-
return command(RefParse.class).setName(remoteRef).call();
298-
}
299279
}

src/remoting/src/test/java/org/locationtech/geogig/test/integration/remoting/PullOpTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,25 @@ public void testPullMerge() throws Exception {
166166
assertEquals(expectedMaster, logged);
167167
}
168168

169+
@Test
170+
public void testPullMergeNothingToFetch() throws Exception {
171+
// Add a commit to the remote
172+
insertAndAdd(remoteGeogig.geogig, lines3);
173+
RevCommit commit = commit(remoteGeogig.repo, "lines3");
174+
expectedMaster.addFirst(commit);
175+
176+
// call fetch first so the missing objects are already in the local repo
177+
fetchOp().call();
178+
179+
// Then Pull should update the target ref even if there's nothing to fetch
180+
PullOp pull = pullOp();
181+
pull.setRemote("origin").call();
182+
183+
List<RevCommit> logged = log(localGeogig.repo);
184+
185+
assertEquals(expectedMaster, logged);
186+
}
187+
169188
/**
170189
* Pull from a remote that's not being saved as named remote in the repository
171190
*/

0 commit comments

Comments
 (0)