MCPcopy Index your code
hub / github.com/git/git / submodule_uses_gitfile

Function submodule_uses_gitfile

submodule.c:1962–1994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1960}
1961
1962int submodule_uses_gitfile(const char *path)
1963{
1964 struct child_process cp = CHILD_PROCESS_INIT;
1965 struct strbuf buf = STRBUF_INIT;
1966 const char *git_dir;
1967
1968 if (validate_submodule_path(path) < 0)
1969 exit(128);
1970
1971 strbuf_addf(&buf, "%s/.git", path);
1972 git_dir = read_gitfile(buf.buf);
1973 if (!git_dir) {
1974 strbuf_release(&buf);
1975 return 0;
1976 }
1977 strbuf_release(&buf);
1978
1979 /* Now test that all nested submodules use a gitfile too */
1980 strvec_pushl(&cp.args,
1981 "submodule", "foreach", "--quiet", "--recursive",
1982 "test -f .git", NULL);
1983
1984 prepare_submodule_repo_env(&cp.env);
1985 cp.git_cmd = 1;
1986 cp.no_stdin = 1;
1987 cp.no_stderr = 1;
1988 cp.no_stdout = 1;
1989 cp.dir = path;
1990 if (run_command(&cp))
1991 return 0;
1992
1993 return 1;
1994}
1995
1996/*
1997 * Check if it is a bad idea to remove a submodule, i.e. if we'd lose data

Callers 3

bad_to_remove_submoduleFunction · 0.85
submodule_move_headFunction · 0.85

Calls 6

validate_submodule_pathFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_releaseFunction · 0.85
strvec_pushlFunction · 0.85
run_commandFunction · 0.85

Tested by

no test coverage detected