Code

git-gc: always use -A when manually repacking
[git.git] / pack-write.c
index 979bdfff7c516ada7fb36281a22b41d303d1b99c..c66c8af725f6d37b4edaeab75eebac7a387f4922 100644 (file)
@@ -17,7 +17,8 @@ static int sha1_compare(const void *_a, const void *_b)
  * the SHA1 hash of sorted object names. The objects array passed in
  * will be sorted by SHA1 on exit.
  */
-const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1)
+char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
+                    int nr_objects, unsigned char *sha1)
 {
        struct sha1file *f;
        struct pack_idx_entry **sorted_by_sha, **list, **last;
@@ -182,7 +183,6 @@ void fixup_pack_header_footer(int pack_fd,
 
 char *index_pack_lockfile(int ip_out)
 {
-       int len, s;
        char packname[46];
 
        /*
@@ -192,11 +192,8 @@ 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.
         */
-       for (len = 0;
-                len < 46 && (s = xread(ip_out, packname+len, 46-len)) > 0;
-                len += s);
-       if (len == 46 && packname[45] == '\n' &&
-               memcmp(packname, "keep\t", 5) == 0) {
+       if (read_in_full(ip_out, packname, 46) == 46 && packname[45] == '\n' &&
+           memcmp(packname, "keep\t", 5) == 0) {
                char path[PATH_MAX];
                packname[45] = 0;
                snprintf(path, sizeof(path), "%s/pack/pack-%s.keep",