From: Junio C Hamano Date: Fri, 28 Sep 2007 21:20:44 GMT Subject: Re: [PATCH 2/2] fetch/push: readd rsync support Message-ID: <7vtzpeo5ar.fsf@gitster.siamese.dyndns.org> In-Reply-To: Johannes Schindelin writes: > diff --git a/transport.c b/transport.c > index 4f9cddc..c8eed95 100644 > --- a/transport.c > +++ b/transport.c > @@ -6,6 +6,330 @@ > ... > +static int direntry_cmp(const void *a, const void *b) > +{ > + const struct dirent *d1 = a; > + const struct dirent *d2 = b; > + > + return strcmp(d1->d_name, d2->d_name); > +} > ... > +/* > + * path is assumed to point to a buffer of PATH_MAX bytes, and > + * path + name_offset is expected to point to "refs/". > + */ > + > +static int read_loose_refs(struct strbuf *path, int name_offset, > + struct ref **tail) > +{ > + DIR *dir = opendir(path->buf); > + struct dirent *de; > + struct { > + char **entries; > + int nr, alloc; > + } list; > ... > + while ((de = readdir(dir))) { > + if (de->d_name[0] == '.' && (de->d_name[1] == '\0' || > + (de->d_name[1] == '.' && > + de->d_name[2] == '\0'))) > + continue; > + ALLOC_GROW(list.entries, list.nr + 1, list.alloc); > + list.entries[list.nr++] = xstrdup(de->d_name); > + } > + closedir(dir); > + > + /* sort the list */ > + > + qsort(list.entries, list.nr, sizeof(*de), direntry_cmp); Hmmmph...?