1 /* 2 * Copyright (C) the libgit2 contributors. All rights reserved. 3 * 4 * This file is part of libgit2, distributed under the GNU GPL v2 with 5 * a Linking Exception. For full terms see the included COPYING file. 6 */ 7 module libgit2_d.transaction; 8 9 10 private static import libgit2_d.oid; 11 private static import libgit2_d.types; 12 13 /** 14 * @file git2/transaction.h 15 * @brief Git transactional reference routines 16 * @defgroup git_transaction Git transactional reference routines 17 * @ingroup Git 18 * @{ 19 */ 20 extern (C): 21 nothrow @nogc: 22 public: 23 24 /** 25 * Create a new transaction object 26 * 27 * This does not lock anything, but sets up the transaction object to 28 * know from which repository to lock. 29 * 30 * @param out_ the resulting transaction 31 * @param repo the repository in which to lock 32 * @return 0 or an error code 33 */ 34 //GIT_EXTERN 35 int git_transaction_new(libgit2_d.types.git_transaction** out_, libgit2_d.types.git_repository* repo); 36 37 /** 38 * Lock a reference 39 * 40 * Lock the specified reference. This is the first step to updating a 41 * reference. 42 * 43 * @param tx the transaction 44 * @param refname the reference to lock 45 * @return 0 or an error message 46 */ 47 //GIT_EXTERN 48 int git_transaction_lock_ref(libgit2_d.types.git_transaction* tx, const (char)* refname); 49 50 /** 51 * Set the target of a reference 52 * 53 * Set the target of the specified reference. This reference must be 54 * locked. 55 * 56 * @param tx the transaction 57 * @param refname reference to update 58 * @param target target to set the reference to 59 * @param sig signature to use in the reflog; pass null to read the identity 60 * from the config 61 * @param msg message to use in the reflog 62 * @return 0, git_error_code.GIT_ENOTFOUND if the reference is not among the locked ones, or an 63 * error code 64 */ 65 //GIT_EXTERN 66 int git_transaction_set_target(libgit2_d.types.git_transaction* tx, const (char)* refname, const (libgit2_d.oid.git_oid)* target, const (libgit2_d.types.git_signature)* sig, const (char)* msg); 67 68 /** 69 * Set the target of a reference 70 * 71 * Set the target of the specified reference. This reference must be 72 * locked. 73 * 74 * @param tx the transaction 75 * @param refname reference to update 76 * @param target target to set the reference to 77 * @param sig signature to use in the reflog; pass null to read the identity 78 * from the config 79 * @param msg message to use in the reflog 80 * @return 0, git_error_code.GIT_ENOTFOUND if the reference is not among the locked ones, or an 81 * error code 82 */ 83 //GIT_EXTERN 84 int git_transaction_set_symbolic_target(libgit2_d.types.git_transaction* tx, const (char)* refname, const (char)* target, const (libgit2_d.types.git_signature)* sig, const (char)* msg); 85 86 /** 87 * Set the reflog of a reference 88 * 89 * Set the specified reference's reflog. If this is combined with 90 * setting the target, that update won't be written to the reflog. 91 * 92 * @param tx the transaction 93 * @param refname the reference whose reflog to set 94 * @param reflog the reflog as it should be written out 95 * @return 0, git_error_code.GIT_ENOTFOUND if the reference is not among the locked ones, or an 96 * error code 97 */ 98 //GIT_EXTERN 99 int git_transaction_set_reflog(libgit2_d.types.git_transaction* tx, const (char)* refname, const (libgit2_d.types.git_reflog)* reflog); 100 101 /** 102 * Remove a reference 103 * 104 * @param tx the transaction 105 * @param refname the reference to remove 106 * @return 0, git_error_code.GIT_ENOTFOUND if the reference is not among the locked ones, or an 107 * error code 108 */ 109 //GIT_EXTERN 110 int git_transaction_remove(libgit2_d.types.git_transaction* tx, const (char)* refname); 111 112 /** 113 * Commit the changes from the transaction 114 * 115 * Perform the changes that have been queued. The updates will be made 116 * one by one, and the first failure will stop the processing. 117 * 118 * @param tx the transaction 119 * @return 0 or an error code 120 */ 121 //GIT_EXTERN 122 int git_transaction_commit(libgit2_d.types.git_transaction* tx); 123 124 /** 125 * Free the resources allocated by this transaction 126 * 127 * If any references remain locked, they will be unlocked without any 128 * changes made to them. 129 * 130 * @param tx the transaction 131 */ 132 //GIT_EXTERN 133 void git_transaction_free(libgit2_d.types.git_transaction* tx); 134 135 /** @} */