FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
git2cpp/src/utils/config_overrides.cpp at main · QuantStack/git2cpp · GitHub
QuantStack
git2cpp
Repository navigation
Code
Issues
6
(6)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
git2cpp
/
src
/
utils
/
config_overrides.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (45 loc) · 2.26 KB
Breadcrumbs
git2cpp
/
src
/
utils
/
config_overrides.cpp
Copy path
File metadata and controls
51 lines (45 loc) · 2.26 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#
include
"
config_overrides.hpp
"
#
ifdef
EMSCRIPTEN
#
include
<
iterator
>
#
include
<
git2/sys/config.h
>
#
include
"
git_exception.hpp
"
#
endif
void
apply_config_overrides
(
[[maybe_unused]]
git_repository* repo)
{
#
ifdef
EMSCRIPTEN
//
Config values to override, each in "name=value" form. core.filemode is disabled because
//
the emscripten filesystem does support executable file permissions but some JupyterLite
//
drive implementations do not.
const
char
* values[] = {
"
core.filemode=false
"
};
//
Create an in-memory config backend holding these values. This backend is read-only, so
//
any config writes (e.g. `git config` or values set by clone/init) skip it and go to the
//
highest-priority writable backend instead, which is the repository's own config file.
//
The overrides are therefore never persisted to disk. backend_type is a label that
//
identifies where these entries came from when inspecting a config entry's origin.
git_config_backend* backend =
nullptr
;
git_config_backend_memory_options opts =
GIT_CONFIG_BACKEND_MEMORY_OPTIONS_INIT
;
opts.
backend_type
=
"
git2cpp-overrides
"
;
throw_if_error
(
git_config_backend_from_values
(&backend, values,
std::size
(values), &opts));
//
git_repository_config returns the repository's cached, shared config object rather than a
//
copy, so adding a backend to it affects all later config lookups through this repository.
//
GIT_CONFIG_LEVEL_APP is the highest priority level, above the local, global and system
//
config files, so these values win over any existing setting. The repo is passed so that
//
conditional includes can be evaluated, and force=0 means fail rather than replace if a
//
backend already exists at this level.
git_config* cfg =
nullptr
;
int
error =
git_repository_config
(&cfg, repo);
if
(error ==
0
)
{
error =
git_config_add_backend
(cfg, backend,
GIT_CONFIG_LEVEL_APP
, repo,
0
);
//
Only releases our reference; the repository still holds the config and its backends.
git_config_free
(cfg);
}
if
(error <
0
)
{
//
On success ownership of the backend passes to the config, but on failure it is still
//
ours to free.
backend->
free
(backend);
throw_if_error
(error);
}
#
endif
}
Back
|
FazBrowse Home
|
New Git URL