Hash :
2508cc66
Author :
Date :
2012-11-18T21:38:08
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
/*
* Copyright (C) 2009-2012 the libgit2 contributors
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_git_reflog_h__
#define INCLUDE_git_reflog_h__
#include "common.h"
#include "types.h"
#include "oid.h"
/**
* @file git2/reflog.h
* @brief Git reflog management routines
* @defgroup git_reflog Git reflog management routines
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
/**
* Read the reflog for the given reference
*
* If there is no reflog file for the given
* reference yet, an empty reflog object will
* be returned.
*
* The reflog must be freed manually by using
* git_reflog_free().
*
* @param out pointer to reflog
* @param ref reference to read the reflog for
* @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_read(git_reflog **out, const git_reference *ref);
/**
* Write an existing in-memory reflog object back to disk
* using an atomic file lock.
*
* @param reflog an existing reflog object
* @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_write(git_reflog *reflog);
/**
* Add a new entry to the reflog.
*
* `msg` is optional and can be NULL.
*
* @param reflog an existing reflog object
* @param id the OID the reference is now pointing to
* @param committer the signature of the committer
* @param msg the reflog message
* @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_append(git_reflog *reflog, const git_oid *id, const git_signature *committer, const char *msg);
/**
* Rename the reflog for the given reference
*
* The reflog to be renamed is expected to already exist
*
* @param ref the reference
* @param name the new name of the reference
* @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_rename(git_reference *ref, const char *name);
/**
* Delete the reflog for the given reference
*
* @param ref the reference
* @return 0 or an error code
*/
GIT_EXTERN(int) git_reflog_delete(git_reference *ref);
/**
* Get the number of log entries in a reflog
*
* @param reflog the previously loaded reflog
* @return the number of log entries
*/
GIT_EXTERN(size_t) git_reflog_entrycount(git_reflog *reflog);
/**
* Lookup an entry by its index
*
* Requesting the reflog entry with an index of 0 (zero) will
* return the most recently created entry.
*
* @param reflog a previously loaded reflog
* @param idx the position of the entry to lookup. Should be greater than or
* equal to 0 (zero) and less than `git_reflog_entrycount()`.
* @return the entry; NULL if not found
*/
GIT_EXTERN(const git_reflog_entry *) git_reflog_entry_byindex(git_reflog *reflog, size_t idx);
/**
* Remove an entry from the reflog by its index
*
* To ensure there's no gap in the log history, set `rewrite_previous_entry`
* param value to 1. When deleting entry `n`, member old_oid of entry `n-1`
* (if any) will be updated with the value of member new_oid of entry `n+1`.
*
* @param reflog a previously loaded reflog.
*
* @param idx the position of the entry to remove. Should be greater than or
* equal to 0 (zero) and less than `git_reflog_entrycount()`.
*
* @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise.
*
* @return 0 on success, GIT_ENOTFOUND if the entry doesn't exist
* or an error code.
*/
GIT_EXTERN(int) git_reflog_drop(
git_reflog *reflog,
size_t idx,
int rewrite_previous_entry);
/**
* Get the old oid
*
* @param entry a reflog entry
* @return the old oid
*/
GIT_EXTERN(const git_oid *) git_reflog_entry_id_old(const git_reflog_entry *entry);
/**
* Get the new oid
*
* @param entry a reflog entry
* @return the new oid at this time
*/
GIT_EXTERN(const git_oid *) git_reflog_entry_id_new(const git_reflog_entry *entry);
/**
* Get the committer of this entry
*
* @param entry a reflog entry
* @return the committer
*/
GIT_EXTERN(const git_signature *) git_reflog_entry_committer(const git_reflog_entry *entry);
/**
* Get the log message
*
* @param entry a reflog entry
* @return the log msg
*/
GIT_EXTERN(const char *) git_reflog_entry_message(const git_reflog_entry *entry);
/**
* Free the reflog
*
* @param reflog reflog to free
*/
GIT_EXTERN(void) git_reflog_free(git_reflog *reflog);
/** @} */
GIT_END_DECL
#endif