Code

Fix combined use of whitespace ignore options to diff
[git.git] / builtin-for-each-ref.c
index 445039e19c75e4c9321f7ee64289ef8201a25c14..72c087840c39bc03b142ba620f94800d40264eb9 100644 (file)
@@ -320,9 +320,7 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
 
 static const char *copy_line(const char *buf)
 {
-       const char *eol = strchr(buf, '\n');
-       if (!eol)
-               return "";
+       const char *eol = strchrnul(buf, '\n');
        return xmemdupz(buf, eol - buf);
 }
 
@@ -459,8 +457,10 @@ static void find_subpos(const char *buf, unsigned long sz, const char **sub, con
                return;
        *sub = buf; /* first non-empty line */
        buf = strchr(buf, '\n');
-       if (!buf)
+       if (!buf) {
+               *body = "";
                return; /* no body */
+       }
        while (*buf == '\n')
                buf++; /* skip blank between subject and body */
        *body = buf;
@@ -650,7 +650,8 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
                        if ((plen <= namelen) &&
                            !strncmp(refname, p, plen) &&
                            (refname[plen] == '\0' ||
-                            refname[plen] == '/'))
+                            refname[plen] == '/' ||
+                            p[plen-1] == '/'))
                                break;
                        if (!fnmatch(p, refname, FNM_PATHNAME))
                                break;