/// <summary> /// Deletes the note on the specified object, and for the given namespace. /// </summary> /// <param name = "targetId">The target <see cref = "ObjectId"/>, for which the note will be created.</param> /// <param name = "author">The author.</param> /// <param name = "committer">The committer.</param> /// <param name = "namespace">The namespace on which the note will be removed. It can be either a canonical namespace or an abbreviated namespace ('refs/notes/myNamespace' or just 'myNamespace').</param> public void Delete(ObjectId targetId, Signature author, Signature committer, string @namespace) { Ensure.ArgumentNotNull(targetId, "targetId"); Ensure.ArgumentNotNull(author, "author"); Ensure.ArgumentNotNull(committer, "committer"); Ensure.ArgumentNotNullOrEmptyString(@namespace, "@namespace"); string canonicalNamespace = NormalizeToCanonicalName(@namespace); GitOid oid = targetId.Oid; int res; using (SignatureSafeHandle authorHandle = author.BuildHandle()) using (SignatureSafeHandle committerHandle = committer.BuildHandle()) { res = NativeMethods.git_note_remove(repo.Handle, canonicalNamespace, authorHandle, committerHandle, ref oid); } if (res == (int)GitErrorCode.GIT_ENOTFOUND) { return; } Ensure.Success(res); }
internal Commit CreateCommit(string message, Signature author, Signature committer, Tree tree, IEnumerable <Commit> parents, string referenceName) { Ensure.ArgumentNotNull(message, "message"); Ensure.ArgumentNotNull(author, "author"); Ensure.ArgumentNotNull(committer, "committer"); Ensure.ArgumentNotNull(tree, "tree"); Ensure.ArgumentNotNull(parents, "parents"); IEnumerable <ObjectId> parentIds = parents.Select(p => p.Id); GitOid commitOid; using (var treePtr = new ObjectSafeWrapper(tree.Id, repo)) using (var parentObjectPtrs = new DisposableEnumerable <ObjectSafeWrapper>(parentIds.Select(id => new ObjectSafeWrapper(id, repo)))) using (SignatureSafeHandle authorHandle = author.BuildHandle()) using (SignatureSafeHandle committerHandle = committer.BuildHandle()) { string encoding = null; //TODO: Handle the encoding of the commit to be created IntPtr[] parentsPtrs = parentObjectPtrs.Select(o => o.ObjectPtr.DangerousGetHandle()).ToArray(); int res = NativeMethods.git_commit_create(out commitOid, repo.Handle, referenceName, authorHandle, committerHandle, encoding, message, treePtr.ObjectPtr, parentObjectPtrs.Count(), parentsPtrs); Ensure.Success(res); } return(repo.Lookup <Commit>(new ObjectId(commitOid))); }
public static extern int git_note_create( out GitOid noteOid, RepositorySafeHandle repo, SignatureSafeHandle author, SignatureSafeHandle committer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, ref GitOid oid, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string note);
public static extern int git_tag_create( out GitOid oid, RepositorySafeHandle repo, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, GitObjectSafeHandle target, SignatureSafeHandle signature, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, [MarshalAs(UnmanagedType.Bool)] bool force);
public static extern int git_commit_create( out GitOid oid, RepositorySafeHandle repo, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string updateRef, SignatureSafeHandle author, SignatureSafeHandle committer, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string encoding, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, GitObjectSafeHandle tree, int parentCount, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 7)][In] IntPtr[] parents);
/// <summary> /// Creates an annotated tag with the specified name. /// </summary> /// <param name = "name">The name.</param> /// <param name = "target">The target which can be sha or a canonical reference name.</param> /// <param name = "tagger">The tagger.</param> /// <param name = "message">The message.</param> /// <param name = "allowOverwrite">True to allow silent overwriting a potentially existing tag, false otherwise.</param> /// <returns></returns> public Tag Create(string name, string target, Signature tagger, string message, bool allowOverwrite = false) { Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(target, "target"); Ensure.ArgumentNotNull(tagger, "tagger"); Ensure.ArgumentNotNull(message, "message"); GitObject objectToTag = repo.Lookup(target, GitObjectType.Any, LookUpOptions.ThrowWhenNoGitObjectHasBeenFound); int res; using (var objectPtr = new ObjectSafeWrapper(objectToTag.Id, repo)) using (SignatureSafeHandle taggerHandle = tagger.BuildHandle()) { GitOid oid; res = NativeMethods.git_tag_create(out oid, repo.Handle, name, objectPtr.ObjectPtr, taggerHandle, message, allowOverwrite); } Ensure.Success(res); return(this[name]); }
/// <summary> /// Creates or updates a <see cref = "Note"/> on the specified object, and for the given namespace. /// </summary> /// <param name = "targetId">The target <see cref = "ObjectId"/>, for which the note will be created.</param> /// <param name = "message">The note message.</param> /// <param name = "author">The author.</param> /// <param name = "committer">The committer.</param> /// <param name = "namespace">The namespace on which the note will be created. It can be either a canonical namespace or an abbreviated namespace ('refs/notes/myNamespace' or just 'myNamespace').</param> /// <returns>The note which was just saved.</returns> public Note Create(ObjectId targetId, string message, Signature author, Signature committer, string @namespace) { Ensure.ArgumentNotNull(targetId, "targetId"); Ensure.ArgumentNotNullOrEmptyString(message, "message"); Ensure.ArgumentNotNull(author, "author"); Ensure.ArgumentNotNull(committer, "committer"); Ensure.ArgumentNotNullOrEmptyString(@namespace, "@namespace"); string canonicalNamespace = NormalizeToCanonicalName(@namespace); GitOid oid = targetId.Oid; Delete(targetId, author, committer, @namespace); using (SignatureSafeHandle authorHandle = author.BuildHandle()) using (SignatureSafeHandle committerHandle = committer.BuildHandle()) { GitOid noteOid; Ensure.Success(NativeMethods.git_note_create(out noteOid, repo.Handle, authorHandle, committerHandle, canonicalNamespace, ref oid, message)); } return(RetrieveNote(targetId, canonicalNamespace)); }
public static extern int git_signature_new( out SignatureSafeHandle signature, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string name, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string email, long time, int offset);
internal static extern int git_stash_save( out GitOid id, RepositorySafeHandle repo, SignatureSafeHandle stasher, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string message, StashOptions flags);
internal static extern int git_note_remove( RepositorySafeHandle repo, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8Marshaler))] string notes_ref, SignatureSafeHandle author, SignatureSafeHandle committer, ref GitOid oid);