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