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.reflog; 8 9 10 private static import libgit2_d.oid; 11 private static import libgit2_d.types; 12 13 /** 14 * @file git2/reflog.h 15 * @brief Git reflog management routines 16 * @defgroup git_reflog Git reflog management routines 17 * @ingroup Git 18 * @{ 19 */ 20 extern (C): 21 nothrow @nogc: 22 public: 23 24 /** 25 * Read the reflog for the given reference 26 * 27 * If there is no reflog file for the given 28 * reference yet, an empty reflog object will 29 * be returned. 30 * 31 * The reflog must be freed manually by using 32 * git_reflog_free(). 33 * 34 * @param out_ pointer to reflog 35 * @param repo the repostiory 36 * @param name reference to look up 37 * @return 0 or an error code 38 */ 39 //GIT_EXTERN 40 int git_reflog_read(libgit2_d.types.git_reflog** out_, libgit2_d.types.git_repository* repo, const (char)* name); 41 42 /** 43 * Write an existing in-memory reflog object back to disk 44 * using an atomic file lock. 45 * 46 * @param reflog an existing reflog object 47 * @return 0 or an error code 48 */ 49 //GIT_EXTERN 50 int git_reflog_write(libgit2_d.types.git_reflog* reflog); 51 52 /** 53 * Add a new entry to the in-memory reflog. 54 * 55 * `msg` is optional and can be null. 56 * 57 * @param reflog an existing reflog object 58 * @param id the OID the reference is now pointing to 59 * @param committer the signature of the committer 60 * @param msg the reflog message 61 * @return 0 or an error code 62 */ 63 //GIT_EXTERN 64 int git_reflog_append(libgit2_d.types.git_reflog* reflog, const (libgit2_d.oid.git_oid)* id, const (libgit2_d.types.git_signature)* committer, const (char)* msg); 65 66 /** 67 * Rename a reflog 68 * 69 * The reflog to be renamed is expected to already exist 70 * 71 * The new name will be checked for validity. 72 * See `git_reference_create_symbolic()` for rules about valid names. 73 * 74 * @param repo the repository 75 * @param old_name the old name of the reference 76 * @param name the new name of the reference 77 * @return 0 on success, git_error_code.GIT_EINVALIDSPEC or an error code 78 */ 79 //GIT_EXTERN 80 int git_reflog_rename(libgit2_d.types.git_repository* repo, const (char)* old_name, const (char)* name); 81 82 /** 83 * Delete the reflog for the given reference 84 * 85 * @param repo the repository 86 * @param name the reflog to delete 87 * @return 0 or an error code 88 */ 89 //GIT_EXTERN 90 int git_reflog_delete(libgit2_d.types.git_repository* repo, const (char)* name); 91 92 /** 93 * Get the number of log entries in a reflog 94 * 95 * @param reflog the previously loaded reflog 96 * @return the number of log entries 97 */ 98 //GIT_EXTERN 99 size_t git_reflog_entrycount(libgit2_d.types.git_reflog* reflog); 100 101 /** 102 * Lookup an entry by its index 103 * 104 * Requesting the reflog entry with an index of 0 (zero) will 105 * return the most recently created entry. 106 * 107 * @param reflog a previously loaded reflog 108 * @param idx the position of the entry to lookup. Should be greater than or 109 * equal to 0 (zero) and less than `git_reflog_entrycount()`. 110 * @return the entry; null if not found 111 */ 112 //GIT_EXTERN 113 const (libgit2_d.types.git_reflog_entry)* git_reflog_entry_byindex(const (libgit2_d.types.git_reflog)* reflog, size_t idx); 114 115 /** 116 * Remove an entry from the reflog by its index 117 * 118 * To ensure there's no gap in the log history, set `rewrite_previous_entry` 119 * param value to 1. When deleting entry `n`, member old_oid of entry `n-1` 120 * (if any) will be updated with the value of member new_oid of entry `n+1`. 121 * 122 * @param reflog a previously loaded reflog. 123 * 124 * @param idx the position of the entry to remove. Should be greater than or 125 * equal to 0 (zero) and less than `git_reflog_entrycount()`. 126 * 127 * @param rewrite_previous_entry 1 to rewrite the history; 0 otherwise. 128 * 129 * @return 0 on success, git_error_code.GIT_ENOTFOUND if the entry doesn't exist 130 * or an error code. 131 */ 132 //GIT_EXTERN 133 int git_reflog_drop(libgit2_d.types.git_reflog* reflog, size_t idx, int rewrite_previous_entry); 134 135 /** 136 * Get the old oid 137 * 138 * @param entry a reflog entry 139 * @return the old oid 140 */ 141 //GIT_EXTERN 142 const (libgit2_d.oid.git_oid)* git_reflog_entry_id_old(const (libgit2_d.types.git_reflog_entry)* entry); 143 144 /** 145 * Get the new oid 146 * 147 * @param entry a reflog entry 148 * @return the new oid at this time 149 */ 150 //GIT_EXTERN 151 const (libgit2_d.oid.git_oid)* git_reflog_entry_id_new(const (libgit2_d.types.git_reflog_entry)* entry); 152 153 /** 154 * Get the committer of this entry 155 * 156 * @param entry a reflog entry 157 * @return the committer 158 */ 159 //GIT_EXTERN 160 const (libgit2_d.types.git_signature)* git_reflog_entry_committer(const (libgit2_d.types.git_reflog_entry)* entry); 161 162 /** 163 * Get the log message 164 * 165 * @param entry a reflog entry 166 * @return the log msg 167 */ 168 //GIT_EXTERN 169 const (char)* git_reflog_entry_message(const (libgit2_d.types.git_reflog_entry)* entry); 170 171 /** 172 * Free the reflog 173 * 174 * @param reflog reflog to free 175 */ 176 //GIT_EXTERN 177 void git_reflog_free(libgit2_d.types.git_reflog* reflog); 178 179 /** @} */