]>
git.proxmox.com Git - libgit2.git/blob - include/git2/reflog.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_reflog_h__
8 #define INCLUDE_git_reflog_h__
16 * @brief Git reflog management routines
17 * @defgroup git_reflog Git reflog management routines
24 * Read the reflog for the given reference
26 * If there is no reflog file for the given
27 * reference yet, an empty reflog object will
30 * The reflog must be freed manually by using
33 * @param out pointer to reflog
34 * @param repo the repository
35 * @param name reference to look up
36 * @return 0 or an error code
38 GIT_EXTERN(int) git_reflog_read(git_reflog
**out
, git_repository
*repo
, const char *name
);
41 * Write an existing in-memory reflog object back to disk
42 * using an atomic file lock.
44 * @param reflog an existing reflog object
45 * @return 0 or an error code
47 GIT_EXTERN(int) git_reflog_write(git_reflog
*reflog
);
50 * Add a new entry to the in-memory reflog.
52 * `msg` is optional and can be NULL.
54 * @param reflog an existing reflog object
55 * @param id the OID the reference is now pointing to
56 * @param committer the signature of the committer
57 * @param msg the reflog message
58 * @return 0 or an error code
60 GIT_EXTERN(int) git_reflog_append(git_reflog
*reflog
, const git_oid
*id
, const git_signature
*committer
, const char *msg
);
65 * The reflog to be renamed is expected to already exist
67 * The new name will be checked for validity.
68 * See `git_reference_create_symbolic()` for rules about valid names.
70 * @param repo the repository
71 * @param old_name the old name of the reference
72 * @param name the new name of the reference
73 * @return 0 on success, GIT_EINVALIDSPEC or an error code
75 GIT_EXTERN(int) git_reflog_rename(git_repository
*repo
, const char *old_name
, const char *name
);
78 * Delete the reflog for the given reference
80 * @param repo the repository
81 * @param name the reflog to delete
82 * @return 0 or an error code
84 GIT_EXTERN(int) git_reflog_delete(git_repository
*repo
, const char *name
);
87 * Get the number of log entries in a reflog
89 * @param reflog the previously loaded reflog
90 * @return the number of log entries
92 GIT_EXTERN(size_t) git_reflog_entrycount(git_reflog
*reflog
);
95 * Lookup an entry by its index
97 * Requesting the reflog entry with an index of 0 (zero) will
98 * return the most recently created entry.
100 * @param reflog a previously loaded reflog
101 * @param idx the position of the entry to lookup. Should be greater than or
102 * equal to 0 (zero) and less than `git_reflog_entrycount()`.
103 * @return the entry; NULL if not found
105 GIT_EXTERN(const git_reflog_entry
*) git_reflog_entry_byindex(const git_reflog
*reflog
, size_t idx
);
108 * Remove an entry from the reflog by its index
110 * To ensure there's no gap in the log history, set `rewrite_previous_entry`
111 * param value to 1. When deleting entry `n`, member old_oid of entry `n-1`
112 * (if any) will be updated with the value of member new_oid of entry `n+1`.
114 * @param reflog a previously loaded reflog.
116 * @param idx the position of the entry to remove. Should be greater than or
117 * equal to 0 (zero) and less than `git_reflog_entrycount()`.
119 * @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise.
121 * @return 0 on success, GIT_ENOTFOUND if the entry doesn't exist
124 GIT_EXTERN(int) git_reflog_drop(
127 int rewrite_previous_entry
);
132 * @param entry a reflog entry
133 * @return the old oid
135 GIT_EXTERN(const git_oid
*) git_reflog_entry_id_old(const git_reflog_entry
*entry
);
140 * @param entry a reflog entry
141 * @return the new oid at this time
143 GIT_EXTERN(const git_oid
*) git_reflog_entry_id_new(const git_reflog_entry
*entry
);
146 * Get the committer of this entry
148 * @param entry a reflog entry
149 * @return the committer
151 GIT_EXTERN(const git_signature
*) git_reflog_entry_committer(const git_reflog_entry
*entry
);
154 * Get the log message
156 * @param entry a reflog entry
157 * @return the log msg
159 GIT_EXTERN(const char *) git_reflog_entry_message(const git_reflog_entry
*entry
);
164 * @param reflog reflog to free
166 GIT_EXTERN(void) git_reflog_free(git_reflog
*reflog
);