line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
* Copyright (C) the libgit2 contributors. All rights reserved. |
3
|
|
|
|
|
|
|
* |
4
|
|
|
|
|
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with |
5
|
|
|
|
|
|
|
* a Linking Exception. For full terms see the included COPYING file. |
6
|
|
|
|
|
|
|
*/ |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#include "sysdir.h" |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "runtime.h" |
11
|
|
|
|
|
|
|
#include "str.h" |
12
|
|
|
|
|
|
|
#include "fs_path.h" |
13
|
|
|
|
|
|
|
#include |
14
|
|
|
|
|
|
|
#if GIT_WIN32 |
15
|
|
|
|
|
|
|
#include "win32/findfile.h" |
16
|
|
|
|
|
|
|
#else |
17
|
|
|
|
|
|
|
#include |
18
|
|
|
|
|
|
|
#include |
19
|
|
|
|
|
|
|
#endif |
20
|
|
|
|
|
|
|
|
21
|
87
|
|
|
|
|
|
static int git_sysdir_guess_programdata_dirs(git_str *out) |
22
|
|
|
|
|
|
|
{ |
23
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
24
|
|
|
|
|
|
|
return git_win32__find_programdata_dirs(out); |
25
|
|
|
|
|
|
|
#else |
26
|
87
|
|
|
|
|
|
git_str_clear(out); |
27
|
87
|
|
|
|
|
|
return 0; |
28
|
|
|
|
|
|
|
#endif |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
87
|
|
|
|
|
|
static int git_sysdir_guess_system_dirs(git_str *out) |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
34
|
|
|
|
|
|
|
return git_win32__find_system_dirs(out, "etc"); |
35
|
|
|
|
|
|
|
#else |
36
|
87
|
|
|
|
|
|
return git_str_sets(out, "/etc"); |
37
|
|
|
|
|
|
|
#endif |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#ifndef GIT_WIN32 |
41
|
0
|
|
|
|
|
|
static int get_passwd_home(git_str *out, uid_t uid) |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
struct passwd pwd, *pwdptr; |
44
|
0
|
|
|
|
|
|
char *buf = NULL; |
45
|
|
|
|
|
|
|
long buflen; |
46
|
|
|
|
|
|
|
int error; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
GIT_ASSERT_ARG(out); |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ((buflen = sysconf(_SC_GETPW_R_SIZE_MAX)) == -1) |
51
|
0
|
|
|
|
|
|
buflen = 1024; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
do { |
54
|
0
|
|
|
|
|
|
buf = git__realloc(buf, buflen); |
55
|
0
|
|
|
|
|
|
error = getpwuid_r(uid, &pwd, buf, buflen, &pwdptr); |
56
|
0
|
|
|
|
|
|
buflen *= 2; |
57
|
0
|
0
|
|
|
|
|
} while (error == ERANGE && buflen <= 8192); |
|
|
0
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if (error) { |
60
|
0
|
|
|
|
|
|
git_error_set(GIT_ERROR_OS, "failed to get passwd entry"); |
61
|
0
|
|
|
|
|
|
goto out; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if (!pwdptr) { |
65
|
0
|
|
|
|
|
|
git_error_set(GIT_ERROR_OS, "no passwd entry found for user"); |
66
|
0
|
|
|
|
|
|
goto out; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if ((error = git_str_puts(out, pwdptr->pw_dir)) < 0) |
70
|
0
|
|
|
|
|
|
goto out; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
out: |
73
|
0
|
|
|
|
|
|
git__free(buf); |
74
|
0
|
|
|
|
|
|
return error; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
#endif |
77
|
|
|
|
|
|
|
|
78
|
87
|
|
|
|
|
|
static int git_sysdir_guess_global_dirs(git_str *out) |
79
|
|
|
|
|
|
|
{ |
80
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
81
|
|
|
|
|
|
|
return git_win32__find_global_dirs(out); |
82
|
|
|
|
|
|
|
#else |
83
|
|
|
|
|
|
|
int error; |
84
|
|
|
|
|
|
|
uid_t uid, euid; |
85
|
|
|
|
|
|
|
const char *sandbox_id; |
86
|
|
|
|
|
|
|
|
87
|
87
|
|
|
|
|
|
uid = getuid(); |
88
|
87
|
|
|
|
|
|
euid = geteuid(); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
/** |
91
|
|
|
|
|
|
|
* If APP_SANDBOX_CONTAINER_ID is set, we are running in a |
92
|
|
|
|
|
|
|
* sandboxed environment on macOS. |
93
|
|
|
|
|
|
|
*/ |
94
|
87
|
|
|
|
|
|
sandbox_id = getenv("APP_SANDBOX_CONTAINER_ID"); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
/* |
97
|
|
|
|
|
|
|
* In case we are running setuid, use the configuration |
98
|
|
|
|
|
|
|
* of the effective user. |
99
|
|
|
|
|
|
|
* |
100
|
|
|
|
|
|
|
* If we are running in a sandboxed environment on macOS, |
101
|
|
|
|
|
|
|
* we have to get the HOME dir from the password entry file. |
102
|
|
|
|
|
|
|
*/ |
103
|
87
|
50
|
|
|
|
|
if (!sandbox_id && uid == euid) |
|
|
50
|
|
|
|
|
|
104
|
87
|
|
|
|
|
|
error = git__getenv(out, "HOME"); |
105
|
|
|
|
|
|
|
else |
106
|
0
|
|
|
|
|
|
error = get_passwd_home(out, euid); |
107
|
|
|
|
|
|
|
|
108
|
87
|
50
|
|
|
|
|
if (error == GIT_ENOTFOUND) { |
109
|
0
|
|
|
|
|
|
git_error_clear(); |
110
|
0
|
|
|
|
|
|
error = 0; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
87
|
|
|
|
|
|
return error; |
114
|
|
|
|
|
|
|
#endif |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
87
|
|
|
|
|
|
static int git_sysdir_guess_xdg_dirs(git_str *out) |
118
|
|
|
|
|
|
|
{ |
119
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
120
|
|
|
|
|
|
|
return git_win32__find_xdg_dirs(out); |
121
|
|
|
|
|
|
|
#else |
122
|
87
|
|
|
|
|
|
git_str env = GIT_STR_INIT; |
123
|
|
|
|
|
|
|
int error; |
124
|
|
|
|
|
|
|
uid_t uid, euid; |
125
|
|
|
|
|
|
|
|
126
|
87
|
|
|
|
|
|
uid = getuid(); |
127
|
87
|
|
|
|
|
|
euid = geteuid(); |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
/* |
130
|
|
|
|
|
|
|
* In case we are running setuid, only look up passwd |
131
|
|
|
|
|
|
|
* directory of the effective user. |
132
|
|
|
|
|
|
|
*/ |
133
|
87
|
50
|
|
|
|
|
if (uid == euid) { |
134
|
87
|
50
|
|
|
|
|
if ((error = git__getenv(&env, "XDG_CONFIG_HOME")) == 0) |
135
|
0
|
|
|
|
|
|
error = git_str_joinpath(out, env.ptr, "git"); |
136
|
|
|
|
|
|
|
|
137
|
87
|
50
|
|
|
|
|
if (error == GIT_ENOTFOUND && (error = git__getenv(&env, "HOME")) == 0) |
|
|
50
|
|
|
|
|
|
138
|
87
|
|
|
|
|
|
error = git_str_joinpath(out, env.ptr, ".config/git"); |
139
|
|
|
|
|
|
|
} else { |
140
|
0
|
0
|
|
|
|
|
if ((error = get_passwd_home(&env, euid)) == 0) |
141
|
0
|
|
|
|
|
|
error = git_str_joinpath(out, env.ptr, ".config/git"); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
87
|
50
|
|
|
|
|
if (error == GIT_ENOTFOUND) { |
145
|
0
|
|
|
|
|
|
git_error_clear(); |
146
|
0
|
|
|
|
|
|
error = 0; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
87
|
|
|
|
|
|
git_str_dispose(&env); |
150
|
87
|
|
|
|
|
|
return error; |
151
|
|
|
|
|
|
|
#endif |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
87
|
|
|
|
|
|
static int git_sysdir_guess_template_dirs(git_str *out) |
155
|
|
|
|
|
|
|
{ |
156
|
|
|
|
|
|
|
#ifdef GIT_WIN32 |
157
|
|
|
|
|
|
|
return git_win32__find_system_dirs(out, "share/git-core/templates"); |
158
|
|
|
|
|
|
|
#else |
159
|
87
|
|
|
|
|
|
return git_str_sets(out, "/usr/share/git-core/templates"); |
160
|
|
|
|
|
|
|
#endif |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
struct git_sysdir__dir { |
164
|
|
|
|
|
|
|
git_str buf; |
165
|
|
|
|
|
|
|
int (*guess)(git_str *out); |
166
|
|
|
|
|
|
|
}; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
static struct git_sysdir__dir git_sysdir__dirs[] = { |
169
|
|
|
|
|
|
|
{ GIT_STR_INIT, git_sysdir_guess_system_dirs }, |
170
|
|
|
|
|
|
|
{ GIT_STR_INIT, git_sysdir_guess_global_dirs }, |
171
|
|
|
|
|
|
|
{ GIT_STR_INIT, git_sysdir_guess_xdg_dirs }, |
172
|
|
|
|
|
|
|
{ GIT_STR_INIT, git_sysdir_guess_programdata_dirs }, |
173
|
|
|
|
|
|
|
{ GIT_STR_INIT, git_sysdir_guess_template_dirs }, |
174
|
|
|
|
|
|
|
}; |
175
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
static void git_sysdir_global_shutdown(void) |
177
|
|
|
|
|
|
|
{ |
178
|
|
|
|
|
|
|
size_t i; |
179
|
|
|
|
|
|
|
|
180
|
0
|
0
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(git_sysdir__dirs); ++i) |
181
|
0
|
|
|
|
|
|
git_str_dispose(&git_sysdir__dirs[i].buf); |
182
|
0
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
87
|
|
|
|
|
|
int git_sysdir_global_init(void) |
185
|
|
|
|
|
|
|
{ |
186
|
|
|
|
|
|
|
size_t i; |
187
|
87
|
|
|
|
|
|
int error = 0; |
188
|
|
|
|
|
|
|
|
189
|
522
|
50
|
|
|
|
|
for (i = 0; !error && i < ARRAY_SIZE(git_sysdir__dirs); i++) |
|
|
100
|
|
|
|
|
|
190
|
435
|
|
|
|
|
|
error = git_sysdir__dirs[i].guess(&git_sysdir__dirs[i].buf); |
191
|
|
|
|
|
|
|
|
192
|
87
|
50
|
|
|
|
|
if (error) |
193
|
0
|
|
|
|
|
|
return error; |
194
|
|
|
|
|
|
|
|
195
|
87
|
|
|
|
|
|
return git_runtime_shutdown_register(git_sysdir_global_shutdown); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
int git_sysdir_reset(void) |
199
|
|
|
|
|
|
|
{ |
200
|
|
|
|
|
|
|
size_t i; |
201
|
0
|
|
|
|
|
|
int error = 0; |
202
|
|
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
for (i = 0; !error && i < ARRAY_SIZE(git_sysdir__dirs); ++i) { |
|
|
0
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
git_str_dispose(&git_sysdir__dirs[i].buf); |
205
|
0
|
|
|
|
|
|
error = git_sysdir__dirs[i].guess(&git_sysdir__dirs[i].buf); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
return error; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
1293
|
|
|
|
|
|
static int git_sysdir_check_selector(git_sysdir_t which) |
212
|
|
|
|
|
|
|
{ |
213
|
1293
|
50
|
|
|
|
|
if (which < ARRAY_SIZE(git_sysdir__dirs)) |
214
|
1293
|
|
|
|
|
|
return 0; |
215
|
|
|
|
|
|
|
|
216
|
0
|
|
|
|
|
|
git_error_set(GIT_ERROR_INVALID, "config directory selector out of range"); |
217
|
0
|
|
|
|
|
|
return -1; |
218
|
|
|
|
|
|
|
} |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
221
|
1293
|
|
|
|
|
|
int git_sysdir_get(const git_str **out, git_sysdir_t which) |
222
|
|
|
|
|
|
|
{ |
223
|
1293
|
50
|
|
|
|
|
GIT_ASSERT_ARG(out); |
224
|
|
|
|
|
|
|
|
225
|
1293
|
|
|
|
|
|
*out = NULL; |
226
|
|
|
|
|
|
|
|
227
|
1293
|
50
|
|
|
|
|
GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which)); |
228
|
|
|
|
|
|
|
|
229
|
1293
|
|
|
|
|
|
*out = &git_sysdir__dirs[which].buf; |
230
|
1293
|
|
|
|
|
|
return 0; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
#define PATH_MAGIC "$PATH" |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
int git_sysdir_set(git_sysdir_t which, const char *search_path) |
236
|
|
|
|
|
|
|
{ |
237
|
0
|
|
|
|
|
|
const char *expand_path = NULL; |
238
|
0
|
|
|
|
|
|
git_str merge = GIT_STR_INIT; |
239
|
|
|
|
|
|
|
|
240
|
0
|
0
|
|
|
|
|
GIT_ERROR_CHECK_ERROR(git_sysdir_check_selector(which)); |
241
|
|
|
|
|
|
|
|
242
|
0
|
0
|
|
|
|
|
if (search_path != NULL) |
243
|
0
|
|
|
|
|
|
expand_path = strstr(search_path, PATH_MAGIC); |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
/* reset the default if this path has been cleared */ |
246
|
0
|
0
|
|
|
|
|
if (!search_path) |
247
|
0
|
|
|
|
|
|
git_sysdir__dirs[which].guess(&git_sysdir__dirs[which].buf); |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
/* if $PATH is not referenced, then just set the path */ |
250
|
0
|
0
|
|
|
|
|
if (!expand_path) { |
251
|
0
|
0
|
|
|
|
|
if (search_path) |
252
|
0
|
|
|
|
|
|
git_str_sets(&git_sysdir__dirs[which].buf, search_path); |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
goto done; |
255
|
|
|
|
|
|
|
} |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
/* otherwise set to join(before $PATH, old value, after $PATH) */ |
258
|
0
|
0
|
|
|
|
|
if (expand_path > search_path) |
259
|
0
|
|
|
|
|
|
git_str_set(&merge, search_path, expand_path - search_path); |
260
|
|
|
|
|
|
|
|
261
|
0
|
0
|
|
|
|
|
if (git_str_len(&git_sysdir__dirs[which].buf)) |
262
|
0
|
|
|
|
|
|
git_str_join(&merge, GIT_PATH_LIST_SEPARATOR, |
263
|
0
|
|
|
|
|
|
merge.ptr, git_sysdir__dirs[which].buf.ptr); |
264
|
|
|
|
|
|
|
|
265
|
0
|
|
|
|
|
|
expand_path += strlen(PATH_MAGIC); |
266
|
0
|
0
|
|
|
|
|
if (*expand_path) |
267
|
0
|
|
|
|
|
|
git_str_join(&merge, GIT_PATH_LIST_SEPARATOR, merge.ptr, expand_path); |
268
|
|
|
|
|
|
|
|
269
|
0
|
|
|
|
|
|
git_str_swap(&git_sysdir__dirs[which].buf, &merge); |
270
|
0
|
|
|
|
|
|
git_str_dispose(&merge); |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
done: |
273
|
0
|
0
|
|
|
|
|
if (git_str_oom(&git_sysdir__dirs[which].buf)) |
274
|
0
|
|
|
|
|
|
return -1; |
275
|
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
|
return 0; |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
|
279
|
1292
|
|
|
|
|
|
static int git_sysdir_find_in_dirlist( |
280
|
|
|
|
|
|
|
git_str *path, |
281
|
|
|
|
|
|
|
const char *name, |
282
|
|
|
|
|
|
|
git_sysdir_t which, |
283
|
|
|
|
|
|
|
const char *label) |
284
|
|
|
|
|
|
|
{ |
285
|
|
|
|
|
|
|
size_t len; |
286
|
1292
|
|
|
|
|
|
const char *scan, *next = NULL; |
287
|
|
|
|
|
|
|
const git_str *syspath; |
288
|
|
|
|
|
|
|
|
289
|
1292
|
50
|
|
|
|
|
GIT_ERROR_CHECK_ERROR(git_sysdir_get(&syspath, which)); |
290
|
1292
|
50
|
|
|
|
|
if (!syspath || !git_str_len(syspath)) |
|
|
100
|
|
|
|
|
|
291
|
|
|
|
|
|
|
goto done; |
292
|
|
|
|
|
|
|
|
293
|
2375
|
100
|
|
|
|
|
for (scan = git_str_cstr(syspath); scan; scan = next) { |
294
|
|
|
|
|
|
|
/* find unescaped separator or end of string */ |
295
|
7506
|
100
|
|
|
|
|
for (next = scan; *next; ++next) { |
296
|
6284
|
50
|
|
|
|
|
if (*next == GIT_PATH_LIST_SEPARATOR && |
|
|
0
|
|
|
|
|
|
297
|
0
|
0
|
|
|
|
|
(next <= scan || next[-1] != '\\')) |
298
|
|
|
|
|
|
|
break; |
299
|
|
|
|
|
|
|
} |
300
|
|
|
|
|
|
|
|
301
|
1222
|
|
|
|
|
|
len = (size_t)(next - scan); |
302
|
1222
|
50
|
|
|
|
|
next = (*next ? next + 1 : NULL); |
303
|
1222
|
50
|
|
|
|
|
if (!len) |
304
|
0
|
|
|
|
|
|
continue; |
305
|
|
|
|
|
|
|
|
306
|
1222
|
50
|
|
|
|
|
GIT_ERROR_CHECK_ERROR(git_str_set(path, scan, len)); |
307
|
1222
|
50
|
|
|
|
|
if (name) |
308
|
1222
|
50
|
|
|
|
|
GIT_ERROR_CHECK_ERROR(git_str_joinpath(path, path->ptr, name)); |
309
|
|
|
|
|
|
|
|
310
|
1222
|
100
|
|
|
|
|
if (git_fs_path_exists(path->ptr)) |
311
|
69
|
|
|
|
|
|
return 0; |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
done: |
315
|
1223
|
50
|
|
|
|
|
if (name) |
316
|
1223
|
|
|
|
|
|
git_error_set(GIT_ERROR_OS, "the %s file '%s' doesn't exist", label, name); |
317
|
|
|
|
|
|
|
else |
318
|
0
|
|
|
|
|
|
git_error_set(GIT_ERROR_OS, "the %s directory doesn't exist", label); |
319
|
1223
|
|
|
|
|
|
git_str_dispose(path); |
320
|
1292
|
|
|
|
|
|
return GIT_ENOTFOUND; |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
1050
|
|
|
|
|
|
int git_sysdir_find_system_file(git_str *path, const char *filename) |
324
|
|
|
|
|
|
|
{ |
325
|
1050
|
|
|
|
|
|
return git_sysdir_find_in_dirlist( |
326
|
|
|
|
|
|
|
path, filename, GIT_SYSDIR_SYSTEM, "system"); |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
70
|
|
|
|
|
|
int git_sysdir_find_global_file(git_str *path, const char *filename) |
330
|
|
|
|
|
|
|
{ |
331
|
70
|
|
|
|
|
|
return git_sysdir_find_in_dirlist( |
332
|
|
|
|
|
|
|
path, filename, GIT_SYSDIR_GLOBAL, "global"); |
333
|
|
|
|
|
|
|
} |
334
|
|
|
|
|
|
|
|
335
|
102
|
|
|
|
|
|
int git_sysdir_find_xdg_file(git_str *path, const char *filename) |
336
|
|
|
|
|
|
|
{ |
337
|
102
|
|
|
|
|
|
return git_sysdir_find_in_dirlist( |
338
|
|
|
|
|
|
|
path, filename, GIT_SYSDIR_XDG, "global/xdg"); |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
|
341
|
70
|
|
|
|
|
|
int git_sysdir_find_programdata_file(git_str *path, const char *filename) |
342
|
|
|
|
|
|
|
{ |
343
|
70
|
|
|
|
|
|
return git_sysdir_find_in_dirlist( |
344
|
|
|
|
|
|
|
path, filename, GIT_SYSDIR_PROGRAMDATA, "ProgramData"); |
345
|
|
|
|
|
|
|
} |
346
|
|
|
|
|
|
|
|
347
|
0
|
|
|
|
|
|
int git_sysdir_find_template_dir(git_str *path) |
348
|
|
|
|
|
|
|
{ |
349
|
0
|
|
|
|
|
|
return git_sysdir_find_in_dirlist( |
350
|
|
|
|
|
|
|
path, NULL, GIT_SYSDIR_TEMPLATE, "template"); |
351
|
|
|
|
|
|
|
} |
352
|
|
|
|
|
|
|
|
353
|
0
|
|
|
|
|
|
int git_sysdir_expand_global_file(git_str *path, const char *filename) |
354
|
|
|
|
|
|
|
{ |
355
|
|
|
|
|
|
|
int error; |
356
|
|
|
|
|
|
|
|
357
|
0
|
0
|
|
|
|
|
if ((error = git_sysdir_find_global_file(path, NULL)) == 0) { |
358
|
0
|
0
|
|
|
|
|
if (filename) |
359
|
0
|
|
|
|
|
|
error = git_str_joinpath(path, path->ptr, filename); |
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
|
362
|
0
|
|
|
|
|
|
return error; |
363
|
|
|
|
|
|
|
} |