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