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