Re: "Git worktree list" on paths with newlines
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 25, 2022, 17:11 UTC
- Message-ID
- <xmqqilt2g9cb.fsf@gitster.g>
- In-Reply-To
- <CADDzAfNTuuAWn1ynswTayRqgNNcPn3ou=v6c+z_tRsu5uoqJZA@mail.gmail.com>
Kang-Che Sung <explorer09@gmail.com> writes:
Show 6 quoted lines
> 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.