Code

No longer install git-svnimport, move to contrib/examples
[git.git] / refs.c
diff --git a/refs.c b/refs.c
index 0dc5678079b6e6d40a06f48d14a9f73465cb9243..aff02cd09d4e40b04f6764a6f6ab43240b736a08 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1213,15 +1213,11 @@ int create_symref(const char *ref_target, const char *refs_heads_master,
 static char *ref_msg(const char *line, const char *endp)
 {
        const char *ep;
-       char *msg;
-
        line += 82;
-       for (ep = line; ep < endp && *ep != '\n'; ep++)
-               ;
-       msg = xmalloc(ep - line + 1);
-       memcpy(msg, line, ep - line);
-       msg[ep - line] = 0;
-       return msg;
+       ep = memchr(line, '\n', endp - line);
+       if (!ep)
+               ep = endp;
+       return xmemdupz(line, ep - line);
 }
 
 int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)