diff options
author | Lukas Fleischer <cgit@cryptocrack.de> | 2013-11-22 21:24:52 (JST) |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2014-01-08 22:59:38 (JST) |
commit | 9973ef0207d21535a05610ca50d9f45c7c56c758 (patch) | |
tree | b6049b899f23d7447ee39077f80e2dd2f86d3d2b /ui-log.c | |
parent | e21da6c2a6ffcd8b4a2b2b06cf7486f36f291a5b (diff) | |
download | cgit-9973ef0207d21535a05610ca50d9f45c7c56c758.zip cgit-9973ef0207d21535a05610ca50d9f45c7c56c758.tar.gz |
Use argv_array in place of vector
Instead of using our own vector implementation, use argv_array from Git
which has been specifically designed for dynamic size argv arrays.
Drop vector.h and vector.c which are no longer needed.
Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'ui-log.c')
-rw-r--r-- | ui-log.c | 34 |
1 files changed, 15 insertions, 19 deletions
@@ -10,7 +10,7 @@ | |||
10 | #include "ui-log.h" | 10 | #include "ui-log.h" |
11 | #include "html.h" | 11 | #include "html.h" |
12 | #include "ui-shared.h" | 12 | #include "ui-shared.h" |
13 | #include "vector.h" | 13 | #include "argv-array.h" |
14 | 14 | ||
15 | int files, add_lines, rem_lines; | 15 | int files, add_lines, rem_lines; |
16 | 16 | ||
@@ -288,25 +288,25 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
288 | { | 288 | { |
289 | struct rev_info rev; | 289 | struct rev_info rev; |
290 | struct commit *commit; | 290 | struct commit *commit; |
291 | struct vector vec = VECTOR_INIT(char *); | 291 | struct argv_array rev_argv = ARGV_ARRAY_INIT; |
292 | int i, columns = commit_graph ? 4 : 3; | 292 | int i, columns = commit_graph ? 4 : 3; |
293 | int must_free_tip = 0; | 293 | int must_free_tip = 0; |
294 | struct strbuf argbuf = STRBUF_INIT; | 294 | struct strbuf argbuf = STRBUF_INIT; |
295 | 295 | ||
296 | /* First argv is NULL */ | 296 | /* rev_argv.argv[0] will be ignored by setup_revisions */ |
297 | vector_push(&vec, NULL, 0); | 297 | argv_array_push(&rev_argv, "log_rev_setup"); |
298 | 298 | ||
299 | if (!tip) | 299 | if (!tip) |
300 | tip = ctx.qry.head; | 300 | tip = ctx.qry.head; |
301 | tip = disambiguate_ref(tip, &must_free_tip); | 301 | tip = disambiguate_ref(tip, &must_free_tip); |
302 | vector_push(&vec, &tip, 0); | 302 | argv_array_push(&rev_argv, tip); |
303 | 303 | ||
304 | if (grep && pattern && *pattern) { | 304 | if (grep && pattern && *pattern) { |
305 | pattern = xstrdup(pattern); | 305 | pattern = xstrdup(pattern); |
306 | if (!strcmp(grep, "grep") || !strcmp(grep, "author") || | 306 | if (!strcmp(grep, "grep") || !strcmp(grep, "author") || |
307 | !strcmp(grep, "committer")) { | 307 | !strcmp(grep, "committer")) { |
308 | strbuf_addf(&argbuf, "--%s=%s", grep, pattern); | 308 | strbuf_addf(&argbuf, "--%s=%s", grep, pattern); |
309 | vector_push(&vec, &argbuf.buf, 0); | 309 | argv_array_push(&rev_argv, argbuf.buf); |
310 | } | 310 | } |
311 | if (!strcmp(grep, "range")) { | 311 | if (!strcmp(grep, "range")) { |
312 | char *arg; | 312 | char *arg; |
@@ -315,50 +315,46 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern | |||
315 | * rev-list options. Also, replace the previously | 315 | * rev-list options. Also, replace the previously |
316 | * pushed tip (it's no longer relevant). | 316 | * pushed tip (it's no longer relevant). |
317 | */ | 317 | */ |
318 | vec.count--; | 318 | argv_array_pop(&rev_argv); |
319 | while ((arg = next_token(&pattern))) { | 319 | while ((arg = next_token(&pattern))) { |
320 | if (*arg == '-') { | 320 | if (*arg == '-') { |
321 | fprintf(stderr, "Bad range expr: %s\n", | 321 | fprintf(stderr, "Bad range expr: %s\n", |
322 | arg); | 322 | arg); |
323 | break; | 323 | break; |
324 | } | 324 | } |
325 | vector_push(&vec, &arg, 0); | 325 | argv_array_push(&rev_argv, arg); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | } | 328 | } |
329 | if (commit_graph) { | 329 | if (commit_graph) { |
330 | static const char *graph_arg = "--graph"; | 330 | static const char *graph_arg = "--graph"; |
331 | static const char *color_arg = "--color"; | 331 | static const char *color_arg = "--color"; |
332 | vector_push(&vec, &graph_arg, 0); | 332 | argv_array_push(&rev_argv, graph_arg); |
333 | vector_push(&vec, &color_arg, 0); | 333 | argv_array_push(&rev_argv, color_arg); |
334 | graph_set_column_colors(column_colors_html, | 334 | graph_set_column_colors(column_colors_html, |
335 | COLUMN_COLORS_HTML_MAX); | 335 | COLUMN_COLORS_HTML_MAX); |
336 | } | 336 | } |
337 | 337 | ||
338 | if (commit_sort == 1) { | 338 | if (commit_sort == 1) { |
339 | static const char *date_order_arg = "--date-order"; | 339 | static const char *date_order_arg = "--date-order"; |
340 | vector_push(&vec, &date_order_arg, 0); | 340 | argv_array_push(&rev_argv, date_order_arg); |
341 | } else if (commit_sort == 2) { | 341 | } else if (commit_sort == 2) { |
342 | static const char *topo_order_arg = "--topo-order"; | 342 | static const char *topo_order_arg = "--topo-order"; |
343 | vector_push(&vec, &topo_order_arg, 0); | 343 | argv_array_push(&rev_argv, topo_order_arg); |
344 | } | 344 | } |
345 | 345 | ||
346 | if (path) { | 346 | if (path) { |
347 | static const char *double_dash_arg = "--"; | 347 | static const char *double_dash_arg = "--"; |
348 | vector_push(&vec, &double_dash_arg, 0); | 348 | argv_array_push(&rev_argv, double_dash_arg); |
349 | vector_push(&vec, &path, 0); | 349 | argv_array_push(&rev_argv, path); |
350 | } | 350 | } |
351 | 351 | ||
352 | /* Make sure the vector is NULL-terminated */ | ||
353 | vector_push(&vec, NULL, 0); | ||
354 | vec.count--; | ||
355 | |||
356 | init_revisions(&rev, NULL); | 352 | init_revisions(&rev, NULL); |
357 | rev.abbrev = DEFAULT_ABBREV; | 353 | rev.abbrev = DEFAULT_ABBREV; |
358 | rev.commit_format = CMIT_FMT_DEFAULT; | 354 | rev.commit_format = CMIT_FMT_DEFAULT; |
359 | rev.verbose_header = 1; | 355 | rev.verbose_header = 1; |
360 | rev.show_root_diff = 0; | 356 | rev.show_root_diff = 0; |
361 | setup_revisions(vec.count, vec.data, &rev, NULL); | 357 | setup_revisions(rev_argv.argc, rev_argv.argv, &rev, NULL); |
362 | load_ref_decorations(DECORATE_FULL_REFS); | 358 | load_ref_decorations(DECORATE_FULL_REFS); |
363 | rev.show_decorations = 1; | 359 | rev.show_decorations = 1; |
364 | rev.grep_filter.regflags |= REG_ICASE; | 360 | rev.grep_filter.regflags |= REG_ICASE; |