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

[PATCH 1/2] status: really ignore config with --porcelain

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jun 24, 2013, 12:45 UTC
Message-ID
<1372077912-18625-2-git-send-email-artagnon@gmail.com>
In-Reply-To
<1372077912-18625-1-git-send-email-artagnon@gmail.com>

1a22bd3 (Merge branch 'jg/status-config', 2013-06-23) introduced a serious regression in --porcelain by introducing the configuration variables status.short and status.branch. Contrary to its description, the output of

  $ git status --porcelain

now depends on the configuration variables status.short and status.branch. As a result, callers that expect parsable output to be returned are broken. For instance, in a repository with submodules with status.branch and status.short set,

  $ git status

always reports all submodules as containing modified content, even if they are clean.

One solution to the problem is to turn off s->show_branch in wt_porcelain_print() just like we turn off other s->* variables, but that would break callers of --porcelain --branch (in fact, there is such a caller in t/t7508-status.sh). Besides, we never said that --porcelain cannot be combined with other options. The larger problem is that the config parser and command-line option parser set the same variables, making it impossible to determine who set them.

The correct solution is therefore to skip the config parser completely when --porcelain is given. Unfortunately, to determine that --porcelain is given, we have to run the command-line option parser. Running the command-line option parser before the config parser is undesirable, as configuration variables would override options on the command-line. As a fair compromise, check that argv[1] is equal to the string "--porcelain" and skip the config parser in this case. It is a compromise, because we expect --porcelain to be specified as the first argument to status.

On a related note, the command-line parser is not very robust.
  $ git status --short --long
  $ git status --long --long
  $ git status --porcelain --long
  $ git status --long --porcelain
  $ git status --porcelain --short
  $ git status --short --porcelain

all return different outputs. This bug is left as an exercise for future contributors to fix.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 builtin/commit.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index b589ce0..896f002 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1193,7 +1193,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)
 
 	wt_status_prepare(&s);
 	gitmodules_config();
-	git_config(git_status_config, &s);
+
+	if (argc > 1 && !strcmp(argv[1], "--porcelain"))
+		; /* Do not read user configuration */
+	else
+		git_config(git_status_config, &s);
+
 	determine_whence(&s);
 	argc = parse_options(argc, argv, prefix,
 			     builtin_status_options,
-- 
1.8.3.1.550.gd96f26e.dirty
Previous: Ramkumar RamachandraNext: Matthieu Moy
Message 2 of 25 in “Fix serious regressions in latest master”
  1. 0/2 Fix serious regressions in latest masterRamkumar Ramachandra, Jun 24, 2013
  2. 1/2 status: really ignore config with --porcelainRamkumar Ramachandra, Jun 24, 2013
  3. Matthieu MoyJun 24, 2013
  4. Ramkumar RamachandraJun 24, 2013
  5. Matthieu MoyJun 24, 2013
  6. Junio C HamanoJun 24, 2013
  7. Matthieu MoyJun 24, 2013
  8. Junio C HamanoJun 24, 2013
  9. Matthieu MoyJun 24, 2013
  10. Junio C HamanoJun 24, 2013
  11. Ramkumar RamachandraJun 24, 2013
  12. Junio C HamanoJun 24, 2013
  13. Junio C HamanoJun 24, 2013
  14. Jeff KingJun 28, 2013
  15. Junio C HamanoJun 28, 2013
  16. Junio C HamanoJun 28, 2013
  17. Jeff KingJun 28, 2013
  18. Junio C HamanoJun 28, 2013
  19. Ramkumar RamachandraJun 24, 2013
  20. Junio C HamanoJun 24, 2013
  21. Matthieu MoyJun 24, 2013
  22. Ramkumar RamachandraJun 24, 2013
  23. 2/2 commit: make it work with status.shortRamkumar Ramachandra, Jun 24, 2013
  24. Junio C HamanoJun 24, 2013
  25. Ramkumar RamachandraJun 24, 2013

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.