bump to v2.0.1
[platform/upstream/git.git] / bulk-checkin.c
index 6b0b6d4..98e651c 100644 (file)
@@ -4,6 +4,7 @@
 #include "bulk-checkin.h"
 #include "csum-file.h"
 #include "pack.h"
+#include "strbuf.h"
 
 static int pack_compression_level = Z_DEFAULT_COMPRESSION;
 
@@ -23,7 +24,7 @@ static struct bulk_checkin_state {
 static void finish_bulk_checkin(struct bulk_checkin_state *state)
 {
        unsigned char sha1[20];
-       char packname[PATH_MAX];
+       struct strbuf packname = STRBUF_INIT;
        int i;
 
        if (!state->f)
@@ -43,8 +44,8 @@ static void finish_bulk_checkin(struct bulk_checkin_state *state)
                close(fd);
        }
 
-       sprintf(packname, "%s/pack/pack-", get_object_directory());
-       finish_tmp_packfile(packname, state->pack_tmp_name,
+       strbuf_addf(&packname, "%s/pack/pack-", get_object_directory());
+       finish_tmp_packfile(&packname, state->pack_tmp_name,
                            state->written, state->nr_written,
                            &state->pack_idx_opts, sha1);
        for (i = 0; i < state->nr_written; i++)
@@ -54,6 +55,7 @@ clear_exit:
        free(state->written);
        memset(state, 0, sizeof(*state));
 
+       strbuf_release(&packname);
        /* Make objects we just wrote available to ourselves */
        reprepare_packed_git();
 }
@@ -114,7 +116,7 @@ static int stream_to_pack(struct bulk_checkin_state *state,
 
                if (size && !s.avail_in) {
                        ssize_t rsize = size < sizeof(ibuf) ? size : sizeof(ibuf);
-                       if (xread(fd, ibuf, rsize) != rsize)
+                       if (read_in_full(fd, ibuf, rsize) != rsize)
                                die("failed to read %d bytes from '%s'",
                                    (int)rsize, path);
                        offset += rsize;