From: Jeff Hostetler <git@jeffhostetler.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Jeff Hostetler <jeffhost@microsoft.com>
Cc: git@vger.kernel.org, peff@peff.net, gitster@pobox.com
Subject: Re: [PATCH v1 1/6] Allow --porcelain[=<n>] in status and commit commands
Date: Wed, 20 Jul 2016 11:38:16 -0400 [thread overview]
Message-ID: <578F9AE8.4000407@jeffhostetler.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1607201600050.14111@virtualbox>
On 07/20/2016 11:08 AM, Johannes Schindelin wrote:
> On Tue, 19 Jul 2016, Jeff Hostetler wrote:
>> diff --git a/builtin/commit.c b/builtin/commit.c
>> + } else if (arg) {
>> + int n = strtol(arg, NULL, 10);
>> + if (n == 1)
>> + *value = STATUS_FORMAT_PORCELAIN;
>> + else
>> + die("unsupported porcelain version");
>> + } else {
>> + *value = STATUS_FORMAT_PORCELAIN;
>
> This could be folded into the previous conditional:
>
> }
> else {
> int n = arg ? strtol(arg, NULL, 10) : 1;
> ...
>
I did it this way because I didn't want to make any assumptions
here on the numeric value of the enum values. Or rather, I didn't
want to add specific assignments to the enum type.
This also helps make it easier to see my later commit:
else if (n == 2) *value = STATUS_FORMAT_PORCELAIN_V2;
Also, I didn't want to alter the order of assignments to the global
status_format variable. That is, if I capture the value of <n> in
a porcelain_version variable and assign that to status_format
afterwards, there is opportunity for mistakes if they type:
git status --short --porcelain=1 --long
where the status_format variable is assigned 3 times.
> Having said this, ...
>
>> @@ -1336,9 +1347,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
>> N_("show status concisely"), STATUS_FORMAT_SHORT),
>> OPT_BOOL('b', "branch", &s.show_branch,
>> N_("show branch information")),
>> - OPT_SET_INT(0, "porcelain", &status_format,
>> - N_("machine-readable output"),
>> - STATUS_FORMAT_PORCELAIN),
>> + { OPTION_CALLBACK, 0, "porcelain", &status_format,
>> + N_("version"), N_("machine-readable output"),
>> + PARSE_OPT_OPTARG, opt_parse_porcelain },
>
> How about using a COUNTUP here instead? We could then set the status
> format afterwards, like this:
>
> if (porcelain == 0)
> status_format = STATUS_FORMAT_UNSPECIFIED;
> else {
> status_format = STATUS_FORMAT_PORCELAIN;
> if (porcelain > 1)
> warning("No porcelain v%d; falling back to v1",
> porcelain);
> }
>
Maybe I misread the COUNTUP docs, but it looked like it would
allow "--porcelain --porcelain", but not "--porcelain=2".
Jeff
next prev parent reply other threads:[~2016-07-20 15:40 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-19 22:10 [PATCH v1 0/6] Porcelain Status V2 Jeff Hostetler
2016-07-19 22:10 ` [PATCH v1 1/6] Allow --porcelain[=<n>] in status and commit commands Jeff Hostetler
2016-07-20 15:08 ` Johannes Schindelin
2016-07-20 15:38 ` Jeff Hostetler [this message]
2016-07-21 14:28 ` Johannes Schindelin
2016-07-20 15:58 ` Jeff King
2016-07-20 17:26 ` Jeff Hostetler
2016-07-20 20:46 ` Junio C Hamano
2016-07-19 22:10 ` [PATCH v1 2/6] Status and checkout unit tests for --porcelain[=<n>] Jeff Hostetler
2016-07-20 15:19 ` Johannes Schindelin
2016-07-20 15:51 ` Jeff Hostetler
2016-07-20 16:00 ` Jeff King
2016-07-20 16:03 ` Jeff King
2016-07-20 17:31 ` Jeff Hostetler
2016-07-20 17:29 ` Jeff Hostetler
2016-07-19 22:10 ` [PATCH v1 3/6] Per-file output for Porcelain Status V2 Jeff Hostetler
2016-07-20 20:50 ` Junio C Hamano
2016-07-21 14:19 ` Johannes Schindelin
2016-07-20 21:31 ` Junio C Hamano
2016-07-21 18:58 ` Jeff Hostetler
2016-07-22 17:01 ` Junio C Hamano
2016-07-19 22:10 ` [PATCH v1 4/6] Expanded branch header " Jeff Hostetler
2016-07-20 16:06 ` Jeff King
2016-07-20 18:20 ` Jeff Hostetler
2016-07-20 20:54 ` Jeff King
2016-07-21 15:46 ` Johannes Schindelin
2016-07-21 19:03 ` Jeff Hostetler
2016-07-19 22:10 ` [PATCH v1 5/6] Add porcelain V2 documentation to status manpage Jeff Hostetler
2016-07-20 15:29 ` Jakub Narębski
2016-07-20 15:42 ` Jeff Hostetler
2016-07-20 15:55 ` Jakub Narębski
2016-07-20 21:50 ` Junio C Hamano
2016-07-19 22:10 ` [PATCH v1 6/6] Unit tests for V2 porcelain status Jeff Hostetler
2016-07-20 15:30 ` Jakub Narębski
2016-07-20 15:47 ` Jeff Hostetler
2016-07-20 16:01 ` Jakub Narębski
2016-07-21 15:54 ` Johannes Schindelin
2016-07-20 16:15 ` [PATCH v1 0/6] Porcelain Status V2 Jeff King
2016-07-20 19:27 ` Jeff Hostetler
2016-07-20 20:57 ` Jeff King
2016-07-21 16:02 ` Johannes Schindelin
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=578F9AE8.4000407@jeffhostetler.com \
--to=git@jeffhostetler.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jeffhost@microsoft.com \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).