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

Function submodule_uses_worktrees

worktree.c:536–581  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534}
535
536int submodule_uses_worktrees(const char *path)
537{
538 char *submodule_gitdir;
539 struct strbuf sb = STRBUF_INIT, err = STRBUF_INIT;
540 DIR *dir;
541 struct dirent *d;
542 int ret = 0;
543 struct repository_format format = REPOSITORY_FORMAT_INIT;
544
545 submodule_gitdir = repo_submodule_path(the_repository,
546 path, "%s", "");
547 if (!submodule_gitdir)
548 return 0;
549
550 /* The env would be set for the superproject. */
551 get_common_dir_noenv(&sb, submodule_gitdir);
552 free(submodule_gitdir);
553
554 strbuf_addstr(&sb, "/config");
555 read_repository_format(&format, sb.buf);
556 if (verify_repository_format(&format, &err)) {
557 strbuf_release(&err);
558 strbuf_release(&sb);
559 clear_repository_format(&format);
560 return 1;
561 }
562 clear_repository_format(&format);
563 strbuf_release(&err);
564
565 /* Replace config by worktrees. */
566 strbuf_setlen(&sb, sb.len - strlen("config"));
567 strbuf_addstr(&sb, "worktrees");
568
569 /* See if there is any file inside the worktrees directory. */
570 dir = opendir(sb.buf);
571 strbuf_release(&sb);
572
573 if (!dir)
574 return 0;
575
576 d = readdir_skip_dot_and_dotdot(dir);
577 if (d)
578 ret = 1;
579 closedir(dir);
580 return ret;
581}
582
583void strbuf_worktree_ref(const struct worktree *wt,
584 struct strbuf *sb,

Calls 11

repo_submodule_pathFunction · 0.85
get_common_dir_noenvFunction · 0.85
strbuf_addstrFunction · 0.85
read_repository_formatFunction · 0.85
verify_repository_formatFunction · 0.85
strbuf_releaseFunction · 0.85
clear_repository_formatFunction · 0.85
strbuf_setlenFunction · 0.85
opendirFunction · 0.85
closedirFunction · 0.85

Tested by

no test coverage detected