From: Junio C Hamano Date: Tue, 29 May 2012 20:08:35 +0000 (-0700) Subject: Merge branch 'mh/ref-api-lazy-loose' X-Git-Tag: v1.7.11-rc1~19 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/38f2b874ff0e7d6f182b7995d45efbaf1adfe94a?ds=inline;hp=-c Merge branch 'mh/ref-api-lazy-loose' The code to lazily read loose refs unnecessarily read the refs in a subhierarchy by mistake when we free the data for the subhierarchy. By Michael Haggerty * mh/ref-api-lazy-loose: free_ref_entry(): do not trigger reading of loose refs --- 38f2b874ff0e7d6f182b7995d45efbaf1adfe94a diff --combined refs.c index 010ed07e33,c9f48735fc..51c8825acf --- a/refs.c +++ b/refs.c @@@ -259,8 -259,13 +259,13 @@@ static void clear_ref_dir(struct ref_di static void free_ref_entry(struct ref_entry *entry) { - if (entry->flag & REF_DIR) - clear_ref_dir(get_ref_dir(entry)); + if (entry->flag & REF_DIR) { + /* + * Do not use get_ref_dir() here, as that might + * trigger the reading of loose refs. + */ + clear_ref_dir(&entry->u.subdir); + } free(entry); } @@@ -273,12 -278,6 +278,12 @@@ static void add_entry_to_dir(struct ref { 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; } /* @@@ -1238,7 -1237,6 +1243,7 @@@ static int warn_if_dangling_symref(cons return 0; fprintf(d->fp, d->msg_fmt, refname); + fputc('\n', d->fp); return 0; }