All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/2] status: really ignore config with --porcelain
Date: Mon, 24 Jun 2013 18:15:11 +0530	[thread overview]
Message-ID: <1372077912-18625-2-git-send-email-artagnon@gmail.com> (raw)
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

  reply	other threads:[~2013-06-24 12:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24 12:45 [PATCH (!) 0/2] Fix serious regressions in latest master Ramkumar Ramachandra
2013-06-24 12:45 ` Ramkumar Ramachandra [this message]
2013-06-24 13:51   ` [PATCH 1/2] status: really ignore config with --porcelain Matthieu Moy
2013-06-24 14:05     ` Ramkumar Ramachandra
2013-06-24 14:51       ` Matthieu Moy
2013-06-24 16:35         ` Junio C Hamano
2013-06-24 16:50           ` Matthieu Moy
2013-06-24 17:16             ` Junio C Hamano
2013-06-24 17:21               ` Matthieu Moy
2013-06-24 18:16             ` Junio C Hamano
2013-06-24 19:30               ` Ramkumar Ramachandra
2013-06-24 22:24                 ` Junio C Hamano
2013-06-24 19:49               ` Junio C Hamano
2013-06-28  1:40               ` Jeff King
2013-06-28  3:59                 ` Junio C Hamano
2013-06-28 17:37                   ` Junio C Hamano
2013-06-28 19:31                     ` Jeff King
2013-06-28 20:15                       ` Junio C Hamano
2013-06-24 16:53           ` Ramkumar Ramachandra
2013-06-24 14:55     ` Junio C Hamano
2013-06-24 15:04       ` Matthieu Moy
2013-06-24 15:50       ` Ramkumar Ramachandra
2013-06-24 12:45 ` [PATCH 2/2] commit: make it work with status.short Ramkumar Ramachandra
2013-06-24 15:17   ` Junio C Hamano
2013-06-24 15:39     ` Ramkumar Ramachandra

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=1372077912-18625-2-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.