t7510: stop referring to master in later tests
[gitweb.git] / pack-write.c
index 605d01b25cbd9d796810f8aa810894a2c198da28..9ccf80419b06789aa3a1171869bd4179787e5eff 100644 (file)
@@ -336,7 +336,7 @@ struct sha1file *create_tmp_packfile(char **pack_tmp_name)
        return sha1fd(fd, *pack_tmp_name);
 }
 
-void finish_tmp_packfile(char *name_buffer,
+void finish_tmp_packfile(struct strbuf *name_buffer,
                         const char *pack_tmp_name,
                         struct pack_idx_entry **written_list,
                         uint32_t nr_written,
@@ -344,7 +344,7 @@ void finish_tmp_packfile(char *name_buffer,
                         unsigned char sha1[])
 {
        const char *idx_tmp_name;
-       char *end_of_name_prefix = strrchr(name_buffer, 0);
+       int basename_len = name_buffer->len;
 
        if (adjust_shared_perm(pack_tmp_name))
                die_errno("unable to make temporary pack file readable");
@@ -354,15 +354,19 @@ void finish_tmp_packfile(char *name_buffer,
        if (adjust_shared_perm(idx_tmp_name))
                die_errno("unable to make temporary index file readable");
 
-       sprintf(end_of_name_prefix, "%s.pack", sha1_to_hex(sha1));
-       free_pack_by_name(name_buffer);
+       strbuf_addf(name_buffer, "%s.pack", sha1_to_hex(sha1));
+       free_pack_by_name(name_buffer->buf);
 
-       if (rename(pack_tmp_name, name_buffer))
+       if (rename(pack_tmp_name, name_buffer->buf))
                die_errno("unable to rename temporary pack file");
 
-       sprintf(end_of_name_prefix, "%s.idx", sha1_to_hex(sha1));
-       if (rename(idx_tmp_name, name_buffer))
+       strbuf_setlen(name_buffer, basename_len);
+
+       strbuf_addf(name_buffer, "%s.idx", sha1_to_hex(sha1));
+       if (rename(idx_tmp_name, name_buffer->buf))
                die_errno("unable to rename temporary index file");
 
+       strbuf_setlen(name_buffer, basename_len);
+
        free((void *)idx_tmp_name);
 }