read_raw_ref(): move docstring to header file
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Michael Haggerty committed
May 6, 2016 at 17:25 UTC
cf596442c6a18268f3f0d95cf7615a613102746f
2 files changed
+38
-38
refs/files-backend.c
-38
@@ -1388,44 +1388,6 @@ static int resolve_missing_loose_ref(const char *refname,
1388
return -1;
1389
}
1390
1391
-/*
1392
- * Read the specified reference from the filesystem or packed refs
1393
- * file, non-recursively. Set type to describe the reference, and:
1394
- *
1395
- * - If refname is the name of a normal reference, fill in sha1
1396
- * (leaving referent unchanged).
1397
- *
1398
- * - If refname is the name of a symbolic reference, write the full
1399
- * name of the reference to which it refers (e.g.
1400
- * "refs/heads/master") to referent and set the REF_ISSYMREF bit in
1401
- * type (leaving sha1 unchanged). The caller is responsible for
1402
- * validating that referent is a valid reference name.
1403
- *
1404
- * WARNING: refname might be used as part of a filename, so it is
1405
- * important from a security standpoint that it be safe in the sense
1406
- * of refname_is_safe(). Moreover, for symrefs this function sets
1407
- * referent to whatever the repository says, which might not be a
1408
- * properly-formatted or even safe reference name. NEITHER INPUT NOR
1409
- * OUTPUT REFERENCE NAMES ARE VALIDATED WITHIN THIS FUNCTION.
1410
- *
1411
- * Return 0 on success. If the ref doesn't exist, set errno to ENOENT
1412
- * and return -1. If the ref exists but is neither a symbolic ref nor
1413
- * a sha1, it is broken; set REF_ISBROKEN in type, set errno to
1414
- * EINVAL, and return -1. If there is another error reading the ref,
1415
- * set errno appropriately and return -1.
1416
- *
1417
- * Backend-specific flags might be set in type as well, regardless of
1418
- * outcome.
1419
- *
1420
- * It is OK for refname to point into referent. If so:
1421
- *
1422
- * - if the function succeeds with REF_ISSYMREF, referent will be
1423
- * overwritten and the memory formerly pointed to by it might be
1424
- * changed or even freed.
1425
- *
1426
- * - in all other cases, referent will be untouched, and therefore
1427
- * refname will still be valid and unchanged.
1428
- */
1391
int read_raw_ref(const char *refname, unsigned char *sha1,
1392
struct strbuf *referent, unsigned int *type)
1393
{
refs/refs-internal.h
+38
@@ -209,6 +209,44 @@ int rename_ref_available(const char *oldname, const char *newname);
209
int do_for_each_ref(const char *submodule, const char *base,
210
each_ref_fn fn, int trim, int flags, void *cb_data);
211
212
+/*
213
+ * Read the specified reference from the filesystem or packed refs
214
+ * file, non-recursively. Set type to describe the reference, and:
215
+ *
216
+ * - If refname is the name of a normal reference, fill in sha1
217
+ * (leaving referent unchanged).
218
+ *
219
+ * - If refname is the name of a symbolic reference, write the full
220
+ * name of the reference to which it refers (e.g.
221
+ * "refs/heads/master") to referent and set the REF_ISSYMREF bit in
222
+ * type (leaving sha1 unchanged). The caller is responsible for
223
+ * validating that referent is a valid reference name.
224
+ *
225
+ * WARNING: refname might be used as part of a filename, so it is
226
+ * important from a security standpoint that it be safe in the sense
227
+ * of refname_is_safe(). Moreover, for symrefs this function sets
228
+ * referent to whatever the repository says, which might not be a
229
+ * properly-formatted or even safe reference name. NEITHER INPUT NOR
230
+ * OUTPUT REFERENCE NAMES ARE VALIDATED WITHIN THIS FUNCTION.
231
+ *
232
+ * Return 0 on success. If the ref doesn't exist, set errno to ENOENT
233
+ * and return -1. If the ref exists but is neither a symbolic ref nor
234
+ * a sha1, it is broken; set REF_ISBROKEN in type, set errno to
235
+ * EINVAL, and return -1. If there is another error reading the ref,
236
+ * set errno appropriately and return -1.
237
+ *
238
+ * Backend-specific flags might be set in type as well, regardless of
239
+ * outcome.
240
+ *
241
+ * It is OK for refname to point into referent. If so:
242
+ *
243
+ * - if the function succeeds with REF_ISSYMREF, referent will be
244
+ * overwritten and the memory formerly pointed to by it might be
245
+ * changed or even freed.
246
+ *
247
+ * - in all other cases, referent will be untouched, and therefore
248
+ * refname will still be valid and unchanged.
249
+ */
250
int read_raw_ref(const char *refname, unsigned char *sha1,
251
struct strbuf *referent, unsigned int *type);
252