setup: stop using `the_repository` in `verify_non_filename()`
Stop using `the_repository` in `verify_non_filename()` and instead accept the repository as a parameter. The injection of `the_repository` is thus bumped one level higher, where callers now pass it in explicitly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>main
parent
6e7e50cc7b
commit
920dba4581
|
|
@ -1484,7 +1484,7 @@ static int parse_branchname_arg(int argc, const char **argv,
|
|||
* it would be extremely annoying.
|
||||
*/
|
||||
if (argc)
|
||||
verify_non_filename(opts->prefix, arg);
|
||||
verify_non_filename(the_repository, opts->prefix, arg);
|
||||
} else if (opts->accept_pathspec) {
|
||||
argcount++;
|
||||
argv++;
|
||||
|
|
|
|||
|
|
@ -1151,7 +1151,7 @@ int cmd_grep(int argc,
|
|||
|
||||
object = parse_object_or_die(the_repository, &oid, arg);
|
||||
if (!seen_dashdash)
|
||||
verify_non_filename(prefix, arg);
|
||||
verify_non_filename(the_repository, prefix, arg);
|
||||
add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
|
||||
object_context_release(&oc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ static void parse_args(struct pathspec *pathspec,
|
|||
* Ok, argv[0] looks like a commit/tree; it should not
|
||||
* be a filename.
|
||||
*/
|
||||
verify_non_filename(prefix, argv[0]);
|
||||
verify_non_filename(the_repository, prefix, argv[0]);
|
||||
rev = *argv++;
|
||||
} else {
|
||||
/* Otherwise we treat this as a filename */
|
||||
|
|
|
|||
|
|
@ -2072,7 +2072,7 @@ static int handle_dotdot_1(const char *a_name, const char *b_name,
|
|||
return -1;
|
||||
|
||||
if (!cant_be_filename) {
|
||||
verify_non_filename(revs->prefix, full_name);
|
||||
verify_non_filename(the_repository, revs->prefix, full_name);
|
||||
}
|
||||
|
||||
a_obj = parse_object(revs->repo, &a_oid);
|
||||
|
|
@ -2225,7 +2225,7 @@ static int handle_revision_arg_1(const char *arg_, struct rev_info *revs, int fl
|
|||
goto out;
|
||||
}
|
||||
if (!cant_be_filename)
|
||||
verify_non_filename(revs->prefix, arg);
|
||||
verify_non_filename(the_repository, revs->prefix, arg);
|
||||
object = get_reference(revs, arg, &oid, flags ^ local_flags);
|
||||
if (!object) {
|
||||
ret = (revs->ignore_missing || revs->do_not_die_on_missing_objects) ? 0 : -1;
|
||||
|
|
|
|||
4
setup.c
4
setup.c
|
|
@ -297,9 +297,9 @@ void verify_filename(struct repository *repo,
|
|||
* and we parsed the arg as a refname. It should not be interpretable
|
||||
* as a filename.
|
||||
*/
|
||||
void verify_non_filename(const char *prefix, const char *arg)
|
||||
void verify_non_filename(struct repository *repo, const char *prefix, const char *arg)
|
||||
{
|
||||
if (!is_inside_work_tree(the_repository) || is_inside_git_dir(the_repository))
|
||||
if (!is_inside_work_tree(repo) || is_inside_git_dir(repo))
|
||||
return;
|
||||
if (*arg == '-')
|
||||
return; /* flag */
|
||||
|
|
|
|||
2
setup.h
2
setup.h
|
|
@ -146,7 +146,7 @@ void verify_filename(struct repository *repo,
|
|||
const char *prefix,
|
||||
const char *name,
|
||||
int diagnose_misspelt_rev);
|
||||
void verify_non_filename(const char *prefix, const char *name);
|
||||
void verify_non_filename(struct repository *repo, const char *prefix, const char *name);
|
||||
int path_inside_repo(struct repository *repo, const char *prefix, const char *path);
|
||||
|
||||
void sanitize_stdfds(void);
|
||||
|
|
|
|||
Loading…
Reference in New Issue