Blame include/git2/transaction.h

Packit ae9e2a
/*
Packit ae9e2a
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit ae9e2a
 *
Packit ae9e2a
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit ae9e2a
 * a Linking Exception. For full terms see the included COPYING file.
Packit ae9e2a
 */
Packit ae9e2a
#ifndef INCLUDE_git_transaction_h__
Packit ae9e2a
#define INCLUDE_git_transaction_h__
Packit ae9e2a
Packit ae9e2a
#include "common.h"
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * @file git2/transaction.h
Packit ae9e2a
 * @brief Git transactional reference routines
Packit ae9e2a
 * @defgroup git_transaction Git transactional reference routines
Packit ae9e2a
 * @ingroup Git
Packit ae9e2a
 * @{
Packit ae9e2a
 */
Packit ae9e2a
GIT_BEGIN_DECL
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Create a new transaction object
Packit ae9e2a
 *
Packit ae9e2a
 * This does not lock anything, but sets up the transaction object to
Packit ae9e2a
 * know from which repository to lock.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out the resulting transaction
Packit ae9e2a
 * @param repo the repository in which to lock
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_transaction_new(git_transaction **out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Lock a reference
Packit ae9e2a
 *
Packit ae9e2a
 * Lock the specified reference. This is the first step to updating a
Packit ae9e2a
 * reference.
Packit ae9e2a
 *
Packit ae9e2a
 * @param tx the transaction
Packit ae9e2a
 * @param refname the reference to lock
Packit ae9e2a
 * @return 0 or an error message
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_transaction_lock_ref(git_transaction *tx, const char *refname);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Set the target of a reference
Packit ae9e2a
 *
Packit ae9e2a
 * Set the target of the specified reference. This reference must be
Packit ae9e2a
 * locked.
Packit ae9e2a
 *
Packit ae9e2a
 * @param tx the transaction
Packit ae9e2a
 * @param refname reference to update
Packit ae9e2a
 * @param target target to set the reference to
Packit ae9e2a
 * @param sig signature to use in the reflog; pass NULL to read the identity from the config
Packit ae9e2a
 * @param msg message to use in the reflog
Packit ae9e2a
 * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_transaction_set_target(git_transaction *tx, const char *refname, const git_oid *target, const git_signature *sig, const char *msg);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Set the target of a reference
Packit ae9e2a
 *
Packit ae9e2a
 * Set the target of the specified reference. This reference must be
Packit ae9e2a
 * locked.
Packit ae9e2a
 *
Packit ae9e2a
 * @param tx the transaction
Packit ae9e2a
 * @param refname reference to update
Packit ae9e2a
 * @param target target to set the reference to
Packit ae9e2a
 * @param sig signature to use in the reflog; pass NULL to read the identity from the config
Packit ae9e2a
 * @param msg message to use in the reflog
Packit ae9e2a
 * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_transaction_set_symbolic_target(git_transaction *tx, const char *refname, const char *target, const git_signature *sig, const char *msg);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Set the reflog of a reference
Packit ae9e2a
 *
Packit ae9e2a
 * Set the specified reference's reflog. If this is combined with
Packit ae9e2a
 * setting the target, that update won't be written to the reflog.
Packit ae9e2a
 *
Packit ae9e2a
 * @param tx the transaction
Packit ae9e2a
 * @param refname the reference whose reflog to set
Packit ae9e2a
 * @param reflog the reflog as it should be written out
Packit ae9e2a
 * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_transaction_set_reflog(git_transaction *tx, const char *refname, const git_reflog *reflog);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Remove a reference
Packit ae9e2a
 *
Packit ae9e2a
 * @param tx the transaction
Packit ae9e2a
 * @param refname the reference to remove
Packit ae9e2a
 * @return 0, GIT_ENOTFOUND if the reference is not among the locked ones, or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_transaction_remove(git_transaction *tx, const char *refname);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Commit the changes from the transaction
Packit ae9e2a
 *
Packit ae9e2a
 * Perform the changes that have been queued. The updates will be made
Packit ae9e2a
 * one by one, and the first failure will stop the processing.
Packit ae9e2a
 *
Packit ae9e2a
 * @param tx the transaction
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_transaction_commit(git_transaction *tx);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Free the resources allocated by this transaction
Packit ae9e2a
 *
Packit ae9e2a
 * If any references remain locked, they will be unlocked without any
Packit ae9e2a
 * changes made to them.
Packit ae9e2a
 *
Packit ae9e2a
 * @param tx the transaction
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_transaction_free(git_transaction *tx);
Packit ae9e2a
Packit ae9e2a
/** @} */
Packit ae9e2a
GIT_END_DECL
Packit ae9e2a
#endif