[PATCH] all: new command used for multi-repo operations
- From
- Lars Hjemli <hjemli@gmail.com>
- Date
- Jan 23, 2013, 08:52 UTC
- Message-ID
- <CAFXTnz5pG8ifPvMp8xin3xSikGT9iLoUfsrqpepxDDTCMZ2wRQ@mail.gmail.com>
- In-Reply-To
- <CAFXTnz51czE5iS_pgZyU7SdUwrmZcmLxjFGpCGVhLGJFvW=HRQ@mail.gmail.com>
[*git@vger.kernel.org accidentally dropped from cc *]
On Wed, Jan 23, 2013 at 7:52 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
> Lars Hjemli <hjemli@gmail.com> 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.
Show 11 quoted lines
> >> + 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