Skip to content

Commit

Permalink
make the pack index version configurable
Browse files Browse the repository at this point in the history
It is a good idea to use pack index version 2 all the time since it has
proper protection against propagation of certain pack corruptions when
repacking which is not possible with index version 1, as demonstrated
in test t5302.

Hence this config option.

The default is still pack index version 1.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nicolas Pitre authored and Junio C Hamano committed Nov 2, 2007
1 parent 3e4bb08 commit 4d00bda
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,15 @@ pack.threads::
machines. The required amount of memory for the delta search window
is however multiplied by the number of threads.

pack.indexVersion::
Specify the default pack index version. Valid values are 1 for
legacy pack index used by Git versions prior to 1.5.2, and 2 for
the new pack index with capabilities for packs larger than 4 GB
as well as proper protection against the repacking of corrupted
packs. Version 2 is selected and this config option ignored
whenever the corresponding pack is larger than 2 GB. Otherwise
the default is 1.

pull.octopus::
The default merge strategy to use when pulling multiple branches
at once.
Expand Down
6 changes: 6 additions & 0 deletions builtin-pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,12 @@ static int git_pack_config(const char *k, const char *v)
#endif
return 0;
}
if (!strcmp(k, "pack.indexversion")) {
pack_idx_default_version = git_config_int(k, v);
if (pack_idx_default_version > 2)
die("bad pack.indexversion=%d", pack_idx_default_version);
return 0;
}
return git_default_config(k, v);
}

Expand Down
13 changes: 13 additions & 0 deletions index-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,17 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
}
}

static int git_index_pack_config(const char *k, const char *v)
{
if (!strcmp(k, "pack.indexversion")) {
pack_idx_default_version = git_config_int(k, v);
if (pack_idx_default_version > 2)
die("bad pack.indexversion=%d", pack_idx_default_version);
return 0;
}
return git_default_config(k, v);
}

int main(int argc, char **argv)
{
int i, fix_thin_pack = 0;
Expand All @@ -693,6 +704,8 @@ int main(int argc, char **argv)
struct pack_idx_entry **idx_objects;
unsigned char sha1[20];

git_config(git_index_pack_config);

for (i = 1; i < argc; i++) {
const char *arg = argv[i];

Expand Down

0 comments on commit 4d00bda

Please sign in to comment.