/// <exception cref="NGit.Errors.TransportException"></exception> private void Want(Ref src, RefSpec spec) { ObjectId newId = src.GetObjectId(); if (spec.GetDestination() != null) { try { TrackingRefUpdate tru = CreateUpdate(spec, newId); if (newId.Equals(tru.GetOldObjectId())) { return; } localUpdates.AddItem(tru); } catch (IOException err) { // Bad symbolic ref? That is the most likely cause. // throw new TransportException(MessageFormat.Format(JGitText.Get().cannotResolveLocalTrackingRefForUpdating , spec.GetDestination()), err); } } askFor.Put(newId, src); FetchHeadRecord fhr = new FetchHeadRecord(); fhr.newValue = newId; fhr.notForMerge = spec.GetDestination() != null; fhr.sourceName = src.GetName(); fhr.sourceURI = transport.GetURI(); fetchHeadUpdates.AddItem(fhr); }
public virtual void TestFindRemoteRefUpdatesTrackingRef() { remoteConfig.AddFetchRefSpec(new RefSpec("refs/heads/*:refs/remotes/test/*")); transport = NGit.Transport.Transport.Open(db, remoteConfig); ICollection <RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(Sharpen.Collections .NCopies(1, new RefSpec("+refs/heads/a:refs/heads/a"))); NUnit.Framework.Assert.AreEqual(1, result.Count); TrackingRefUpdate tru = result.Iterator().Next().GetTrackingRefUpdate(); NUnit.Framework.Assert.AreEqual("refs/remotes/test/a", tru.GetLocalName()); NUnit.Framework.Assert.AreEqual("refs/heads/a", tru.GetRemoteName()); NUnit.Framework.Assert.AreEqual(db.Resolve("refs/heads/a"), tru.GetNewObjectId()); NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, tru.GetOldObjectId()); }
/// <exception cref="NGit.Errors.TransportException"></exception> private void Want(Ref src, RefSpec spec) { ObjectId newId = src.GetObjectId(); if (spec.GetDestination() != null) { TrackingRefUpdate tru = CreateUpdate(spec, newId); if (newId.Equals(tru.GetOldObjectId())) { return; } localUpdates.AddItem(tru); } askFor.Put(newId, src); FetchHeadRecord fhr = new FetchHeadRecord(); fhr.newValue = newId; fhr.notForMerge = spec.GetDestination() != null; fhr.sourceName = src.GetName(); fhr.sourceURI = transport.GetURI(); fetchHeadUpdates.AddItem(fhr); }