summaryrefslogtreecommitdiff
path: root/builtin/annotate.c
diff options
context:
space:
mode:
authorLibravatar René Scharfe <l.s.r@web.de>2014-07-16 10:51:33 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-07-16 11:10:11 -0700
commit8c2cfa55446f542454eb4acc7f49d1747e425c94 (patch)
treecdb357d0fae79890827c6e488cbed69eef837fe6 /builtin/annotate.c
parentt7300: repair filesystem permissions with test_when_finished (diff)
downloadtgif-8c2cfa55446f542454eb4acc7f49d1747e425c94.tar.xz
annotate: use argv_array
Simplify the code and get rid of some magic constants by using argv_array to build the argument list for cmd_blame. Be lazy and let the OS release our allocated memory, as before. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/annotate.c')
-rw-r--r--builtin/annotate.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/builtin/annotate.c b/builtin/annotate.c
index fc43eed36b..da413ae0d1 100644
--- a/builtin/annotate.c
+++ b/builtin/annotate.c
@@ -5,20 +5,18 @@
*/
#include "git-compat-util.h"
#include "builtin.h"
+#include "argv-array.h"
int cmd_annotate(int argc, const char **argv, const char *prefix)
{
- const char **nargv;
+ struct argv_array args = ARGV_ARRAY_INIT;
int i;
- nargv = xmalloc(sizeof(char *) * (argc + 2));
- nargv[0] = "annotate";
- nargv[1] = "-c";
+ argv_array_pushl(&args, "annotate", "-c", NULL);
for (i = 1; i < argc; i++) {
- nargv[i+1] = argv[i];
+ argv_array_push(&args, argv[i]);
}
- nargv[argc + 1] = NULL;
- return cmd_blame(argc + 1, nargv, prefix);
+ return cmd_blame(args.argc, args.argv, prefix);
}