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

Re: [Question] How to force relative path output when using `git status --porcelain=2 -z`

From
叶叶志晟 <yzs981130@gmail.com>
Date
Nov 6, 2024, 05:07 UTC
Message-ID
<CAH1CY-kD1MhuuVW8UqkJeiFZkgv2zDBXb1u6q3DLNbUs4R6zXg@mail.gmail.com>
In-Reply-To
<xmqqses5qis5.fsf@gitster.g>
Hi Junio,
Thank you for the quick response! That is exactly what I have encountered.

I understand that it is highly probable that the result of `git status --porcelain=2` is unexpected, and it may not be fixed due to consistency.

Thanks a lot!
Junio C Hamano <gitster@pobox.com> 于2024年11月6日周三 08:59写道:
Show 40 quoted lines
>
> 叶志晟 <yzs981130@gmail.com> writes:
>
> > I am experiencing a problem when parsing the results of `git status`.
> > My primary goal is to parse the output of `git status`
> > programmatically, so I am trying to parse the result of `git status
> > --porcelain=2 -z`.
>
> Interesting finding.  Here is what I tried in my working tree, where
> I have a few cruft files left at the top, and ran these commands
> inside the 't/' subdirectory:
>
>     $ git status --porcelain=1
>     ?? +ps8-v2-reftable-iterator-reuse
>     ?? :runme.sh
>     : git t/master; git status --porcelain=2
>     ? ../+ps8-v2-reftable-iterator-reuse
>     ? ../:runme.sh
>     : git t/master; git status --porcelain=1 -z | tr '\0' '\n'
>     ?? +ps8-v2-reftable-iterator-reuse
>     ?? :runme.sh
>     : git t/master; git status --porcelain=2 -z | tr '\0' '\n'
>     ? +ps8-v2-reftable-iterator-reuse
>     ? :runme.sh
>
> I haven't dug into the history to see if these inconsistencies in
> behaviour are deliberate, but I somehow suspect that the output from
> "--porcelain=2" without "-z" is mistaken.  As the porcelain output
> is designed to be machine parseable with or without "-z" (and the
> reader of the output, the implementation of a Porcelain command, is
> responsible for turning it into relative if it prefers), it would be
> a mistake to turn relative output on based on the lack of "-z".
>
> Not that we can "fix" the output from "--porcelain=2" at this point.
> To changge them to uniformly show absolute (or relative for that
> matter), we'd need "--porcelain=3" to preserve these inconsistency
> output because it is very certain that existing users and scripts
> already rely on it.
>
> Thanks.
-- 
志晟 叶
yezhisheng.com.cn
Previous: Junio C Hamano
Message 3 of 3 in “[Question] How to force relative path output when using `git status --porcelain=2 -z`”
  1. 叶志晟Nov 5, 2024
  2. Junio C HamanoNov 6, 2024
  3. 叶志晟Nov 6, 2024

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.