Skip to content

Commit

Permalink
gvfs: add the core.gvfs config setting
Browse files Browse the repository at this point in the history
This does not do anything yet. The next patches will add various values
for that config setting that correspond to the various features
offered/required by GVFS.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>

gvfs: refactor loading the core.gvfs config value

This code change makes sure that the config value for core_gvfs
is always loaded before checking it.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
  • Loading branch information
Kevin Willford authored and dscho committed Oct 8, 2024
1 parent 6ef6540 commit e3d9c14
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,9 @@ core.multiPackIndex::
single index. See linkgit:git-multi-pack-index[1] for more
information. Defaults to true.

core.gvfs::
Enable the features needed for GVFS.

core.sparseCheckout::
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
for more information.
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ LIB_OBJS += git-zlib.o
LIB_OBJS += gpg-interface.o
LIB_OBJS += graph.o
LIB_OBJS += grep.o
LIB_OBJS += gvfs.o
LIB_OBJS += hash-lookup.o
LIB_OBJS += hashmap.o
LIB_OBJS += help.o
Expand Down
6 changes: 6 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "abspath.h"
#include "advice.h"
#include "date.h"
#include "gvfs.h"
#include "branch.h"
#include "config.h"
#include "parse.h"
Expand Down Expand Up @@ -1642,6 +1643,11 @@ int git_default_core_config(const char *var, const char *value,
return 0;
}

if (!strcmp(var, "core.gvfs")) {
gvfs_load_config_value(value);
return 0;
}

if (!strcmp(var, "core.sparsecheckout")) {
core_apply_sparse_checkout = git_config_bool(var, value);
return 0;
Expand Down
1 change: 1 addition & 0 deletions environment.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ int grafts_keep_true_parents;
int core_apply_sparse_checkout;
int core_sparse_checkout_cone;
int sparse_expect_files_outside_of_patterns;
int core_gvfs;
int merge_log_config = -1;
int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */
unsigned long pack_size_limit_cfg;
Expand Down
1 change: 1 addition & 0 deletions environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ extern unsigned long pack_size_limit_cfg;
extern int max_allowed_tree_depth;

extern int core_preload_index;
extern int core_gvfs;
extern int precomposed_unicode;
extern int protect_hfs;
extern int protect_ntfs;
Expand Down
45 changes: 45 additions & 0 deletions gvfs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#define USE_THE_REPOSITORY_VARIABLE
#include "git-compat-util.h"
#include "environment.h"
#include "gvfs.h"
#include "setup.h"
#include "config.h"

static int gvfs_config_loaded;
static int core_gvfs_is_bool;

static int early_core_gvfs_config(const char *var, const char *value,
const struct config_context *ctx, void *cb UNUSED)
{
if (!strcmp(var, "core.gvfs"))
core_gvfs = git_config_bool_or_int("core.gvfs", value, ctx->kvi,
&core_gvfs_is_bool);
return 0;
}

void gvfs_load_config_value(const char *value)
{
if (gvfs_config_loaded)
return;

if (value) {
struct key_value_info default_kvi = KVI_INIT;
core_gvfs = git_config_bool_or_int("core.gvfs", value, &default_kvi, &core_gvfs_is_bool);
} else if (startup_info->have_repository == 0)
read_early_config(the_repository, early_core_gvfs_config, NULL);
else
repo_config_get_bool_or_int(the_repository, "core.gvfs",
&core_gvfs_is_bool, &core_gvfs);

/* Turn on all bits if a bool was set in the settings */
if (core_gvfs_is_bool && core_gvfs)
core_gvfs = -1;

gvfs_config_loaded = 1;
}

int gvfs_config_is_set(int mask)
{
gvfs_load_config_value(NULL);
return (core_gvfs & mask) == mask;
}
4 changes: 4 additions & 0 deletions gvfs.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#ifndef GVFS_H
#define GVFS_H


/*
* This file is for the specific settings and methods
* used for GVFS functionality
*/

void gvfs_load_config_value(const char *value);
int gvfs_config_is_set(int mask);

#endif /* GVFS_H */

0 comments on commit e3d9c14

Please sign in to comment.