index-pack: fix compilation with NO_PTHREADS
[gitweb.git] / pack-write.c
index 9ccf80419b06789aa3a1171869bd4179787e5eff..33293ce2a6b8ea51516e42d01001b15a3016ca27 100644 (file)
@@ -288,13 +288,12 @@ char *index_pack_lockfile(int ip_out)
         * case, we need it to remove the corresponding .keep file
         * later on.  If we don't get that then tough luck with it.
         */
-       if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n' &&
-           memcmp(packname, "keep\t", 5) == 0) {
-               char path[PATH_MAX];
+       if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n') {
+               const char *name;
                packname[45] = 0;
-               snprintf(path, sizeof(path), "%s/pack/pack-%s.keep",
-                        get_object_directory(), packname + 5);
-               return xstrdup(path);
+               if (skip_prefix(packname, "keep\t", &name))
+                       return xstrfmt("%s/pack/pack-%s.keep",
+                                      get_object_directory(), name);
        }
        return NULL;
 }