Skip to content

Commit 03b3262

Browse files
mhaggerpeff
authored andcommitted
refname_is_safe(): improve docstring
Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent a935ebd commit 03b3262

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

refs.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,17 @@ static struct ref_dir *get_ref_dir(struct ref_entry *entry)
341341
}
342342

343343
/*
344-
* Check if a refname is safe.
345-
* For refs that start with "refs/" we consider it safe as long they do
346-
* not try to resolve to outside of refs/.
344+
* Return true iff refname is minimally safe. "Safe" here means that
345+
* deleting a loose reference by this name will not do any damage, for
346+
* example by causing a file that is not a reference to be deleted.
347+
* This function does not check that the reference name is legal; for
348+
* that, use check_refname_format().
347349
*
348-
* For all other refs we only consider them safe iff they only contain
349-
* upper case characters and '_' (like "HEAD" AND "MERGE_HEAD", and not like
350-
* "config").
350+
* We consider a refname that starts with "refs/" to be safe as long
351+
* as any ".." components that it might contain do not escape "refs/".
352+
* Names that do not start with "refs/" are considered safe iff they
353+
* consist entirely of upper case characters and '_' (like "HEAD" and
354+
* "MERGE_HEAD" but not "config" or "FOO/BAR").
351355
*/
352356
static int refname_is_safe(const char *refname)
353357
{

0 commit comments

Comments
 (0)