]>
| Commit | Line | Data |
|---|---|---|
| f789e347 RA |
1 | /* |
| 2 | * "git annotate" builtin alias | |
| 3 | * | |
| 4 | * Copyright (C) 2006 Ryan Anderson | |
| 5 | */ | |
| 03eae9af | 6 | |
| f789e347 | 7 | #include "git-compat-util.h" |
| a19f901d | 8 | #include "builtin.h" |
| dbbcd44f | 9 | #include "strvec.h" |
| f789e347 | 10 | |
| 9b1cb507 JC |
11 | int cmd_annotate(int argc, |
| 12 | const char **argv, | |
| 13 | const char *prefix, | |
| ebe8f4b6 | 14 | struct repository *repo) |
| f789e347 | 15 | { |
| 22f9b7f3 | 16 | struct strvec args = STRVEC_INIT; |
| 9a48fc1d PS |
17 | const char **args_copy; |
| 18 | int ret; | |
| f789e347 | 19 | |
| 22f9b7f3 | 20 | strvec_pushl(&args, "annotate", "-c", NULL); |
| 9a48fc1d | 21 | for (int i = 1; i < argc; i++) |
| 22f9b7f3 | 22 | strvec_push(&args, argv[i]); |
| f789e347 | 23 | |
| 9a48fc1d PS |
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 | ||
| 0ab43ed9 | 31 | ret = cmd_blame(args.nr, args_copy, prefix, repo); |
| 9a48fc1d PS |
32 | |
| 33 | strvec_clear(&args); | |
| 34 | free(args_copy); | |
| 35 | return ret; | |
| f789e347 | 36 | } |