+ struct vector vec = VECTOR_INIT(char *);
+ int i, columns = 3;
+ char *arg;
+
+ /* First argv is NULL */
+ vector_push(&vec, NULL, 0);
+
+ if (!tip)
+ tip = ctx.qry.head;
+ tip = disambiguate_ref(tip);
+ vector_push(&vec, &tip, 0);
+
+ if (grep && pattern && *pattern) {
+ pattern = xstrdup(pattern);
+ if (!strcmp(grep, "grep") || !strcmp(grep, "author") ||
+ !strcmp(grep, "committer")) {
+ arg = fmt("--%s=%s", grep, pattern);
+ vector_push(&vec, &arg, 0);
+ }
+ if (!strcmp(grep, "range")) {
+ /* Split the pattern at whitespace and add each token
+ * as a revision expression. Do not accept other
+ * rev-list options. Also, replace the previously
+ * pushed tip (it's no longer relevant).
+ */
+ vec.count--;
+ while ((arg = next_token(&pattern))) {
+ if (*arg == '-') {
+ fprintf(stderr, "Bad range expr: %s\n",
+ arg);
+ break;
+ }
+ vector_push(&vec, &arg, 0);
+ }
+ }
+ }
+ if (commit_graph) {
+ static const char *graph_arg = "--graph";
+ static const char *color_arg = "--color";
+ vector_push(&vec, &graph_arg, 0);
+ vector_push(&vec, &color_arg, 0);
+ graph_set_column_colors(column_colors_html,
+ COLUMN_COLORS_HTML_MAX);
+ }
+
+ if (commit_sort == 1) {
+ static const char *date_order_arg = "--date-order";
+ vector_push(&vec, &date_order_arg, 0);
+ } else if (commit_sort == 2) {
+ static const char *topo_order_arg = "--topo-order";
+ vector_push(&vec, &topo_order_arg, 0);
+ }
+
+ if (path) {
+ arg = "--";
+ vector_push(&vec, &arg, 0);
+ vector_push(&vec, &path, 0);
+ }
+
+ /* Make sure the vector is NULL-terminated */
+ vector_push(&vec, NULL, 0);
+ vec.count--;