refname_is_safe(): improve docstring

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jeff King <peff@peff.net>

Michael Haggerty committed Nov 10, 2015 at 12:42 UTC 03b32623d82d20835d8dda3f9ce9900f09485d11
1 file changed +10 -6
refs.c
+10 -6
@@ -341,13 +341,17 @@ static struct ref_dir *get_ref_dir(struct ref_entry *entry)
341 }
342
343 /*
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().
349 *
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").
355 */
356 static int refname_is_safe(const char *refname)
357 {