From: Junio C Hamano <gitster@pobox•com>
To: 叶志晟 <yzs981130@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [Question] How to force relative path output when using `git status --porcelain=2 -z`
Date: Tue, 05 Nov 2024 16:59:22 -0800 [thread overview]
Message-ID: <xmqqses5qis5.fsf@gitster.g> (raw)
In-Reply-To: <CAH1CY-=FtMTSisCmcz7ovciPomXYBogjNCmqO1mEjN9H6zEfgQ@mail.gmail.com> ("叶志晟"'s message of "Wed, 6 Nov 2024 00:59:43 +0800")
叶志晟 <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.
next prev parent reply other threads:[~2024-11-06 0:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-05 16:59 [Question] How to force relative path output when using `git status --porcelain=2 -z` 叶志晟
2024-11-06 0:59 ` Junio C Hamano [this message]
2024-11-06 5:07 ` 叶志晟
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqses5qis5.fsf@gitster.g \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=yzs981130@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox