From: Junio C Hamano Date: Fri, 23 Sep 2011 21:20:51 +0000 (-0700) Subject: Merge branch 'mh/check-ref-format-print-normalize' into maint X-Git-Tag: v1.7.6.4~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/be5acb3b63af077db05788235a1d845d511e4561?ds=inline;hp=-c Merge branch 'mh/check-ref-format-print-normalize' into maint * mh/check-ref-format-print-normalize: Forbid DEL characters in reference names check-ref-format --print: Normalize refnames that start with slashes --- be5acb3b63af077db05788235a1d845d511e4561 diff --combined refs.c index 3a8789d385,6f471d42c3..0fa8dcf3e1 --- a/refs.c +++ b/refs.c @@@ -837,7 -837,7 +837,7 @@@ int for_each_rawref(each_ref_fn fn, voi static inline int bad_ref_char(int ch) { - if (((unsigned) ch) <= ' ' || + if (((unsigned) ch) <= ' ' || ch == 0x7f || ch == '~' || ch == '^' || ch == ':' || ch == '\\') return 1; /* 2.13 Pattern Matching Notation */ @@@ -1451,7 -1451,7 +1451,7 @@@ int write_ref_sha1(struct ref_lock *loc } o = parse_object(sha1); if (!o) { - error("Trying to write ref %s with nonexistant object %s", + error("Trying to write ref %s with nonexistent object %s", lock->ref_name, sha1_to_hex(sha1)); unlock_ref(lock); return -1; @@@ -1826,12 -1826,6 +1826,12 @@@ int update_ref(const char *action, cons return 0; } +int ref_exists(char *refname) +{ + unsigned char sha1[20]; + return !!resolve_ref(refname, sha1, 1, NULL); +} + struct ref *find_ref_by_name(const struct ref *list, const char *name) { for ( ; list; list = list->next)