Skip to content

Commit d1dd721

Browse files
mhaggergitster
authored andcommitted
refs.h: remove duplication in function docstrings
Add more information to the comment introducing the four reference transaction update functions, so that each function's docstring doesn't have to repeat it. Add a pointer from the individual functions' docstrings to the introductory comment. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4b7b520 commit d1dd721

File tree

1 file changed

+43
-23
lines changed

1 file changed

+43
-23
lines changed

refs.h

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,31 @@ enum action_on_err {
255255
struct ref_transaction *ref_transaction_begin(struct strbuf *err);
256256

257257
/*
258-
* The following functions add a reference check or update to a
259-
* ref_transaction. In all of them, refname is the name of the
260-
* reference to be affected. The functions make internal copies of
261-
* refname and msg, so the caller retains ownership of these parameters.
262-
* flags can be REF_NODEREF; it is passed to update_ref_lock().
258+
* Reference transaction updates
259+
*
260+
* The following four functions add a reference check or update to a
261+
* ref_transaction. They have some common similar parameters:
262+
*
263+
* transaction -- a pointer to an open ref_transaction, obtained
264+
* from ref_transaction_begin().
265+
*
266+
* refname -- the name of the reference to be affected.
267+
*
268+
* flags -- flags affecting the update, passed to
269+
* update_ref_lock(). Can be REF_NODEREF, which means that
270+
* symbolic references should not be followed.
271+
*
272+
* msg -- a message describing the change (for the reflog).
273+
*
274+
* err -- a strbuf for receiving a description of any error that
275+
* might have occured.
276+
*
277+
* The functions make internal copies of refname and msg, so the
278+
* caller retains ownership of these parameters.
279+
*
280+
* The functions return 0 on success and non-zero on failure. A
281+
* failure means that the transaction as a whole has failed and needs
282+
* to be rolled back.
263283
*/
264284

265285
/*
@@ -273,9 +293,8 @@ struct ref_transaction *ref_transaction_begin(struct strbuf *err);
273293
* whole transaction fails. If old_sha1 is NULL, then the previous
274294
* value is not checked.
275295
*
276-
* Return 0 on success and non-zero on failure. Any failure in the
277-
* transaction means that the transaction as a whole has failed and
278-
* will need to be rolled back.
296+
* See the above comment "Reference transaction updates" for more
297+
* information.
279298
*/
280299
int ref_transaction_update(struct ref_transaction *transaction,
281300
const char *refname,
@@ -285,13 +304,13 @@ int ref_transaction_update(struct ref_transaction *transaction,
285304
struct strbuf *err);
286305

287306
/*
288-
* Add a reference creation to transaction. new_sha1 is the value
289-
* that the reference should have after the update; it must not be the
290-
* null SHA-1. It is verified that the reference does not exist
307+
* Add a reference creation to transaction. new_sha1 is the value that
308+
* the reference should have after the update; it must not be
309+
* null_sha1. It is verified that the reference does not exist
291310
* already.
292-
* Function returns 0 on success and non-zero on failure. A failure to create
293-
* means that the transaction as a whole has failed and will need to be
294-
* rolled back.
311+
*
312+
* See the above comment "Reference transaction updates" for more
313+
* information.
295314
*/
296315
int ref_transaction_create(struct ref_transaction *transaction,
297316
const char *refname,
@@ -300,12 +319,12 @@ int ref_transaction_create(struct ref_transaction *transaction,
300319
struct strbuf *err);
301320

302321
/*
303-
* Add a reference deletion to transaction. If old_sha1 is non-NULL, then
304-
* it holds the value that the reference should have had before
305-
* the update (which must not be the null SHA-1).
306-
* Function returns 0 on success and non-zero on failure. A failure to delete
307-
* means that the transaction as a whole has failed and will need to be
308-
* rolled back.
322+
* Add a reference deletion to transaction. If old_sha1 is non-NULL,
323+
* then it holds the value that the reference should have had before
324+
* the update (which must not be null_sha1).
325+
*
326+
* See the above comment "Reference transaction updates" for more
327+
* information.
309328
*/
310329
int ref_transaction_delete(struct ref_transaction *transaction,
311330
const char *refname,
@@ -316,9 +335,10 @@ int ref_transaction_delete(struct ref_transaction *transaction,
316335
/*
317336
* Verify, within a transaction, that refname has the value old_sha1,
318337
* or, if old_sha1 is null_sha1, then verify that the reference
319-
* doesn't exist. old_sha1 must be non-NULL. Function returns 0 on
320-
* success and non-zero on failure. A failure to verify means that the
321-
* transaction as a whole has failed and will need to be rolled back.
338+
* doesn't exist. old_sha1 must be non-NULL.
339+
*
340+
* See the above comment "Reference transaction updates" for more
341+
* information.
322342
*/
323343
int ref_transaction_verify(struct ref_transaction *transaction,
324344
const char *refname,

0 commit comments

Comments
 (0)