git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] all: new command used for multi-repo operations

From
LHLars Hjemli <hjemli@gmail.com>
Date
Jan 23, 2013, 18:19 UTC
Message-ID
<CAFXTnz5VJCwk7DWMe_9kZdY4OfLzbj0eqVB976DUT_bogzr4sg@mail.gmail.com>
In-Reply-To
<7v622nj0ys.fsf@alter.siamese.dyndns.org>
On Wed, Jan 23, 2013 at 5:52 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 40 quoted lines
> Lars Hjemli <hjemli@gmail.com> writes:
>
>> +static int walk(struct strbuf *path, int argc, const char **argv)
>> +{
>> +     DIR *dir;
>> +     struct dirent *ent;
>> +     struct stat st;
>> +     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")) {
>> +                     strbuf_addstr(path, ent->d_name);
>> +                     setenv(GIT_DIR_ENVIRONMENT, path->buf, 1);
>> +                     strbuf_setlen(path, len - 1);
>> +                     setenv(GIT_WORK_TREE_ENVIRONMENT, path->buf, 1);
>> +                     handle_repo(path->buf, argv);
>> +                     strbuf_addstr(path, "/");
>> +                     continue;
>> +             }
>> +             strbuf_setlen(path, len);
>> +             strbuf_addstr(path, ent->d_name);
>> +             switch (DTYPE(ent)) {
>> +             case DT_UNKNOWN:
>> +                     /* Use stat() instead of lstat(), since we want to
>> +                      * know if we can follow this path into another
>> +                      * directory - it's  not important if it's actually
>> +                      * a symlink which gets us there.
>> +                      */
>
> This is wrong if you are on a platform that does have d_type, no?
> It may say it is a symbolic link, and until you stat you wouldn't
> know if it may lead to a directory.  You can add "case DT_LNK:" that
> behaves the same as DT_UNKNOWN, I think.
Yeah, that seems right, thanks.
-- 
larsh
Previous: Lars Hjemli
Message 9 of 9 in “all: new command used for multi-repo operations”
  1. all: new command used for multi-repo operationsLars Hjemli, Jan 23, 2013
  2. Duy NguyenJan 23, 2013
  3. Lars HjemliJan 23, 2013
  4. Duy NguyenJan 23, 2013
  5. Jens LehmannJan 23, 2013
  6. Junio C HamanoJan 23, 2013
  7. Junio C HamanoJan 23, 2013
  8. Lars HjemliJan 23, 2013
  9. Lars HjemliJan 23, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.