]>
git.proxmox.com Git - libgit2.git/blob - include/git2/transaction.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_git_transaction_h__
8 #define INCLUDE_git_transaction_h__
13 * @file git2/transaction.h
14 * @brief Git transactional reference routines
15 * @defgroup git_transaction Git transactional reference routines
22 * Create a new transaction object
24 * This does not lock anything, but sets up the transaction object to
25 * know from which repository to lock.
27 * @param out the resulting transaction
28 * @param repo the repository in which to lock
29 * @return 0 or an error code
31 GIT_EXTERN(int) git_transaction_new(git_transaction
**out
, git_repository
*repo
);
36 * Lock the specified reference. This is the first step to updating a
39 * @param tx the transaction
40 * @param refname the reference to lock
41 * @return 0 or an error message
43 GIT_EXTERN(int) git_transaction_lock_ref(git_transaction
*tx
, const char *refname
);
46 * Set the target of a reference
48 * Set the target of the specified reference. This reference must be
51 * @param tx the transaction
52 * @param refname reference to update
53 * @param target target to set the reference to
54 * @param sig signature to use in the reflog; pass NULL to read the identity from the config
55 * @param msg message to use in the reflog
56 * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
58 GIT_EXTERN(int) git_transaction_set_target(git_transaction
*tx
, const char *refname
, const git_oid
*target
, const git_signature
*sig
, const char *msg
);
61 * Set the target of a reference
63 * Set the target of the specified reference. This reference must be
66 * @param tx the transaction
67 * @param refname reference to update
68 * @param target target to set the reference to
69 * @param sig signature to use in the reflog; pass NULL to read the identity from the config
70 * @param msg message to use in the reflog
71 * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
73 GIT_EXTERN(int) git_transaction_set_symbolic_target(git_transaction
*tx
, const char *refname
, const char *target
, const git_signature
*sig
, const char *msg
);
76 * Set the reflog of a reference
78 * Set the specified reference's reflog. If this is combined with
79 * setting the target, that update won't be written to the reflog.
81 * @param tx the transaction
82 * @param refname the reference whose reflog to set
83 * @param reflog the reflog as it should be written out
84 * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
86 GIT_EXTERN(int) git_transaction_set_reflog(git_transaction
*tx
, const char *refname
, const git_reflog
*reflog
);
91 * @param tx the transaction
92 * @param refname the reference to remove
93 * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
95 GIT_EXTERN(int) git_transaction_remove(git_transaction
*tx
, const char *refname
);
98 * Commit the changes from the transaction
100 * Perform the changes that have been queued. The updates will be made
101 * one by one, and the first failure will stop the processing.
103 * @param tx the transaction
104 * @return 0 or an error code
106 GIT_EXTERN(int) git_transaction_commit(git_transaction
*tx
);
109 * Free the resources allocated by this transaction
111 * If any references remain locked, they will be unlocked without any
112 * changes made to them.
114 * @param tx the transaction
116 GIT_EXTERN(void) git_transaction_free(git_transaction
*tx
);