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

Re: [PATCH 2/2] checkout-index: omit entries with no tempname from --temp output

From
Matheus Tavares Bernardino <matheus.bernardino@usp.br>
Date
Feb 9, 2021, 21:57 UTC
Message-ID
<CAHd-oW4ddei-bRZkQUSpMevyZYgOBi2T6uQPzJ_XscTmfxhWtw@mail.gmail.com>
In-Reply-To
<xmqqmtwczzyv.fsf@gitster.c.googlers.com>
On Tue, Feb 9, 2021 at 6:35 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 51 quoted lines
>
> Matheus Tavares <matheus.bernardino@usp.br> writes:
>
> >       if (CHECKOUT_ALL == checkout_stage) {
> > -             for (i = 1; i < 4; i++) {
> > -                     if (i > 1)
> > -                             putchar(' ');
> > -                     if (topath[i][0])
> > -                             fputs(topath[i], stdout);
> > -                     else
> > -                             putchar('.');
> > +             for (i = 1; i < 4; i++)
> > +                     if (topath[i][0]) {
> > +                             have_tempname = 1;
> > +                             break;
> > +                     }
> > +
> > +             if (have_tempname) {
> > +                     for (i = 1; i < 4; i++) {
> > +                             if (i > 1)
> > +                                     putchar(' ');
> > +                             if (topath[i][0])
> > +                                     fputs(topath[i], stdout);
> > +                             else
> > +                                     putchar('.');
> > +                     }
> >               }
> > -     } else
> > +     } else if (topath[checkout_stage][0]) {
> > +             have_tempname = 1;
> >               fputs(topath[checkout_stage], stdout);
> > +     }
> >
> > -     putchar('\t');
> > -     write_name_quoted_relative(name, prefix, stdout,
> > -                                nul_term_line ? '\0' : '\n');
> > +     if (have_tempname) {
> > +             putchar('\t');
> > +             write_name_quoted_relative(name, prefix, stdout,
> > +                                        nul_term_line ? '\0' : '\n');
> >
> > -     for (i = 0; i < 4; i++) {
> > -             topath[i][0] = 0;
> > +             for (i = 0; i < 4; i++) {
> > +                     topath[i][0] = 0;
> > +             }
> >       }
>
> Hmph, is topath[][] array used after this function gets called and
> in what way?  Whether have_tempname is true or not, wouldn't we want
> to clear it?

Yeah, topath[][] can be reused in the next checkout_entry() call. But if have_tempname is false, the positions that are going to be used again (either checkout_stage or 1, 2, and 3, if checkout_stage == CHECKOUT_ALL) will be already empty. So I think we only need to clear topath[][] when have_tempname is false.

Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 15 in “checkout-index: some cleanups to --temp and --prefix outputs”
  1. 0/2 checkout-index: some cleanups to --temp and --prefix outputsMatheus Tavares, Feb 8, 2021
  2. 1/2 write_entry(): fix misuses of `path` in error messagesMatheus Tavares, Feb 8, 2021
  3. Junio C HamanoFeb 9, 2021
  4. Matheus Tavares BernardinoFeb 9, 2021
  5. 2/2 checkout-index: omit entries with no tempname from --temp outputMatheus Tavares, Feb 8, 2021
  6. Junio C HamanoFeb 9, 2021
  7. Matheus Tavares BernardinoFeb 9, 2021
  8. Junio C HamanoFeb 10, 2021
  9. 0/2 checkout-index: some cleanups to --temp and --prefix outputsMatheus Tavares, Feb 15, 2021
  10. 1/2 write_entry(): fix misuses of `path` in error messagesMatheus Tavares, Feb 15, 2021
  11. Junio C HamanoFeb 16, 2021
  12. 2/2 checkout-index: omit entries with no tempname from --temp outputMatheus Tavares, Feb 15, 2021
  13. 0/2 checkout-index: some cleanups to --temp and --prefix outputsMatheus Tavares, Feb 16, 2021
  14. 2/2 checkout-index: omit entries with no tempname from --temp outputMatheus Tavares, Feb 16, 2021
  15. 1/2 write_entry(): fix misuses of `path` in error messagesMatheus Tavares, Feb 16, 2021

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.