use skip_prefix to avoid repeating strings
[gitweb.git] / builtin / apply.c
index 9c5724eaccfaee62ff10eb097adc39ace351cade..bc924ab2d03a17477fbbe9ea6a25a704963f85b5 100644 (file)
@@ -3847,9 +3847,10 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
        ce->ce_flags = create_ce_flags(0);
        ce->ce_namelen = namelen;
        if (S_ISGITLINK(mode)) {
-               const char *s = buf;
+               const char *s;
 
-               if (get_sha1_hex(s + strlen("Subproject commit "), ce->sha1))
+               if (!skip_prefix(buf, "Subproject commit ", &s) ||
+                   get_sha1_hex(s, ce->sha1))
                        die(_("corrupt patch for submodule %s"), path);
        } else {
                if (!cached) {