Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH_v1] add 'git credential' plumbing command

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:54:01

roucherj [off-list ref] writes:
On Sat, 09 Jun 2012 21:52:36 +0200, konglu@minatec.inpg.fr wrote:
quoted
quoted
+void cmd_credential (int argc, char **argv, const char *prefix){
+	const char *op;
+	struct credential c = CREDENTIAL_INIT;
+	int i;
+
+	op = argv[1];
+	if (!op)
+		usage(usage_msg);
+
+	for (i = 2; i < argc; i++)
+		string_list_append(&c.helpers, argv[i]);
+
+	if (credential_read(&c, stdin) < 0)
+		die("unable to read credential from stdin");
+
+	if (!strcmp(op, "fill")) {
+		credential_fill(&c);
+		if (c.username)
+			printf("username=%s\n", c.username);
+		if (c.password)
+			printf("password=%s\n", c.password);
+	}
+	else if (!strcmp(op, "approve")) {
+		credential_approve(&c);
+	}
+	else if (!strcmp(op, "reject")) {
+		credential_reject(&c);
+	}
+	else
+		usage(usage_msg);
Braces for the last "else" part. In general, the structure should be

      if (...) {
               /*code*/
      } else if (...) {
               /*code*/
      } else {
               /*code*/
      }

If juste one block needs brances, all the other "else if"/"else" part
need it too.

BTW, please be aware of the white spaces (here mostly in the doc) :).

Lucien Kong.
I will remove brances.
The remark was about adding them, not removing them. There's one branch
of the if/else if/ with several instructions, so we usually put braces
everywhere.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help