Signed-off-by: John Keeping <j...@keeping.me.uk>
---
 ui-log.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/ui-log.c b/ui-log.c
index 7c3308c..44f6004 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -289,7 +289,7 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char 
*grep, char *pattern
        struct vector vec = VECTOR_INIT(char *);
        int i, columns = commit_graph ? 4 : 3;
        int must_free_tip = 0;
-       char *arg;
+       struct strbuf argbuf = STRBUF_INIT;
 
        /* First argv is NULL */
        vector_push(&vec, NULL, 0);
@@ -303,10 +303,11 @@ void cgit_print_log(const char *tip, int ofs, int cnt, 
char *grep, char *pattern
                pattern = xstrdup(pattern);
                if (!strcmp(grep, "grep") || !strcmp(grep, "author") ||
                    !strcmp(grep, "committer")) {
-                       arg = fmt("--%s=%s", grep, pattern);
-                       vector_push(&vec, &arg, 0);
+                       strbuf_addf(&argbuf, "--%s=%s", grep, pattern);
+                       vector_push(&vec, &argbuf.buf, 0);
                }
                if (!strcmp(grep, "range")) {
+                       char *arg;
                        /* Split the pattern at whitespace and add each token
                         * as a revision expression. Do not accept other
                         * rev-list options. Also, replace the previously
@@ -341,8 +342,8 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char 
*grep, char *pattern
        }
 
        if (path) {
-               arg = "--";
-               vector_push(&vec, &arg, 0);
+               static const char *double_dash_arg = "--";
+               vector_push(&vec, &double_dash_arg, 0);
                vector_push(&vec, &path, 0);
        }
 
@@ -438,4 +439,5 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char 
*grep, char *pattern
        /* If we allocated tip then it is safe to cast away const. */
        if (must_free_tip)
                free((char*) tip);
+       strbuf_release(&argbuf);
 }
-- 
1.8.2.692.g17a9715


_______________________________________________
cgit mailing list
cgit@hjemli.net
http://hjemli.net/mailman/listinfo/cgit

Reply via email to