Imported Upstream version 2.27.0
[platform/upstream/git.git] / builtin / pack-objects.c
index 02aa6ee..c5b433a 100644 (file)
@@ -26,7 +26,7 @@
 #include "pack-bitmap.h"
 #include "delta-islands.h"
 #include "reachable.h"
-#include "sha1-array.h"
+#include "oid-array.h"
 #include "argv-array.h"
 #include "list.h"
 #include "packfile.h"
@@ -34,6 +34,7 @@
 #include "dir.h"
 #include "midx.h"
 #include "trace2.h"
+#include "shallow.h"
 
 #define IN_PACK(obj) oe_in_pack(&to_pack, obj)
 #define SIZE(obj) oe_size(&to_pack, obj)
@@ -880,7 +881,7 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out,
                        len = encode_in_pack_object_header(header, sizeof(header),
                                                           OBJ_REF_DELTA, size);
                        hashwrite(out, header, len);
-                       hashwrite(out, base_oid.hash, 20);
+                       hashwrite(out, base_oid.hash, the_hash_algo->rawsz);
                        copy_pack_data(out, reuse_packfile, w_curs, cur, next - cur);
                        return;
                }
@@ -3380,9 +3381,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                OPT_BOOL(0, "all-progress-implied",
                         &all_progress_implied,
                         N_("similar to --all-progress when progress meter is shown")),
-               { OPTION_CALLBACK, 0, "index-version", NULL, N_("<version>[,<offset>]"),
+               OPT_CALLBACK_F(0, "index-version", NULL, N_("<version>[,<offset>]"),
                  N_("write the pack index file in the specified idx format version"),
-                 PARSE_OPT_NONEG, option_parse_index_version },
+                 PARSE_OPT_NONEG, option_parse_index_version),
                OPT_MAGNITUDE(0, "max-pack-size", &pack_size_limit,
                              N_("maximum size of each output pack file")),
                OPT_BOOL(0, "local", &local,
@@ -3427,9 +3428,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                         N_("keep unreachable objects")),
                OPT_BOOL(0, "pack-loose-unreachable", &pack_loose_unreachable,
                         N_("pack loose unreachable objects")),
-               { OPTION_CALLBACK, 0, "unpack-unreachable", NULL, N_("time"),
+               OPT_CALLBACK_F(0, "unpack-unreachable", NULL, N_("time"),
                  N_("unpack unreachable objects newer than <time>"),
-                 PARSE_OPT_OPTARG, option_parse_unpack_unreachable },
+                 PARSE_OPT_OPTARG, option_parse_unpack_unreachable),
                OPT_BOOL(0, "sparse", &sparse,
                         N_("use the sparse reachability algorithm")),
                OPT_BOOL(0, "thin", &thin,
@@ -3454,9 +3455,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
                              N_("write a bitmap index if possible"),
                              WRITE_BITMAP_QUIET, PARSE_OPT_HIDDEN),
                OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
-               { OPTION_CALLBACK, 0, "missing", NULL, N_("action"),
+               OPT_CALLBACK_F(0, "missing", NULL, N_("action"),
                  N_("handling for missing objects"), PARSE_OPT_NONEG,
-                 option_parse_missing_action },
+                 option_parse_missing_action),
                OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects,
                         N_("do not pack objects in promisor packfiles")),
                OPT_BOOL(0, "delta-islands", &use_delta_islands,
@@ -3469,9 +3470,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 
        read_replace_refs = 0;
 
-       sparse = git_env_bool("GIT_TEST_PACK_SPARSE", 0);
+       sparse = git_env_bool("GIT_TEST_PACK_SPARSE", -1);
        prepare_repo_settings(the_repository);
-       if (!sparse && the_repository->settings.pack_use_sparse != -1)
+       if (sparse < 0)
                sparse = the_repository->settings.pack_use_sparse;
 
        reset_pack_idx_option(&pack_idx_opts);