Skip to content

Commit 9d299a0

Browse files
Kevin Willforddscho
authored andcommitted
gvfs: add the core.gvfs config setting
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 <[email protected]> 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 <[email protected]>
1 parent f4dd260 commit 9d299a0

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

Documentation/config/core.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,9 @@ core.multiPackIndex::
742742
single index. See linkgit:git-multi-pack-index[1] for more
743743
information. Defaults to true.
744744

745+
core.gvfs::
746+
Enable the features needed for GVFS.
747+
745748
core.sparseCheckout::
746749
Enable "sparse checkout" feature. See linkgit:git-sparse-checkout[1]
747750
for more information.

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,7 @@ LIB_OBJS += git-zlib.o
10461046
LIB_OBJS += gpg-interface.o
10471047
LIB_OBJS += graph.o
10481048
LIB_OBJS += grep.o
1049+
LIB_OBJS += gvfs.o
10491050
LIB_OBJS += hash-lookup.o
10501051
LIB_OBJS += hash.o
10511052
LIB_OBJS += hashmap.o

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "git-compat-util.h"
1010
#include "abspath.h"
1111
#include "date.h"
12+
#include "gvfs.h"
1213
#include "branch.h"
1314
#include "config.h"
1415
#include "parse.h"

gvfs.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
2+
#include "git-compat-util.h"
3+
#include "environment.h"
4+
#include "gvfs.h"
5+
#include "setup.h"
6+
#include "config.h"
7+
8+
static int gvfs_config_loaded;
9+
static struct repository *gvfs_repo;
10+
static int core_gvfs;
11+
static int core_gvfs_is_bool;
12+
13+
static int early_core_gvfs_config(const char *var, const char *value,
14+
const struct config_context *ctx, void *cb UNUSED)
15+
{
16+
if (!strcmp(var, "core.gvfs"))
17+
core_gvfs = git_config_bool_or_int("core.gvfs", value, ctx->kvi,
18+
&core_gvfs_is_bool);
19+
return 0;
20+
}
21+
22+
static void gvfs_load_config_value(struct repository *r)
23+
{
24+
if (gvfs_config_loaded && gvfs_repo == r)
25+
return;
26+
27+
if (r) {
28+
repo_config_get_bool_or_int(r, "core.gvfs",
29+
&core_gvfs_is_bool, &core_gvfs);
30+
} else if (startup_info->have_repository == 0)
31+
read_early_config(the_repository, early_core_gvfs_config, NULL);
32+
else
33+
repo_config_get_bool_or_int(the_repository, "core.gvfs",
34+
&core_gvfs_is_bool, &core_gvfs);
35+
36+
/* Turn on all bits if a bool was set in the settings */
37+
if (core_gvfs_is_bool && core_gvfs)
38+
core_gvfs = -1;
39+
40+
gvfs_config_loaded = 1;
41+
gvfs_repo = r;
42+
}
43+
44+
int gvfs_config_is_set(struct repository *r, int mask)
45+
{
46+
gvfs_load_config_value(r);
47+
return (core_gvfs & mask) == mask;
48+
}

gvfs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#ifndef GVFS_H
22
#define GVFS_H
33

4+
struct repository;
5+
46
/*
57
* This file is for the specific settings and methods
68
* used for GVFS functionality
79
*/
810

11+
int gvfs_config_is_set(struct repository *r, int mask);
12+
913
#endif /* GVFS_H */

meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ libgit_sources = [
353353
'gpg-interface.c',
354354
'graph.c',
355355
'grep.c',
356+
'gvfs.c',
356357
'hash-lookup.c',
357358
'hash.c',
358359
'hashmap.c',

0 commit comments

Comments
 (0)