Re: [PATCH 5/7] worktree: `list` escape lock reason in --porcelain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 5, 2021 at 5:29 AM Phillip Wood <phillip.wood123@xxxxxxxxx> wrote:
> On 04/01/2021 16:21, Rafael Silva wrote:
> > In case the lock reason contains newline characters (i.e: LF or CRLF)
> > this will cause the format to break as each line should correspond to
> > one attribute. This leads to unwanted behavior, specially as the
> > porcelain is intended to be machine-readable. To address this shortcoming
> > let's teach "git worktree list" to escape any newline character before
> > outputting the locked reason for porcelain format.
>
> As the porcelain output format cannot handle worktree paths that contain
> newlines either I think it would be better to add a `-z` flag which uses
> NUL termination as we have for many other commands (diff, ls-files etc).
> This would fix the problem forever without having to worry about quoting
> each time a new field is added.

Adding a `-z` flag makes sense, but that doesn't mean the existing
`--porcelain` is meaningless without it. I see `-z` as a good
complement to `--porcelain`.

Yes, we should fix the problem that the existing porcelain output
doesn't escape the path, but that can be done as a separate bug fix;
it doesn't need to be rolled into this series.

> If you really need to quote the lock reason then please use one of the
> path quoting routines (probably quote_c_style() or write_name_quoted())
> in quote.c rather than rolling your own - the code below gives the same
> output for a string that contains the two characters `\` followed by `n`
> as it does for the single character `\n`. People are (hopefully) used to
> dequoting our path quoting and there are routines out there to do it (we
> have one git Git.pm) using a function in quote.c will allow them to use
> those routines here.

I was going to suggest the same. Thanks.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux