Re: "Git worktree list" on paths with newlines

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

 



On Fri, Feb 25, 2022 at 3:47 PM Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Kang-Che Sung <explorer09@xxxxxxxxx> writes:
> > I wish "git worktree list --porcelain" would show directory names with some
> > quoting or escaping so that tricky names can be handled easily for any program
> > that reads the porcelain output. But I didn't see any command line option that
> > enables quoting or escaping of file names.
> >
> > Does anyone have an idea on what I could do?
>
> I agree that an output mode that claims to be --porcelain should
> produce output that is machine-parseable without ambiguity.
>
> The usual practice is to use quote_c_style() for output without
> "-z", and with "-z", just use the NUL as the termination character,
> as you shouldn't be listing strings with embedded NUL.

A couple additional comments...

Phillip has just submitted a patch to add a `-z` mode to `git worktree
list --porcelain`. You can see it at [1].

Porcelain mode should indeed be quoting the path using
quote_c_style(); the fact that it doesn't is a bug which would be nice
to fix. This has been discussed previously[2], however, there may be
backward compatibility concerns[3].

[1]: https://lore.kernel.org/git/pull.1164.git.1645801727732.gitgitgadget@xxxxxxxxx/
[2]: https://lore.kernel.org/git/CAPig+cQq_RnanDQ3jHfNz_L58WyzmsUJBhtdrLxa=H0v_io+WA@xxxxxxxxxxxxxx/
[3]: https://lore.kernel.org/git/936f9b7c-6d54-00bc-f136-4cb4c2836eb6@xxxxxxxxx/



[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