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

Re: [PATCH] git-status: Show empty directories

From
Leila <muhtasib@gmail.com>
Date
Jun 9, 2012, 21:08 UTC
Message-ID
<CAA3EhHJ9WnisF21iFfsjQKYFSY0t0jFvNV3aBjx0eGFPm8aoGg@mail.gmail.com>
In-Reply-To
<20120609221315.Horde.fN5FP3wdC4BP065b3FviijA@webmail.minatec.grenoble-inp.fr>
On Sat, Jun 9, 2012 at 4:13 PM,  <konglu@minatec.inpg.fr> wrote:
Show 15 quoted lines
>
> Leila Muhtasib <muhtasib@gmail.com> a écrit :
>
>
>>  wt-status.c |   24 +++++++++++++++++++-----
>>  1 files changed, 19 insertions(+), 5 deletions(-)
>
>
> Do not forget to also update the test that need 'git
> status'. For example, most of the tests in t7508 are
> broken with your patch (the change is not huge, just
> adding "and directories" at the end of "untracked files:"
> here and there and maybe some other minor details).
> Otherwise, the idea seems good to me :).
>
Thanks! I didn't update the tests. I will do so now.
Show 31 quoted lines
>
>>        for (i = 0; i < dir.nr; i++) {
>>                struct dir_entry *ent = dir.entries[i];
>>                if (cache_name_is_other(ent->name, ent->len) &&
>> -                   match_pathspec(s->pathspec, ent->name, ent->len, 0,
>> NULL))
>> -                       string_list_insert(&s->untracked, ent->name);
>> +                   match_pathspec(s->pathspec, ent->name, ent->len, 0,
>> NULL)) {
>> +                       if (is_empty_dir(ent->name)) {
>> +                               struct strbuf buf_name = STRBUF_INIT;
>> +                               strbuf_addstr(&buf_name, ent->name);
>> +                               strbuf_addstr(&buf_name, " (empty
>> directories cannot be added)");
>> +                               string_list_insert(&s->untracked,
>> buf_name.buf);
>> +                               strbuf_release(&buf_name);
>> +                       }
>> +                       else
>> +                               string_list_insert(&s->untracked,
>> ent->name);
>
>
> The structure is
>      if (...) {
>             /*code*/
>      } else {
>             /*code*/
>      }
>
> Do not forget braces in the "else" part as the firt block needs it.

I was under the impression that one liners didn't require parenthesis according to the style guidelines. I didn't realize that if the 'if' required it, then the else required it. I will make that change and remember it for the future. Thanks!

Show 5 quoted lines
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: konglu@minatec.inpg.frNext: Thomas Rast
Message 3 of 17 in “git-status: Show empty directories”
  1. git-status: Show empty directoriesLeila Muhtasib, Jun 9, 2012
  2. konglu@minatec.inpg.frJun 9, 2012
  3. LeilaJun 9, 2012
  4. Thomas RastJun 9, 2012
  5. LeilaJun 9, 2012
  6. konglu@minatec.inpg.frJun 9, 2012
  7. Thomas RastJun 10, 2012
  8. konglu@minatec.inpg.frJun 10, 2012
  9. LeilaJun 10, 2012
  10. Junio C HamanoJun 11, 2012
  11. Junio C HamanoJun 10, 2012
  12. LeilaJun 10, 2012
  13. konglu@minatec.inpg.frJun 10, 2012
  14. LeilaJun 10, 2012
  15. Junio C HamanoJun 11, 2012
  16. LeilaJun 11, 2012
  17. LeilaJun 11, 2012

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.