The twelfth batch
[git/gitster.git] / builtin / annotate.c
blob7f754f2309b66222db7ebf6f7605119d1e39122e
1 /*
2 * "git annotate" builtin alias
4 * Copyright (C) 2006 Ryan Anderson
5 */
7 #include "git-compat-util.h"
8 #include "builtin.h"
9 #include "strvec.h"
11 int cmd_annotate(int argc,
12 const char **argv,
13 const char *prefix,
14 struct repository *repo)
16 struct strvec args = STRVEC_INIT;
17 const char **args_copy;
18 int ret;
20 strvec_pushl(&args, "annotate", "-c", NULL);
21 for (int i = 1; i < argc; i++)
22 strvec_push(&args, argv[i]);
25 * `cmd_blame()` ends up modifying the array, which causes memory leaks
26 * if we didn't copy the array here.
28 CALLOC_ARRAY(args_copy, args.nr + 1);
29 COPY_ARRAY(args_copy, args.v, args.nr);
31 ret = cmd_blame(args.nr, args_copy, prefix, repo);
33 strvec_clear(&args);
34 free(args_copy);
35 return ret;