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

Re: Path differences between git status & git status --porcelain

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 27, 2022, 00:47 UTC
Message-ID
<xmqqzglc5ih8.fsf@gitster.g>
In-Reply-To
<CAHCc5YXmegAV-sSpLLpY19rXhnxYEgM+RzZHJ=saG8nD5HsGKg@mail.gmail.com>
Tone Kastlunger <users.giulietta@gmail.com> writes:
Show 8 quoted lines
> "git status --porcelain"  output from the same location:
>
>     ....cutted stuff to keep things clean...
>        M src/api/db.py   <---- Notice the missing ".." in front of the
> (modified) file path.
>
> Is this intentional/expected behaviour; and if not, we were wondering
> if this is a known issue?

Yes, this is working as designed and any future versions of Git will not change it. Scripts can forever rely on the fact that it can get paths relative to the root of the working tree regardless of where in the working tree they start.

You can add this:
    [status]
	relativepaths=no

to your ~/.gitconfig and "git status" (without --porcelain option) will also show paths relative to the root of the working tree (i.e. without ugly ../ prefix).

We made --porcelain=v2 to get affected by the status.relativepaths configuration, which may probably have been a mistake, but that is also too late to fix now. It defaults to show paths relative to the directory the command happened to be run, and in order to get a reliable output, the calling script must override status.relativepaths configuration variable the end-user may have, e.g.

    git -c status.relativepaths=no status --porcelain=v2
Previous: Tone KastlungerNext: Tone Kastlunger
Message 2 of 3 in “Path differences between git status & git status --porcelain”
  1. Tone KastlungerMar 26, 2022
  2. Junio C HamanoMar 27, 2022
  3. Tone KastlungerMar 27, 2022

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.