Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH v9 1/9] Add column layout skeleton and git-column

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:36

Possibly related (same subject, not in this thread)

Nguyễn Thái Ngọc Duy  [off-list ref] writes:
+static int column_config(const char *var, const char *value,
+			 const char *key, unsigned int *colopts)
+{
+	if (parse_config(colopts, value))
+		return error("invalid %s mode %s", key, value);
+	return 0;
+}
+
+int git_column_config(const char *var, const char *value,
+		      const char *command, unsigned int *colopts)
+{
+	if (!strcmp(var, "column.ui"))
+		return column_config(var, value, "column.ui", colopts);
I do not think there is anything that reads column.ui from a configuration
file (or "git -c column.ui") in this step, but later patches seem to use
it from their configuration callback (e.g. git_branch_config()) and at
that point you will segfault because you ignore the case where value is
NULL.
+	if (command) {
+		struct strbuf sb = STRBUF_INIT;
+		int ret = 0;
+		strbuf_addf(&sb, "column.%s", command);
+		if (!strcmp(var, sb.buf))
+			ret = column_config(var, value, sb.buf, colopts);
+		strbuf_release(&sb);
+		return ret;
+	}
This whole thing looks overly wasteful.  How about doing it this way?

	const char *it = skip_prefix(var, "column.");
        if (!it)
		return 0;
	if (!strcmp(it, "ui"))
		parse "ui";
	else if (!strcmp(it, command))
		parse "command";

and make the third parameter to column_config() be without the constant
prefix "column."?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help