summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4165076)
raw | patch | inline | side by side (parent: 4165076)
author | Christian Couder <chriscool@tuxfamily.org> | |
Mon, 3 Dec 2007 04:51:50 +0000 (05:51 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 4 Dec 2007 06:11:53 +0000 (22:11 -0800) |
Now that str_buf takes care of all the allocations, there is
no more gain to pass an argument count.
So this patch removes the "count" argument from:
- "sq_quote_argv"
- "trace_argv_printf"
and all the callers.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
no more gain to pass an argument count.
So this patch removes the "count" argument from:
- "sq_quote_argv"
- "trace_argv_printf"
and all the callers.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-rev-parse.c | patch | blob | history | |
cache.h | patch | blob | history | |
exec_cmd.c | patch | blob | history | |
git.c | patch | blob | history | |
quote.c | patch | blob | history | |
quote.h | patch | blob | history | |
trace.c | patch | blob | history |
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index d1038a0e66edf728fbba9476b3b9f443647c612c..20d1789e0161ed3d2d18cec94b1915f518a5d662 100644 (file)
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0);
strbuf_addf(&parsed, " --");
- sq_quote_argv(&parsed, argv, argc, 0);
+ sq_quote_argv(&parsed, argv, 0);
puts(parsed.buf);
return 0;
}
index d0e7a71c6e61e56c841f9670266a2e5d61211158..ed8be062990410875b6a1a4cf8663bd5b8a69879 100644 (file)
--- a/cache.h
+++ b/cache.h
/* trace.c */
extern void trace_printf(const char *format, ...);
-extern void trace_argv_printf(const char **argv, int count, const char *format, ...);
+extern void trace_argv_printf(const char **argv, const char *format, ...);
/* convert.c */
/* returns 1 if *dst was used */
diff --git a/exec_cmd.c b/exec_cmd.c
index 2d0a75851284392aa8ae44bc486df6a034d0af13..e189caca629262334541ea8313d2931b06e67adf 100644 (file)
--- a/exec_cmd.c
+++ b/exec_cmd.c
tmp = argv[0];
argv[0] = cmd.buf;
- trace_argv_printf(argv, -1, "trace: exec:");
+ trace_argv_printf(argv, "trace: exec:");
/* execvp() can only ever return if it fails */
execvp(cmd.buf, (char **)argv);
index f510fe37069a5b11dfef445f862da9f52337d172..c4877a9714c227a1af77cfa84caa2230eb30bf9d 100644 (file)
--- a/git.c
+++ b/git.c
strbuf_init(&buf, PATH_MAX);
strbuf_addstr(&buf, alias_string);
- sq_quote_argv(&buf, (*argv) + 1, *argcp - 1, PATH_MAX);
+ sq_quote_argv(&buf, (*argv) + 1, PATH_MAX);
free(alias_string);
alias_string = buf.buf;
}
if (!strcmp(alias_command, new_argv[0]))
die("recursive alias: %s", alias_command);
- trace_argv_printf(new_argv, count,
+ trace_argv_printf(new_argv,
"trace: alias expansion: %s =>",
alias_command);
if (p->option & NEED_WORK_TREE)
setup_work_tree();
- trace_argv_printf(argv, argc, "trace: built-in: git");
+ trace_argv_printf(argv, "trace: built-in: git");
status = p->fn(argc, argv, prefix);
if (status)
index 04557833a561b4613a511af8fb9f0fb18b36b2fa..6986b4420f66e1f01cd4517d35ce9adc300eaa8b 100644 (file)
--- a/quote.c
+++ b/quote.c
fputc('\'', stream);
}
-void sq_quote_argv(struct strbuf *dst, const char** argv, int count,
- size_t maxlen)
+void sq_quote_argv(struct strbuf *dst, const char** argv, size_t maxlen)
{
int i;
- /* Count argv if needed. */
- if (count < 0) {
- for (count = 0; argv[count]; count++)
- ; /* just counting */
- }
-
/* Copy into destination buffer. */
- strbuf_grow(dst, 32 * count);
- for (i = 0; i < count; ++i) {
+ strbuf_grow(dst, 255);
+ for (i = 0; argv[i]; ++i) {
strbuf_addch(dst, ' ');
sq_quote_buf(dst, argv[i]);
if (maxlen && dst->len > maxlen)
index 42879909983679f31b9ac6d7e5bfc330d8167a91..ab7596f57b7f23899ef1bbb8d0c7ba6ec5baf12f 100644 (file)
--- a/quote.h
+++ b/quote.h
extern void sq_quote_print(FILE *stream, const char *src);
extern void sq_quote_buf(struct strbuf *, const char *src);
-extern void sq_quote_argv(struct strbuf *, const char **argv, int count,
- size_t maxlen);
+extern void sq_quote_argv(struct strbuf *, const char **argv, size_t maxlen);
/* This unwraps what sq_quote() produces in place, but returns
* NULL if the input does not look like what sq_quote would have
index d3d1b6d55e86aab94ddb9712f5eee743b3bfa9a8..4713f9165c54405d51e81c3e90847120ee907e5d 100644 (file)
--- a/trace.c
+++ b/trace.c
close(fd);
}
-void trace_argv_printf(const char **argv, int count, const char *fmt, ...)
+void trace_argv_printf(const char **argv, const char *fmt, ...)
{
struct strbuf buf;
va_list ap;
}
strbuf_setlen(&buf, len);
- sq_quote_argv(&buf, argv, count, 0);
+ sq_quote_argv(&buf, argv, 0);
strbuf_addch(&buf, '\n');
write_or_whine_pipe(fd, buf.buf, buf.len, err_msg);
strbuf_release(&buf);