@@ -10,7 +10,7 @@ use crate::{bstr::BString, ext::ReferenceExt, reference, Reference};
10
10
impl crate :: Repository {
11
11
/// Create a lightweight tag with given `name` (and without `refs/tags/` prefix) pointing to the given `target`, and return it as reference.
12
12
///
13
- /// It will be created with `constraint` which is most commonly to [only create it][ PreviousValue::MustNotExist]
13
+ /// It will be created with `constraint` which is most commonly to [only create it]( PreviousValue::MustNotExist)
14
14
/// or to [force overwriting a possibly existing tag](PreviousValue::Any).
15
15
pub fn tag_reference (
16
16
& self ,
@@ -135,25 +135,37 @@ impl crate::Repository {
135
135
136
136
/// Edit one or more references as described by their `edits`.
137
137
/// Note that one can set the committer name for use in the ref-log by temporarily
138
- /// [overriding the git-config][crate::Repository::config_snapshot_mut()].
138
+ /// [overriding the git-config](crate::Repository::config_snapshot_mut()), or use
139
+ /// [`edit_references_as(committer)`](Self::edit_references_as()) for convenience.
139
140
///
140
141
/// Returns all reference edits, which might be more than where provided due the splitting of symbolic references, and
141
142
/// whose previous (_old_) values are the ones seen on in storage after the reference was locked.
142
143
pub fn edit_references (
143
144
& self ,
144
145
edits : impl IntoIterator < Item = RefEdit > ,
146
+ ) -> Result < Vec < RefEdit > , reference:: edit:: Error > {
147
+ self . edit_references_as ( edits, self . committer ( ) . transpose ( ) ?)
148
+ }
149
+
150
+ /// A way to apply reference `edits` similar to [edit_references(…)](Self::edit_references()), but set a specific
151
+ /// `commiter` for use in the reflog. It can be `None` if it's the purpose `edits` are configured to not update the
152
+ /// reference log, or cause a failure otherwise.
153
+ pub fn edit_references_as (
154
+ & self ,
155
+ edits : impl IntoIterator < Item = RefEdit > ,
156
+ committer : Option < gix_actor:: SignatureRef < ' _ > > ,
145
157
) -> Result < Vec < RefEdit > , reference:: edit:: Error > {
146
158
let ( file_lock_fail, packed_refs_lock_fail) = self . config . lock_timeout ( ) ?;
147
159
self . refs
148
160
. transaction ( )
149
161
. prepare ( edits, file_lock_fail, packed_refs_lock_fail) ?
150
- . commit ( self . committer ( ) . transpose ( ) ? )
162
+ . commit ( committer)
151
163
. map_err ( Into :: into)
152
164
}
153
165
154
166
/// Return the repository head, an abstraction to help dealing with the `HEAD` reference.
155
167
///
156
- /// The `HEAD` reference can be in various states, for more information, the documentation of [`Head`][ crate::Head] .
168
+ /// The `HEAD` reference can be in various states, for more information, the documentation of [`Head`]( crate::Head) .
157
169
pub fn head ( & self ) -> Result < crate :: Head < ' _ > , reference:: find:: existing:: Error > {
158
170
let head = self . find_reference ( "HEAD" ) ?;
159
171
Ok ( match head. inner . target {
@@ -184,7 +196,7 @@ impl crate::Repository {
184
196
185
197
/// Return the name to the symbolic reference `HEAD` points to, or `None` if the head is detached.
186
198
///
187
- /// The difference to [`head_ref()`][ Self::head_ref()] is that the latter requires the reference to exist,
199
+ /// The difference to [`head_ref()`]( Self::head_ref()) is that the latter requires the reference to exist,
188
200
/// whereas here we merely return a the name of the possibly unborn reference.
189
201
pub fn head_name ( & self ) -> Result < Option < FullName > , reference:: find:: existing:: Error > {
190
202
Ok ( self . head ( ) ?. referent_name ( ) . map ( std:: borrow:: ToOwned :: to_owned) )
@@ -228,7 +240,7 @@ impl crate::Repository {
228
240
/// Find the reference with the given partial or full `name`, like `main`, `HEAD`, `heads/branch` or `origin/other`,
229
241
/// or return an error if it wasn't found.
230
242
///
231
- /// Consider [`try_find_reference(…)`][ crate::Repository::try_find_reference()] if the reference might not exist
243
+ /// Consider [`try_find_reference(…)`]( crate::Repository::try_find_reference()) if the reference might not exist
232
244
/// without that being considered an error.
233
245
pub fn find_reference < ' a , Name , E > ( & self , name : Name ) -> Result < Reference < ' _ > , reference:: find:: existing:: Error >
234
246
where
@@ -249,7 +261,7 @@ impl crate::Repository {
249
261
250
262
/// Return a platform for iterating references.
251
263
///
252
- /// Common kinds of iteration are [all][ crate::reference::iter::Platform::all()] or [prefixed][ crate::reference::iter::Platform::prefixed()]
264
+ /// Common kinds of iteration are [all]( crate::reference::iter::Platform::all()) or [prefixed]( crate::reference::iter::Platform::prefixed())
253
265
/// references.
254
266
pub fn references ( & self ) -> Result < reference:: iter:: Platform < ' _ > , reference:: iter:: Error > {
255
267
Ok ( reference:: iter:: Platform {
@@ -261,7 +273,7 @@ impl crate::Repository {
261
273
/// Try to find the reference named `name`, like `main`, `heads/branch`, `HEAD` or `origin/other`, and return it.
262
274
///
263
275
/// Otherwise return `None` if the reference wasn't found.
264
- /// If the reference is expected to exist, use [`find_reference()`][ crate::Repository::find_reference()] .
276
+ /// If the reference is expected to exist, use [`find_reference()`]( crate::Repository::find_reference()) .
265
277
pub fn try_find_reference < ' a , Name , E > ( & self , name : Name ) -> Result < Option < Reference < ' _ > > , reference:: find:: Error >
266
278
where
267
279
Name : TryInto < & ' a PartialNameRef , Error = E > ,
0 commit comments