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

Document git status -b --porcelain

From
Ondra Medek <xmedeko@gmail.com>
Date
Nov 14, 2023, 09:14 UTC
Message-ID
<CAJsoDaFNxEEBuXK1o16NE-JzLeckpWbqxY_vhgqGF7MS-A85jg@mail.gmail.com>
Hi,

I am using "git status -b --porcelain" and parsing output in a code. However, the output is not documented for an empty repository or a missing remote branch. (And maybe a detached head, too).

Doc for Porcelain Format Version 1
https://git-scm.com/docs/git-status#_porcelain_format_version_1
references doc for Short Format
https://git-scm.com/docs/git-status#_short_format
and it says:
> If -b is used the short-format status is preceded by a line
>   ## branchname tracking info

However, when I have a fresh clone or an empty repository, "git status -b --porcelain" results in:

## No commits yet on master...origin/master [gone]

So, it seems to me the format is something like "# [info1 ]branchname...tracking[ info2]" and it should be documented what infos may appear and when. Otherwise it's hard to write robust parsing of such output.

Thanks Ondra Medek

Message 1 of 1 in “Document git status -b --porcelain”
  1. Ondra MedekNov 14, 2023

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.