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

Function is_main_worktree_bare

worktree.c:96–109  ·  view source on GitHub ↗

* When in a secondary worktree, and when extensions.worktreeConfig * is true, only $commondir/config and $commondir/worktrees/ / * config.worktree are consulted, hence any core.bare=true setting in * $commondir/config.worktree gets overlooked. Thus, check it manually * to determine if the repository is bare. */

Source from the content-addressed store, hash-verified

94* to determine if the repository is bare.
95*/
96static int is_main_worktree_bare(struct repository *repo)
97{
98 int bare = 0;
99 struct config_set cs = {0};
100 char *worktree_config = xstrfmt("%s/config.worktree", repo_get_common_dir(repo));
101
102 git_configset_init(&cs);
103 git_configset_add_file(&cs, worktree_config);
104 git_configset_get_bool(&cs, "core.bare", &bare);
105
106 git_configset_clear(&cs);
107 free(worktree_config);
108 return bare;
109}
110
111/**
112 * get the main worktree

Callers 1

get_main_worktreeFunction · 0.85

Calls 6

xstrfmtFunction · 0.85
repo_get_common_dirFunction · 0.85
git_configset_initFunction · 0.85
git_configset_add_fileFunction · 0.85
git_configset_get_boolFunction · 0.85
git_configset_clearFunction · 0.85

Tested by

no test coverage detected