summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-07-17 01:38:18 +0200
committerJunio C Hamano <gitster@pobox.com>2014-07-17 13:33:52 -0700
commitcedc61a99804db99f9a658c3cccd5c2786a28501 (patch)
tree7bc10fd908eba7b65762badba1a4e27a42c696ae /diff.c
parent9d02150cf4d833935161ef265e4dc03807caa800 (diff)
downloadgit-cedc61a99804db99f9a658c3cccd5c2786a28501.tar.gz
strbuf: use strbuf_addstr() for adding C strings
Avoid code duplication and let strbuf_addstr() call strlen() for us. Signed-off-by: Rene Scharfe <l.s.r@web.de> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/diff.c b/diff.c
index 06bdfb8ae5..867f034b8f 100644
--- a/diff.c
+++ b/diff.c
@@ -525,9 +525,9 @@ static void emit_hunk_header(struct emit_callback *ecbdata,
ep += 2; /* skip over @@ */
/* The hunk header in fraginfo color */
- strbuf_add(&msgbuf, frag, strlen(frag));
+ strbuf_addstr(&msgbuf, frag);
strbuf_add(&msgbuf, line, ep - line);
- strbuf_add(&msgbuf, reset, strlen(reset));
+ strbuf_addstr(&msgbuf, reset);
/*
* trailing "\r\n"
@@ -541,15 +541,15 @@ static void emit_hunk_header(struct emit_callback *ecbdata,
if (*ep != ' ' && *ep != '\t')
break;
if (ep != cp) {
- strbuf_add(&msgbuf, plain, strlen(plain));
+ strbuf_addstr(&msgbuf, plain);
strbuf_add(&msgbuf, cp, ep - cp);
- strbuf_add(&msgbuf, reset, strlen(reset));
+ strbuf_addstr(&msgbuf, reset);
}
if (ep < line + len) {
- strbuf_add(&msgbuf, func, strlen(func));
+ strbuf_addstr(&msgbuf, func);
strbuf_add(&msgbuf, ep, line + len - ep);
- strbuf_add(&msgbuf, reset, strlen(reset));
+ strbuf_addstr(&msgbuf, reset);
}
strbuf_add(&msgbuf, line + len, org_len - len);