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

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

From
叶叶志晟 <yzs981130@gmail.com>
Date
Nov 5, 2024, 16:59 UTC
Message-ID
<CAH1CY-=FtMTSisCmcz7ovciPomXYBogjNCmqO1mEjN9H6zEfgQ@mail.gmail.com>
Hi all,

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`.

According to the docs [here](https://git-scm.com/docs/git-status), the `-z` option only changes the entry terminations and implies the `--porcelain=v1` output format if no other format is given. However, the result shows that the path returned is a relative path to the repo root rather than the current directory when using `-z`. Simply using `git status --porcelain=2` returns the relative path to the current directory.

I am wondering how to force the path to be relative to the current directory (for easier cutting and pasting) rather than the repo root when using `git status --porcelain=2 -z`. I would really appreciate it if you could help me!

Regards, Zhisheng

Next: Junio C Hamano
Message 1 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.