Beispiel #1
0
        private int GitPushNegotiationHandler(IntPtr updates, UIntPtr len, IntPtr payload)
        {
            if (updates == IntPtr.Zero)
            {
                return((int)GitErrorCode.Error);
            }

            bool result = false;

            try
            {
                int          length      = len.ConvertToInt();
                PushUpdate[] pushUpdates = new PushUpdate[length];

                unsafe
                {
                    IntPtr *ptr = (IntPtr *)updates.ToPointer();

                    for (int i = 0; i < length; i++)
                    {
                        if (ptr[i] == IntPtr.Zero)
                        {
                            throw new NullReferenceException("Unexpected null git_push_update pointer was encountered");
                        }

                        GitPushUpdate gitPushUpdate = ptr[i].MarshalAs <GitPushUpdate>();
                        PushUpdate    pushUpdate    = new PushUpdate(gitPushUpdate);
                        pushUpdates[i] = pushUpdate;
                    }

                    result = PrePushCallback(pushUpdates);
                }
            }
            catch (Exception exception)
            {
                Log.Write(LogLevel.Error, exception.ToString());
                Proxy.giterr_set_str(GitErrorCategory.Callback, exception);
                result = false;
            }

            return(Proxy.ConvertResultToCancelFlag(result));
        }
Beispiel #2
0
        private int GitPushNegotiationHandler(IntPtr updates, UIntPtr len, IntPtr payload)
        {
            if (updates == IntPtr.Zero)
            {
                return (int)GitErrorCode.Error;
            }

            bool result = false;
            try
            {

                int length = len.ConvertToInt();
                PushUpdate[] pushUpdates = new PushUpdate[length];

                unsafe
                {
                    IntPtr* ptr = (IntPtr*)updates.ToPointer();

                    for (int i = 0; i < length; i++)
                    {
                        if (ptr[i] == IntPtr.Zero)
                        {
                            throw new NullReferenceException("Unexpected null git_push_update pointer was encountered");
                        }

                        PushUpdate pushUpdate = new PushUpdate((git_push_update*) ptr[i].ToPointer());
                        pushUpdates[i] = pushUpdate;
                    }

                    result = PrePushCallback(pushUpdates);
                }
            }
            catch (Exception exception)
            {
                Log.Write(LogLevel.Error, exception.ToString());
                Proxy.giterr_set_str(GitErrorCategory.Callback, exception);
                result = false;
            }

            return Proxy.ConvertResultToCancelFlag(result);
        }