make the pack index version configurable
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>
Nicolas Pitre committed
Nov 1, 2007 at 23:26 UTC
4d00bda2aa9dd8cd6ec4015832b80eb1273d46d7
3 files changed
+28
Documentation/config.txt
+9
@@ -661,6 +661,15 @@ pack.threads::
661
machines. The required amount of memory for the delta search window
662
is however multiplied by the number of threads.
663
664
+pack.indexVersion::
665
+ Specify the default pack index version. Valid values are 1 for
666
+ legacy pack index used by Git versions prior to 1.5.2, and 2 for
667
+ the new pack index with capabilities for packs larger than 4 GB
668
+ as well as proper protection against the repacking of corrupted
669
+ packs. Version 2 is selected and this config option ignored
670
+ whenever the corresponding pack is larger than 2 GB. Otherwise
671
+ the default is 1.
672
+
673
pull.octopus::
674
The default merge strategy to use when pulling multiple branches
675
at once.
builtin-pack-objects.c
+6
@@ -1773,6 +1773,12 @@ static int git_pack_config(const char *k, const char *v)
1773
#endif
1774
return 0;
1775
}
1776
+ if (!strcmp(k, "pack.indexversion")) {
1777
+ pack_idx_default_version = git_config_int(k, v);
1778
+ if (pack_idx_default_version > 2)
1779
+ die("bad pack.indexversion=%d", pack_idx_default_version);
1780
+ return 0;
1781
+ }
1782
return git_default_config(k, v);
1783
}
1784
index-pack.c
+13
@@ -683,6 +683,17 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
683
}
684
}
685
686
+static int git_index_pack_config(const char *k, const char *v)
687
+{
688
+ if (!strcmp(k, "pack.indexversion")) {
689
+ pack_idx_default_version = git_config_int(k, v);
690
+ if (pack_idx_default_version > 2)
691
+ die("bad pack.indexversion=%d", pack_idx_default_version);
692
+ return 0;
693
+ }
694
+ return git_default_config(k, v);
695
+}
696
+
697
int main(int argc, char **argv)
698
{
699
int i, fix_thin_pack = 0;
@@ -693,6 +704,8 @@ int main(int argc, char **argv)
704
struct pack_idx_entry **idx_objects;
705
unsigned char sha1[20];
706
707
+ git_config(git_index_pack_config);
708
+
709
for (i = 1; i < argc; i++) {
710
const char *arg = argv[i];
711