Merge branch 'mh/check-ref-format-print-normalize' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 23 Sep 2011 21:20:51 +0000 (14:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 23 Sep 2011 21:20:51 +0000 (14:20 -0700)
* mh/check-ref-format-print-normalize:
Forbid DEL characters in reference names
check-ref-format --print: Normalize refnames that start with slashes

1  2 
refs.c
diff --combined refs.c
index 3a8789d3857d17a3a0a94ba2750e9f22857b8667,6f471d42c37ab4e66f402d1c983d3d42e4ebb2d8..0fa8dcf3e10bfed4825db1c3d2cf140507cfa617
--- 1/refs.c
--- 2/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)