Thread (34 messages) flat view 34 messages, 5 authors, 2016-07-21

Re: [PATCH v1 1/6] Allow --porcelain[=<n>] in status and commit commands

From: Johannes Schindelin <hidden>
Date: 2016-07-21 14:29:41

Hi Jeff,

On Wed, 20 Jul 2016, Jeff Hostetler wrote:
On 07/20/2016 11:08 AM, Johannes Schindelin wrote:
quoted
On Tue, 19 Jul 2016, Jeff Hostetler wrote:
quoted
@@ -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".
Whoops, you're right. It is *I* who misread the code (I did not bother
looking for the docs ;-))

Still, I would prefer to avoid that callback. IOW something like

	{ OPTION_INTEGER, 0, "porcelain", &status_format,
	  N_("version"), N_("machine-readable output"),
	  PARSE_OPT_OPTARG, NULL, 1 },

followed by the if () outlined above.

Ciao,
Johannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help