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

Re: Broken interactive rebase text after some UTF-8 characters

From
PWPhillip Wood <phillip.wood@talktalk.net>
Date
Jan 31, 2019, 20:40 UTC
Message-ID
<2cbb5818-643d-bafd-6721-91e0d291a5fd@talktalk.net>
In-Reply-To
<505c2e2e-c9bc-aa57-c498-2acced0b8afa@gmail.com>
Hi Alban
On 31/01/2019 17:43, Alban Gruin wrote:
> Hi Phillip and Michal,
> 
> I think I found the bug.
Good find! Which os are you on?
Show 20 quoted lines
> 
> If you look at .git/rebase-merge/git-rebase-todo.backup, which is
> created before the editor is opened, you can see that it does not have
> this problem.  In between, transform_todos() is called and causes the
> problem reported by Michal.
> 
> This seems to be caused by a single line, sequencer:4661 (on b5101f9297,
> "Fourth batch after 2.20", 2019-01-29)[1].  If you add just before a
> something like this:
> 
>      fwrite(item->arg, item->arg_len, sizeof(char), stdout);
> 
> You will see that the argument is properly written to stdout.  But if
> you write this:
> 
>      printf("%.*s\n", item->arg_len, item->arg);
> 
> You will have the same broken output as in the todo file.
> 
> Are we misusing C formats?

The C standard and POSIX both say that the * refers to the maximum number of bytes to print but it looks like it is being treated as the maximum number of characters on OpenIndiana.

Johannes - Perhaps we should change it to use fwrite() unless printf() gets fixed and we're sure no other operating systems are affected?

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html [2] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf page 309

Best Wishes
Phillip
Show 6 quoted lines
> [1] https://github.com/git/git/blob/master/sequencer.c#L4661
> 
> Cheers,
> Alban
> 
> 
Previous: Alban GruinNext: Alban Gruin
Message 6 of 16 in “Broken interactive rebase text after some UTF-8 characters”
  1. Michal NowakJan 15, 2019
  2. Phillip WoodJan 16, 2019
  3. Michal NowakJan 16, 2019
  4. Phillip WoodJan 17, 2019
  5. Alban GruinJan 31, 2019
  6. Phillip WoodJan 31, 2019
  7. Alban GruinJan 31, 2019
  8. Junio C HamanoJan 31, 2019
  9. Johannes SchindelinFeb 1, 2019
  10. Michal NowakFeb 1, 2019
  11. Johannes SchindelinFeb 1, 2019
  12. Michal NowakFeb 1, 2019
  13. Junio C HamanoFeb 1, 2019
  14. Michal NowakFeb 1, 2019
  15. Alban GruinFeb 1, 2019
  16. Alban GruinFeb 1, 2019

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.