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

Re: [PATCH v5 3/4] status: give more information during rebase -i

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jul 2, 2015, 08:01 UTC
Message-ID
<vpqh9pnm1hu.fsf@anie.imag.fr>
In-Reply-To
<xmqqr3or7et9.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 12 quoted lines
> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
>> Actually, we can do simpler: we still have the original line available,
>> ...
>>
>> I took this (modulo s/line.len[0]/line.buf[0]/, and s/rtrim/trim/ to be
>> robust to leading whitespace (not really important, but doesn't harm).
>
> I'd prefer us to be more strict when we know we are reading our own
> output; rtrim is sensible, as the log line has end-user subject
> the end and the subject might have a trailing whitespace we want to
> trim, but there is no valid reason to expect leading whitespace.

I would agree with "more strict" is it was about rejecting the input (to catch errors), but here we're still accepting it without complaining if it has leading whitespaces. So, being strict does not seem to have any benefit to me. Being a bit more robust is just one character _less_ in the code.

Actually, there's a hidden benefit in accepting not-well-formatted input: it mimicks the shell equivalent closer, which means that we're close to replacing the shell's collapse_todo_ids and expand_todo_ids in C which would avoid C/shell duplication.

Show 17 quoted lines
> --- a/wt-status.c
> +++ b/wt-status.c
> @@ -1046,12 +1046,8 @@ static void abbrev_sha1_in_line(struct strbuf *line)
>                 unsigned char sha1[20];
>                 const char *abbrev;
>  
> -               /*
> -                * strbuf_split_max left a space. Trim it and re-add
> -                * it after abbreviation.
> -                */
> -               strbuf_trim(split[1]);
> -               if (!get_sha1(split[1]->buf, sha1)) {
> +               if (!get_sha1_hex(split[1]->buf, sha1) &&
> +                   !strcmp(split[1]->buf + 40, " ")) {
>                         abbrev = find_unique_abbrev(sha1, DEFAULT_ABBREV);
>                         strbuf_reset(split[1]);
>                         strbuf_addf(split[1], "%s ", abbrev);

I prefer my version. It's simpler: when we can't expand, keep the original "line", don't try to deconstruct/reconstruct it, it's unmodified by construction. And my version works if the line is just "pick <sha1>\n", while yours doesn't.

About get_sha1_hex Vs get_sha1, the same argument as above applies: accepting short sha1s here means that implementing expand_todo_ids based on the function would be relatively easy.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Junio C HamanoNext: Junio C Hamano
Message 23 of 26 in “More helpful 'git status' during 'rebase -i'”
  1. 0/4 More helpful 'git status' during 'rebase -i'Matthieu Moy, Jun 30, 2015
  2. 1/4 status: factor two rebase-related messages togetherMatthieu Moy, Jun 30, 2015
  3. 2/4 status: differentiate interactive from non-interactive rebasesMatthieu Moy, Jun 30, 2015
  4. 3/4 status: give more information during rebase -iMatthieu Moy, Jun 30, 2015
  5. 4/4 status: add new tests for status during rebase -iMatthieu Moy, Jun 30, 2015
  6. Junio C HamanoJun 30, 2015
  7. Matthieu MoyJul 1, 2015
  8. 1/4 status: factor two rebase-related messages togetherMatthieu Moy, Jul 1, 2015
  9. 2/4 status: differentiate interactive from non-interactive rebasesMatthieu Moy, Jul 1, 2015
  10. 3/4 status: give more information during rebase -iMatthieu Moy, Jul 1, 2015
  11. Junio C HamanoJul 1, 2015
  12. Eric SunshineJul 1, 2015
  13. Junio C HamanoJul 1, 2015
  14. Eric SunshineJul 1, 2015
  15. Matthieu MoyJul 1, 2015
  16. 1/4 status: factor two rebase-related messages togetherMatthieu Moy, Jul 1, 2015
  17. 2/4 status: differentiate interactive from non-interactive rebasesMatthieu Moy, Jul 1, 2015
  18. 3/4 status: give more information during rebase -iMatthieu Moy, Jul 1, 2015
  19. Junio C HamanoJul 7, 2015
  20. Matthieu MoyJul 8, 2015
  21. 4/4 status: add new tests for status during rebase -iMatthieu Moy, Jul 1, 2015
  22. Junio C HamanoJul 1, 2015
  23. Matthieu MoyJul 2, 2015
  24. Junio C HamanoJul 3, 2015
  25. Matthieu MoyJul 2, 2015
  26. 4/4 status: add new tests for status during rebase -iMatthieu Moy, Jul 1, 2015

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.