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  * Params:
31  *      out_ = the resulting transaction
32  *      repo = the repository in which to lock
33  *
34  * Returns: 0 or an error code
35  */
36 //GIT_EXTERN
37 int git_transaction_new(libgit2_d.types.git_transaction** out_, libgit2_d.types.git_repository* repo);
38 
39 /**
40  * Lock a reference
41  *
42  * Lock the specified reference. This is the first step to updating a
43  * reference.
44  *
45  * Params:
46  *      tx = the transaction
47  *      refname = the reference to lock
48  *
49  * Returns: 0 or an error message
50  */
51 //GIT_EXTERN
52 int git_transaction_lock_ref(libgit2_d.types.git_transaction* tx, const (char)* refname);
53 
54 /**
55  * Set the target of a reference
56  *
57  * Set the target of the specified reference. This reference must be
58  * locked.
59  *
60  * Params:
61  *      tx = the transaction
62  *      refname = reference to update
63  *      target = target to set the reference to
64  *      sig = signature to use in the reflog; pass null to read the identity from the config
65  *      msg = message to use in the reflog
66  *
67  * Returns: 0, git_error_code.GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
68  */
69 //GIT_EXTERN
70 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);
71 
72 /**
73  * Set the target of a reference
74  *
75  * Set the target of the specified reference. This reference must be
76  * locked.
77  *
78  * Params:
79  *      tx = the transaction
80  *      refname = reference to update
81  *      target = target to set the reference to
82  *      sig = signature to use in the reflog; pass null to read the identity from the config
83  *      msg = message to use in the reflog
84  *
85  * Returns: 0, git_error_code.GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
86  */
87 //GIT_EXTERN
88 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);
89 
90 /**
91  * Set the reflog of a reference
92  *
93  * Set the specified reference's reflog. If this is combined with
94  * setting the target, that update won't be written to the reflog.
95  *
96  * Params:
97  *      tx = the transaction
98  *      refname = the reference whose reflog to set
99  *      reflog = the reflog as it should be written out
100  *
101  * Returns: 0, git_error_code.GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
102  */
103 //GIT_EXTERN
104 int git_transaction_set_reflog(libgit2_d.types.git_transaction* tx, const (char)* refname, const (libgit2_d.types.git_reflog)* reflog);
105 
106 /**
107  * Remove a reference
108  *
109  * Params:
110  *      tx = the transaction
111  *      refname = the reference to remove
112  *
113  * Returns: 0, git_error_code.GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
114  */
115 //GIT_EXTERN
116 int git_transaction_remove(libgit2_d.types.git_transaction* tx, const (char)* refname);
117 
118 /**
119  * Commit the changes from the transaction
120  *
121  * Perform the changes that have been queued. The updates will be made
122  * one by one, and the first failure will stop the processing.
123  *
124  * Params:
125  *      tx = the transaction
126  *
127  * Returns: 0 or an error code
128  */
129 //GIT_EXTERN
130 int git_transaction_commit(libgit2_d.types.git_transaction* tx);
131 
132 /**
133  * Free the resources allocated by this transaction
134  *
135  * If any references remain locked, they will be unlocked without any
136  * changes made to them.
137  *
138  * Params:
139  *      tx = the transaction
140  */
141 //GIT_EXTERN
142 void git_transaction_free(libgit2_d.types.git_transaction* tx);
143 
144 /** @} */