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