THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.5KB

  1. #include "cache.h"
  2. #include "config.h"
  3. #include "repository.h"
  4. #define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
  5. void prepare_repo_settings(struct repository *r)
  6. {
  7. int value;
  8. char *strval;
  9. if (r->settings.initialized)
  10. return;
  11. /* Defaults */
  12. memset(&r->settings, -1, sizeof(r->settings));
  13. if (!repo_config_get_bool(r, "core.commitgraph", &value))
  14. r->settings.core_commit_graph = value;
  15. if (!repo_config_get_bool(r, "gc.writecommitgraph", &value))
  16. r->settings.gc_write_commit_graph = value;
  17. UPDATE_DEFAULT_BOOL(r->settings.core_commit_graph, 1);
  18. UPDATE_DEFAULT_BOOL(r->settings.gc_write_commit_graph, 1);
  19. if (!repo_config_get_bool(r, "index.version", &value))
  20. r->settings.index_version = value;
  21. if (!repo_config_get_maybe_bool(r, "core.untrackedcache", &value)) {
  22. if (value == 0)
  23. r->settings.core_untracked_cache = UNTRACKED_CACHE_REMOVE;
  24. else
  25. r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
  26. } else if (!repo_config_get_string(r, "core.untrackedcache", &strval)) {
  27. if (!strcasecmp(strval, "keep"))
  28. r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
  29. free(strval);
  30. }
  31. if (!repo_config_get_string(r, "fetch.negotiationalgorithm", &strval)) {
  32. if (!strcasecmp(strval, "skipping"))
  33. r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
  34. else
  35. r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_DEFAULT;
  36. }
  37. if (!repo_config_get_bool(r, "pack.usesparse", &value))
  38. r->settings.pack_use_sparse = value;
  39. if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
  40. UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
  41. UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
  42. }
  43. if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value))
  44. r->settings.fetch_write_commit_graph = value;
  45. if (!repo_config_get_bool(r, "feature.experimental", &value) && value) {
  46. UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
  47. UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
  48. UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 1);
  49. }
  50. UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 0);
  51. /* Hack for test programs like test-dump-untracked-cache */
  52. if (ignore_untracked_cache_config)
  53. r->settings.core_untracked_cache = UNTRACKED_CACHE_KEEP;
  54. else
  55. UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_KEEP);
  56. UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_DEFAULT);
  57. }