Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]>
---
diff.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/diff.c b/diff.c
index dfbed41..8af1df1 100644
--- a/diff.c
+++ b/diff.c
@@ -788,9 +788,17 @@ struct diff_words_data {
struct diff_words_style *style;
};
-static void diff_words_append(char *line, unsigned long len,
- struct diff_words_buffer *buffer)
+static void diff_words_append(struct diff_words_data *diff_words,
+ char *line, unsigned long len)
{
+ struct diff_words_buffer *buffer;
+
+ if (line[0] == '-')
+ buffer = &diff_words->minus;
+ else {
+ assert(line[0] == '+');
+ buffer = &diff_words->plus;
+ }
ALLOC_GROW(buffer->text.ptr, buffer->text.size + len, buffer->alloc);
line++;
len--;
@@ -1252,13 +1260,8 @@ static void fn_out_consume(void *priv, char *line,
unsigned long len)
}
if (ecbdata->diff_words) {
- if (line[0] == '-') {
- diff_words_append(line, len,
- &ecbdata->diff_words->minus);
- return;
- } else if (line[0] == '+') {
- diff_words_append(line, len,
- &ecbdata->diff_words->plus);
+ if (line[0] == '-' || line[0] == '+') {
+ diff_words_append(ecbdata->diff_words, line, len);
return;
} else if (starts_with(line, "\\ ")) {
/*
--
2.3.0.rc1.137.g477eb31
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html