help: use HTML as the default help format on Windows
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index 9f2da16642b2e284ef96ff12547262cdc2e0bfee..010ed07e33d90cbdae4511013319a129c1201ca9 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -273,6 +273,12 @@ static void add_entry_to_dir(struct ref_dir *dir, struct ref_entry *entry)
 {
        ALLOC_GROW(dir->entries, dir->nr + 1, dir->alloc);
        dir->entries[dir->nr++] = entry;
+       /* optimize for the case that entries are added in order */
+       if (dir->nr == 1 ||
+           (dir->nr == dir->sorted + 1 &&
+            strcmp(dir->entries[dir->nr - 2]->name,
+                   dir->entries[dir->nr - 1]->name) < 0))
+               dir->sorted = dir->nr;
 }
 
 /*
@@ -390,8 +396,10 @@ static struct ref_dir *find_containing_dir(struct ref_dir *dir,
                           refname + dirname.len,
                           (slash + 1) - (refname + dirname.len));
                subdir = search_for_subdir(dir, dirname.buf, mkdir);
-               if (!subdir)
+               if (!subdir) {
+                       dir = NULL;
                        break;
+               }
                dir = subdir;
        }
 
@@ -1230,6 +1238,7 @@ static int warn_if_dangling_symref(const char *refname, const unsigned char *sha
                return 0;
 
        fprintf(d->fp, d->msg_fmt, refname);
+       fputc('\n', d->fp);
        return 0;
 }