[*git@xxxxxxxxxxxxxxx accidentally dropped from cc *] On Wed, Jan 23, 2013 at 7:52 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote: > Lars Hjemli <hjemli@xxxxxxxxx> writes: > >> +static int walk(struct strbuf *path, int argc, const char **argv) >> +{ >> + DIR *dir; >> + struct dirent *ent; >> + size_t len; >> + >> + dir = opendir(path->buf); >> + if (!dir) >> + return errno; >> + strbuf_addstr(path, "/"); >> + len = path->len; >> + while ((ent = readdir(dir))) { >> + if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) >> + continue; >> + if (!strcmp(ent->d_name, ".git")) { > > This only looks for the top of working tree. Have you considered if > this "iterate over directories and list git repositories in them" > may be useful for collection of bare repositories, and if it is, how > to go about implementing the discovery process? Yes, occasionally I've needed this, but implementing it in my original shell script was cumbersome. Doing it in C should be as simple as invoking is_git_directory() on each subdir. > >> + if (ent->d_type != DT_DIR) >> + continue; > > I think this is wrong. > > On platforms that need a NO_D_TYPE_IN_DIRENT build, your compilation > may fail here (you would need to lstat() it yourself). See how > dir.c does this without ugly #ifdef's in the code, especially around > the use of get_dtype() and DTYPE() macro. > Thanks for the pointer, will fix. -- larsh -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html