Merge branch 'jn/send-pack-error' into maint
[gitweb.git] / builtin / index-pack.c
index 89a1f12d615bb997bd992abba61da712def3ea44..8dc5c0b5410d4bb57607bab690126f22d954dd7a 100644 (file)
@@ -11,7 +11,7 @@
 #include "exec_cmd.h"
 
 static const char index_pack_usage[] =
-"git index-pack [-v] [-o <index-file>] [{ --keep | --keep=<msg> }] [--strict] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
+"git index-pack [-v] [-o <index-file>] [ --keep | --keep=<msg> ] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";
 
 struct object_entry
 {
@@ -161,7 +161,7 @@ static void use(int bytes)
        input_offset += bytes;
 
        /* make sure off_t is sufficiently large not to wrap */
-       if (consumed_bytes > consumed_bytes + bytes)
+       if (signed_add_overflows(consumed_bytes, bytes))
                die("pack too large for current definition of off_t");
        consumed_bytes += bytes;
 }
@@ -880,12 +880,12 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
        char *index_name_buf = NULL, *keep_name_buf = NULL;
        struct pack_idx_entry **idx_objects;
        unsigned char pack_sha1[20];
-       int nongit;
 
        if (argc == 2 && !strcmp(argv[1], "-h"))
                usage(index_pack_usage);
 
-       prefix = setup_git_directory_gently(&nongit);
+       read_replace_refs = 0;
+
        git_config(git_index_pack_config, NULL);
        if (prefix && chdir(prefix))
                die("Cannot come back to cwd");