Fetch/Clone/Pull 自定义传输异常

Exception on Fetch/Clone/Pull with custom transport

我写了一个自定义的smarttransport。获取、拉取或克隆后,我得到了有效数据,但该方法抛出 LibGit2Sharp 异常 "error reading from the zlib stream"。

Transport with upload-pack read->write->read->write 工作。

阅读:

00fc5daa747d4ca7905ff8996f770ef74d1b894be3d2 HEAD multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master agent=git/2.18.0.windows.1 003f5daa747d4ca7905ff8996f770ef74d1b894be3d2 refs/heads/master 003e5daa747d4ca7905ff8996f770ef74d1b894be3d2 refs/heads/test2 0000

写入:

0074want 5daa747d4ca7905ff8996f770ef74d1b894be3d2 multi_ack_detailed side-band-64k include-tag thin-pack ofs-delta 0032want 5daa747d4ca7905ff8996f770ef74d1b894be3d2 00000009done

阅读:

0008NAK 0023Enumerating objects: 9, done. Counting objects: 100% (9/9), done. Compressing objects: 100% (6/6), done. 002bTotal 9 (delta 0), reused 0 (delta 0) 02e7PACK òx£ì-1-0 +=»+ÄälºNc !6Ìß$NAé+­x-m763[AÁ+sª$C+!7eì[å$í¦Àn÷^A&ã:Cÿ+-T#&Ö+BfàªäëKê+Úg_·µ»}+²i¨yi·¦Ò+ï«gÅÉä+Ç \Ú¤þ}¹©]ks_.k8¬òx£ì-=-0@ß=º+ÄäþºÄäþpº ZéZszûÀ}z¦ëÏ\KpêÈUqòÉk+=-Ç U8O àú¨­&oÁëÿ=óª=d+AÊ4qóÏÇ:+ã-áß»>ãf´cÌÝe>zٳƾ2*/WÙó?«ô-hOÇ ªÄu}¬- -¿ýj~Ç@9[ÿ<br> x£ì-1-0@Ð=º­ÄäLLöTBê¡þpmÀDñDj-²¦#¦³7}¯¦@°nël8eÔR-ª¿ëSûY'UM%IÓƒ+¹c_vx,g_3ý+¦p{--ûé4d©DÊÎÁ¦¦ G¿¯Ûò[8 Ë-õ¿x£343 ¢Éd¸¦åîUFzÜ--£+²Ê½2.Þr³ê]ÙdhfbóPöÜÿÆø¬WRQ-ã»Ã¤J¦_Ðß¾ØKMº¥à 3Sã¦x£-¦-,+L¦QH+¤--,I,NIa.-à-3©îí+ §Ó-¿x£343 ¢Éd¸¦åîUFzÜ--£+²Ê½2.Þr³ê]ÙdhfbóPöÜÿÆø¬WRQ-­=âìBnï§+=ƒ º=¦|[c N+ô¦x£-¦-,+L¦QH+¤--,I,NIa.-ò +®*ªx£340031Q(JML+Mi+®(a+§u¦sQ?-§î¦O´¢¹¦,²Û+. H>x£-¦-,+L¦QH+¤--, )-öP¸ãyô

写入:

0000

异常:

An unhandled exception of type 'LibGit2Sharp.LibGit2SharpException' occurred in LibGit2Sharp.dll

Additional information: error reading from the zlib stream

调用堆栈:

bei LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:Zeile 136. bei LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable1 refSpecs, GitFetchOptions fetchOptions, String logMessage) in C:\projects\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:Zeile 2268. bei LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable1 refspecs, FetchOptions options, String logMessage) in C:\projects\libgit2sharp\LibGit2Sharp\Commands\Fetch.cs:Zeile 76.
bei GitFunction.Test.Beta2.button1_Click(Object sender, EventArgs e) in C:\TFS\DS\ThomasZ\BeckhoffGitAdsService\GitAdsServicePackage\GitFunction.Test\Beta2.cs:Zeile 62. bei System.Windows.Forms.Control.OnClick(EventArgs e) bei System.Windows.Forms.Button.OnClick(EventArgs e) bei System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) bei System.Windows.Forms.Control.WndProc(Message& m) bei System.Windows.Forms.ButtonBase.WndProc(Message& m) bei System.Windows.Forms.Button.WndProc(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(Form mainForm) bei GitFunction.Test.Program.Main() in C:\TFS\DS\ThomasZ\BeckhoffGitAdsService\GitAdsServicePackage\GitFunction.Test\Program.cs:Zeile 19. bei System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart()

版本:

仅供参考: UTF8Encoding 和 Encoding.Utf8 不相等。 Encoding.Utf8 添加 UTF8 BOM(字节顺序标记)。这会导致此错误。在我的代码中将所有编码设置为 UTF8Encoding 解决了我的问题。