]> asedeno.scripts.mit.edu Git - git.git/blobdiff - xdiff-interface.c
Merge branch 'js/maint-fetch-update-head'
[git.git] / xdiff-interface.c
index f3f6db3297e4fd367d7af05a4755037aaf2aaf42..49e06af710ceee5538eb10f0c6cf9c30f31748b4 100644 (file)
@@ -207,6 +207,16 @@ static long ff_regexp(const char *line, long len,
 
        line_buffer = xstrndup(line, len); /* make NUL terminated */
 
+       /* Exclude terminating newline (and cr) from matching */
+       if (len > 0 && line[len-1] == '\n') {
+               if (len > 1 && line[len-2] == '\r')
+                       len -= 2;
+               else
+                       len--;
+       }
+
+       line_buffer = xstrndup(line, len); /* make NUL terminated */
+
        for (i = 0; i < regs->nr; i++) {
                struct ff_reg *reg = regs->array + i;
                if (!regexec(&reg->re, line_buffer, 2, pmatch, 0)) {