MCPcopy Create free account
hub / github.com/git/git / check_filename

Function check_filename

setup.c:173–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173int check_filename(const char *prefix, const char *arg)
174{
175 char *to_free = NULL;
176 struct stat st;
177
178 if (skip_prefix(arg, ":/", &arg)) {
179 if (!*arg) /* ":/" is root dir, always exists */
180 return 1;
181 prefix = NULL;
182 } else if (skip_prefix(arg, ":!", &arg) ||
183 skip_prefix(arg, ":^", &arg)) {
184 if (!*arg) /* excluding everything is silly, but allowed */
185 return 1;
186 }
187
188 if (prefix)
189 arg = to_free = prefix_filename(prefix, arg);
190
191 if (!lstat(arg, &st)) {
192 free(to_free);
193 return 1; /* file exists */
194 }
195 if (is_missing_file_error(errno)) {
196 free(to_free);
197 return 0; /* file does not exist */
198 }
199 die_errno(_("failed to stat '%s'"), arg);
200}
201
202static void NORETURN die_verify_filename(struct repository *r,
203 const char *prefix,

Callers 3

verify_filenameFunction · 0.85
verify_non_filenameFunction · 0.85
parse_branchname_argFunction · 0.85

Calls 3

prefix_filenameFunction · 0.85
is_missing_file_errorFunction · 0.85
die_errnoFunction · 0.85

Tested by

no test coverage detected