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

Function add_config_scope_arg

config.c:2104–2145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2102}
2103
2104static void add_config_scope_arg(struct repository *repo, struct strbuf *buf,
2105 struct comment_char_config_item *item)
2106{
2107 char *global_config = git_global_config();
2108 char *system_config = git_system_config();
2109
2110 if (item->scope == CONFIG_SCOPE_SYSTEM && access(item->path, W_OK)) {
2111 /*
2112 * If the user cannot write to the system config recommend
2113 * setting the global config instead.
2114 */
2115 strbuf_addstr(buf, "--global ");
2116 } else if (fspatheq(item->path, system_config)) {
2117 strbuf_addstr(buf, "--system ");
2118 } else if (fspatheq(item->path, global_config)) {
2119 strbuf_addstr(buf, "--global ");
2120 } else if (fspatheq(item->path,
2121 mkpath("%s/config",
2122 repo_get_git_dir(repo)))) {
2123 ; /* --local is the default */
2124 } else if (fspatheq(item->path,
2125 mkpath("%s/config.worktree",
2126 repo_get_common_dir(repo)))) {
2127 strbuf_addstr(buf, "--worktree ");
2128 } else {
2129 const char *path = item->path;
2130 const char *home = getenv("HOME");
2131
2132 strbuf_addstr(buf, "--file ");
2133 if (home && !fspathncmp(path, home, strlen(home))) {
2134 path += strlen(home);
2135 if (!fspathncmp(path, "/", 1))
2136 path++;
2137 strbuf_addstr(buf, "~/");
2138 }
2139 sq_quote_buf_pretty(buf, path);
2140 strbuf_addch(buf, ' ');
2141 }
2142
2143 free(global_config);
2144 free(system_config);
2145}
2146
2147static bool can_unset_comment_char_config(struct comment_char_config *config)
2148{

Callers 2

add_comment_char_adviceFunction · 0.85

Calls 9

git_global_configFunction · 0.85
git_system_configFunction · 0.85
strbuf_addstrFunction · 0.85
fspatheqFunction · 0.85
mkpathFunction · 0.85
repo_get_git_dirFunction · 0.85
repo_get_common_dirFunction · 0.85
sq_quote_buf_prettyFunction · 0.85
strbuf_addchFunction · 0.85

Tested by

no test coverage detected